From ea4c55a6ec3271d260ec7ffd27115e781d0346a7 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Thu, 19 Feb 2026 14:27:16 -0800 Subject: [PATCH] added ListPolicies GetPolicy DeletePolicy --- AWS-IAM-CLI.md | 51 ++++++++++++++++++++++++++++++++++++++++++++--- Amazon-IAM-API.md | 23 +++++++++++++++++++-- 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/AWS-IAM-CLI.md b/AWS-IAM-CLI.md index f118245..0c1cd77 100644 --- a/AWS-IAM-CLI.md +++ b/AWS-IAM-CLI.md @@ -264,7 +264,43 @@ aws --endpoint $AWS_ENDPOINT iam delete-user-policy \ Managed policies are standalone policies that are stored in the configuration and can be attached to multiple users. -#### Attach a Managed Policy +#### Create a Managed Policy + +```bash +# Create policy document +cat > readonly-policy.json << 'EOF' +{ + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": ["s3:Get*", "s3:List*"], + "Resource": ["*"] + } + ] +} +EOF + +# Create the policy +aws --endpoint $AWS_ENDPOINT iam create-policy \ + --policy-name ReadOnlyPolicy \ + --policy-document file://readonly-policy.json +``` + +#### List All Managed Policies + +```bash +aws --endpoint $AWS_ENDPOINT iam list-policies +``` + +#### Get Managed Policy Details + +```bash +aws --endpoint $AWS_ENDPOINT iam get-policy \ + --policy-arn arn:aws:iam::seaweedfs:policy/ReadOnlyPolicy +``` + +#### Attach a Managed Policy to a User ```bash aws --endpoint $AWS_ENDPOINT iam attach-user-policy \ @@ -272,13 +308,13 @@ aws --endpoint $AWS_ENDPOINT iam attach-user-policy \ --policy-arn arn:aws:iam::seaweedfs:policy/ReadOnlyPolicy ``` -#### List Attached Managed Policies +#### List Managed Policies Attached to a User ```bash aws --endpoint $AWS_ENDPOINT iam list-attached-user-policies --user-name bob ``` -#### Detach a Managed Policy +#### Detach a Managed Policy from a User ```bash aws --endpoint $AWS_ENDPOINT iam detach-user-policy \ @@ -286,6 +322,15 @@ aws --endpoint $AWS_ENDPOINT iam detach-user-policy \ --policy-arn arn:aws:iam::seaweedfs:policy/ReadOnlyPolicy ``` +#### Delete a Managed Policy + +> **Note**: A policy must be detached from all users before it can be deleted. + +```bash +aws --endpoint $AWS_ENDPOINT iam delete-policy \ + --policy-arn arn:aws:iam::seaweedfs:policy/ReadOnlyPolicy +``` + --- ## Verify Configuration diff --git a/Amazon-IAM-API.md b/Amazon-IAM-API.md index 9656f5e..8257653 100644 --- a/Amazon-IAM-API.md +++ b/Amazon-IAM-API.md @@ -60,10 +60,13 @@ weed iam -filer=localhost:8888 -port=8111 | `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 and store a managed policy | 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 | +| `CreatePolicy` | Create and store a managed policy | Admin only | +| `DeletePolicy` | Delete a managed policy | Admin only | +| `ListPolicies` | List managed policies | Admin only | +| `GetPolicy` | Get managed policy metadata | Admin only | | `AttachUserPolicy` | Attach managed policy to user | Admin only | | `DetachUserPolicy` | Remove managed policy from user | Admin only | | `ListAttachedUserPolicies` | List managed policies for user | Admin only | @@ -156,13 +159,29 @@ aws --endpoint $AWS_ENDPOINT iam attach-user-policy \ --user-name alice \ --policy-arn arn:aws:iam::seaweedfs:policy/ReadOnlyPolicy -# List attached managed policies +# List attached managed policies for a user aws --endpoint $AWS_ENDPOINT iam list-attached-user-policies --user-name alice # Detach a managed policy aws --endpoint $AWS_ENDPOINT iam detach-user-policy \ --user-name alice \ --policy-arn arn:aws:iam::seaweedfs:policy/ReadOnlyPolicy + +# Create a managed policy +aws --endpoint $AWS_ENDPOINT iam create-policy \ + --policy-name MyManagedPolicy \ + --policy-document file://policy.json + +# List all managed policies +aws --endpoint $AWS_ENDPOINT iam list-policies + +# Get managed policy metadata +aws --endpoint $AWS_ENDPOINT iam get-policy \ + --policy-arn arn:aws:iam::seaweedfs:policy/MyManagedPolicy + +# Delete a managed policy +aws --endpoint $AWS_ENDPOINT iam delete-policy \ + --policy-arn arn:aws:iam::seaweedfs:policy/MyManagedPolicy ``` ### Self-Service: User Managing Their Own Keys