added ListPolicies GetPolicy DeletePolicy

Chris Lu
2026-02-19 14:27:16 -08:00
parent 109f3acdd6
commit ea4c55a6ec
2 changed files with 69 additions and 5 deletions
+48 -3
@@ -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
+21 -2
@@ -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