Thanks to visit codestin.com
Credit goes to github.com

Skip to content
chrislusf edited this page Dec 15, 2025 · 11 revisions

Amazon IAM API

SeaweedFS provides AWS IAM API compatibility for managing users, access keys, and policies.

Embedded IAM (Default)

Starting with SeaweedFS 3.x, the IAM API is embedded in the S3 server by default. This means:

  • IAM API is available on the same port as S3 (default: 8333)
  • No need to run a separate IAM server
  • Simplified deployment - single process handles both S3 and IAM

Starting S3 with Embedded IAM

# IAM is enabled by default
weed s3 -filer=localhost:8888

# Or with weed server
weed server -s3

# To explicitly disable embedded IAM
weed s3 -iam=false -filer=localhost:8888

Accessing the Embedded IAM API

The IAM API is available at the root path (/) of the S3 server using POST requests with an Action parameter:

# IAM endpoint is the same as S3 endpoint
export AWS_ENDPOINT=http://localhost:8333

Standalone IAM (Deprecated)

Note: The standalone weed iam command is deprecated. Please use the embedded IAM in the S3 server instead.

For backwards compatibility, you can still run a separate IAM server:

weed iam -filer=localhost:8888 -port=8111

Supported IAM Actions

Action Description Self-Service
CreateUser Create a new IAM user Admin only
DeleteUser Delete an IAM user Admin only
GetUser Get user details Yes (own user)
UpdateUser Update user properties Admin only
ListUsers List all users Admin only
SetUserStatus Enable or disable a user Admin only
CreateAccessKey Create access key for user Yes (own keys)
DeleteAccessKey Delete access key Yes (own keys)
UpdateAccessKey Change access key status (Active/Inactive) Yes (own keys)
ListAccessKeys List access keys for user Yes (own keys)
CreatePolicy Validate a policy document Admin only
PutUserPolicy Attach inline policy to user Admin only
GetUserPolicy Get user's inline policy Admin only
DeleteUserPolicy Remove user's inline policy Admin only

Self-Service Operations

Users can manage their own access keys without admin privileges:

  • Create, delete, and list their own access keys
  • View their own user information

Operations on other users require Admin action permission.


Authentication

Setting Up Admin Credentials

Before using the IAM API, create an admin user with the Admin action:

echo 's3.configure -access_key admin_key -secret_key admin_secret -user admin -actions Admin -apply' | weed shell

Using the IAM API

Set environment variables for AWS CLI:

export AWS_ACCESS_KEY_ID=admin_key
export AWS_SECRET_ACCESS_KEY=admin_secret
export AWS_ENDPOINT=http://localhost:8333  # S3/IAM endpoint

Examples

Create a User and Access Key

# Create user
aws --endpoint $AWS_ENDPOINT iam create-user --user-name alice

# Create access key for user
aws --endpoint $AWS_ENDPOINT iam create-access-key --user-name alice

Attach a Policy to User

# Create policy document
cat > policy.json << 'EOF'
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:Get*", "s3:List*"],
      "Resource": ["arn:aws:s3:::my-bucket/*"]
    }
  ]
}
EOF

# Attach policy to user
aws --endpoint $AWS_ENDPOINT iam put-user-policy \
  --user-name alice \
  --policy-name ReadOnlyPolicy \
  --policy-document file://policy.json

List Users and Access Keys

# List all users
aws --endpoint $AWS_ENDPOINT iam list-users

# List access keys for a user
aws --endpoint $AWS_ENDPOINT iam list-access-keys --user-name alice

Self-Service: User Managing Their Own Keys

A non-admin user can manage their own access keys:

# Set credentials for the user
export AWS_ACCESS_KEY_ID=alice_access_key
export AWS_SECRET_ACCESS_KEY=alice_secret_key

# User can create additional access keys for themselves
aws --endpoint $AWS_ENDPOINT iam create-access-key
# (no --user-name needed, defaults to authenticated user)

# List own access keys
aws --endpoint $AWS_ENDPOINT iam list-access-keys

# Deactivate an access key (key rotation)
aws --endpoint $AWS_ENDPOINT iam update-access-key --access-key-id AKIAEXAMPLE --status Inactive

User and Access Key Status Management

SeaweedFS supports enabling/disabling users and access keys without deleting them. This is useful for:

  • Temporary suspension: Disable user access during investigation
  • Key rotation: Deactivate old keys before deletion
  • Offboarding: Disable rather than delete for audit purposes
  • Emergency response: Quickly disable compromised credentials

Disable a User

# Disable a user (all their access keys will stop working)
aws --endpoint $AWS_ENDPOINT iam set-user-status --user-name alice --status Inactive

# Re-enable the user
aws --endpoint $AWS_ENDPOINT iam set-user-status --user-name alice --status Active

Deactivate an Access Key

# Deactivate an access key
aws --endpoint $AWS_ENDPOINT iam update-access-key \
  --user-name alice \
  --access-key-id AKIAEXAMPLE \
  --status Inactive

# Reactivate the access key
aws --endpoint $AWS_ENDPOINT iam update-access-key \
  --user-name alice \
  --access-key-id AKIAEXAMPLE \
  --status Active

Check Access Key Status

# List access keys shows their status
aws --endpoint $AWS_ENDPOINT iam list-access-keys --user-name alice

Output:

{
    "AccessKeyMetadata": [
        {
            "UserName": "alice",
            "AccessKeyId": "X8R439UM7OSQJX28I9QTP",
            "Status": "Active"
        },
        {
            "UserName": "alice", 
            "AccessKeyId": "Y9S540VN8PTRKZ39J0URP",
            "Status": "Inactive"
        }
    ]
}

Configuration Storage

IAM configurations are stored on the filer at /etc/iam/identity.json. Changes are automatically propagated to all S3 servers subscribed to filer metadata events.

You can view the current configuration:

echo 's3.configure' | weed shell

Related Documentation

Introduction

API

Configuration

Filer

Management

Advanced Filer Configurations

Cloud Drive

AWS S3 API

S3 Authentication & IAM

Server-Side Encryption

S3 Client Tools

Machine Learning

HDFS

Replication and Backup

Metadata Change Events

Messaging

Use Cases

Operations

Advanced

Security

Misc Use Case Examples

Clone this wiki locally