awslabs.iam-mcp-server 1.0.1__tar.gz → 1.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/CHANGELOG.md +26 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/Dockerfile +1 -1
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/PKG-INFO +212 -2
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/README.md +211 -1
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/awslabs/iam_mcp_server/__init__.py +1 -1
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/awslabs/iam_mcp_server/context.py +5 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/awslabs/iam_mcp_server/models.py +93 -0
- awslabs_iam_mcp_server-1.0.2/awslabs/iam_mcp_server/server.py +1596 -0
- awslabs_iam_mcp_server-1.0.2/examples/get_policy_document_example.py +93 -0
- awslabs_iam_mcp_server-1.0.2/examples/inline_policy_demo.py +157 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/pyproject.toml +1 -1
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/tests/test_errors.py +83 -0
- awslabs_iam_mcp_server-1.0.2/tests/test_inline_policies.py +558 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/tests/test_server.py +534 -3
- awslabs_iam_mcp_server-1.0.2/uv-requirements.txt +26 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/uv.lock +1 -1
- awslabs_iam_mcp_server-1.0.1/awslabs/iam_mcp_server/server.py +0 -769
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/.gitignore +0 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/DESIGN_COMPLIANCE.md +0 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/LICENSE +0 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/NOTICE +0 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/awslabs/__init__.py +0 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/awslabs/iam_mcp_server/aws_client.py +0 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/awslabs/iam_mcp_server/errors.py +0 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/docker-healthcheck.sh +0 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/run_tests.sh +0 -0
- {awslabs_iam_mcp_server-1.0.1 → awslabs_iam_mcp_server-1.0.2}/tests/test_context.py +0 -0
|
@@ -5,6 +5,32 @@ All notable changes to the AWS IAM MCP Server will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.1.0] - 2025-06-23
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Inline Policy Management**: Full CRUD operations for user and role inline policies
|
|
12
|
+
- `put_user_policy` - Create or update inline policies for IAM users
|
|
13
|
+
- `get_user_policy` - Retrieve inline policy documents for users
|
|
14
|
+
- `delete_user_policy` - Delete inline policies from users
|
|
15
|
+
- `list_user_policies` - List all inline policies for a user
|
|
16
|
+
- `put_role_policy` - Create or update inline policies for IAM roles
|
|
17
|
+
- `get_role_policy` - Retrieve inline policy documents for roles
|
|
18
|
+
- `delete_role_policy` - Delete inline policies from roles
|
|
19
|
+
- `list_role_policies` - List all inline policies for a role
|
|
20
|
+
- New data models for inline policy operations:
|
|
21
|
+
- `InlinePolicy` - Model for inline policy data
|
|
22
|
+
- `InlinePolicyResponse` - Response model for inline policy operations
|
|
23
|
+
- `InlinePolicyListResponse` - Response model for listing inline policies
|
|
24
|
+
- Comprehensive test coverage for all inline policy operations
|
|
25
|
+
- Enhanced documentation with usage examples and best practices
|
|
26
|
+
- Demo script showing inline policy management capabilities
|
|
27
|
+
|
|
28
|
+
### Enhanced
|
|
29
|
+
- Updated server instructions to include inline policy management guidance
|
|
30
|
+
- Added security best practices for inline policy usage
|
|
31
|
+
- Enhanced error handling and validation for policy documents
|
|
32
|
+
- Updated required IAM permissions documentation
|
|
33
|
+
|
|
8
34
|
## [1.0.0] - 2025-06-18
|
|
9
35
|
|
|
10
36
|
### Added
|
|
@@ -35,7 +35,7 @@ COPY . /app
|
|
|
35
35
|
|
|
36
36
|
# Install uv and sync dependencies
|
|
37
37
|
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
38
|
-
pip install uv
|
|
38
|
+
pip install --require-hashes --requirement uv-requirements.txt && \
|
|
39
39
|
uv sync --frozen --no-dev --no-editable
|
|
40
40
|
|
|
41
41
|
# Make the directory just in case it doesn't exist
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: awslabs.iam-mcp-server
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.2
|
|
4
4
|
Summary: An AWS Labs Model Context Protocol (MCP) server for managing AWS IAM resources including users, roles, policies, and permissions
|
|
5
5
|
Project-URL: homepage, https://awslabs.github.io/mcp/
|
|
6
6
|
Project-URL: docs, https://awslabs.github.io/mcp/servers/iam-mcp-server/
|
|
@@ -37,7 +37,9 @@ A Model Context Protocol (MCP) server for comprehensive AWS Identity and Access
|
|
|
37
37
|
### Core IAM Management
|
|
38
38
|
- **User Management**: Create, list, retrieve, and delete IAM users
|
|
39
39
|
- **Role Management**: Create, list, and manage IAM roles with trust policies
|
|
40
|
+
- **Group Management**: Create, list, retrieve, and delete IAM groups with member management
|
|
40
41
|
- **Policy Management**: List and manage IAM policies (managed and inline)
|
|
42
|
+
- **Inline Policy Management**: Full CRUD operations for user and role inline policies
|
|
41
43
|
- **Permission Management**: Attach/detach policies to users and roles
|
|
42
44
|
- **Access Key Management**: Create and delete access keys for users
|
|
43
45
|
- **Security Simulation**: Test policy permissions before applying them
|
|
@@ -104,6 +106,16 @@ The AWS credentials used by this server need the following IAM permissions:
|
|
|
104
106
|
"iam:GetRole",
|
|
105
107
|
"iam:CreateRole",
|
|
106
108
|
"iam:DeleteRole",
|
|
109
|
+
"iam:ListGroups",
|
|
110
|
+
"iam:GetGroup",
|
|
111
|
+
"iam:CreateGroup",
|
|
112
|
+
"iam:DeleteGroup",
|
|
113
|
+
"iam:AddUserToGroup",
|
|
114
|
+
"iam:RemoveUserFromGroup",
|
|
115
|
+
"iam:AttachGroupPolicy",
|
|
116
|
+
"iam:DetachGroupPolicy",
|
|
117
|
+
"iam:ListAttachedGroupPolicies",
|
|
118
|
+
"iam:ListGroupPolicies",
|
|
107
119
|
"iam:ListPolicies",
|
|
108
120
|
"iam:GetPolicy",
|
|
109
121
|
"iam:CreatePolicy",
|
|
@@ -116,13 +128,18 @@ The AWS credentials used by this server need the following IAM permissions:
|
|
|
116
128
|
"iam:ListAttachedRolePolicies",
|
|
117
129
|
"iam:ListUserPolicies",
|
|
118
130
|
"iam:ListRolePolicies",
|
|
131
|
+
"iam:GetUserPolicy",
|
|
132
|
+
"iam:GetRolePolicy",
|
|
133
|
+
"iam:PutUserPolicy",
|
|
134
|
+
"iam:PutRolePolicy",
|
|
119
135
|
"iam:GetGroupsForUser",
|
|
120
136
|
"iam:ListAccessKeys",
|
|
121
137
|
"iam:CreateAccessKey",
|
|
122
138
|
"iam:DeleteAccessKey",
|
|
123
139
|
"iam:SimulatePrincipalPolicy",
|
|
124
140
|
"iam:RemoveUserFromGroup",
|
|
125
|
-
"iam:DeleteUserPolicy"
|
|
141
|
+
"iam:DeleteUserPolicy",
|
|
142
|
+
"iam:DeleteRolePolicy"
|
|
126
143
|
],
|
|
127
144
|
"Resource": "*"
|
|
128
145
|
}
|
|
@@ -304,6 +321,63 @@ Create a new IAM role with a trust policy.
|
|
|
304
321
|
- `max_session_duration` (optional): Maximum session duration in seconds (default: 3600)
|
|
305
322
|
- `permissions_boundary` (optional): ARN of the permissions boundary policy
|
|
306
323
|
|
|
324
|
+
### Group Management
|
|
325
|
+
|
|
326
|
+
#### `list_groups`
|
|
327
|
+
List IAM groups in the account with optional filtering.
|
|
328
|
+
|
|
329
|
+
**Parameters:**
|
|
330
|
+
- `path_prefix` (optional): Path prefix to filter groups (e.g., "/division_abc/")
|
|
331
|
+
- `max_items` (optional): Maximum number of groups to return (default: 100)
|
|
332
|
+
|
|
333
|
+
#### `get_group`
|
|
334
|
+
Get detailed information about a specific IAM group including members, attached policies, and inline policies.
|
|
335
|
+
|
|
336
|
+
**Parameters:**
|
|
337
|
+
- `group_name`: The name of the IAM group to retrieve
|
|
338
|
+
|
|
339
|
+
#### `create_group`
|
|
340
|
+
Create a new IAM group.
|
|
341
|
+
|
|
342
|
+
**Parameters:**
|
|
343
|
+
- `group_name`: The name of the new IAM group
|
|
344
|
+
- `path` (optional): The path for the group (default: "/")
|
|
345
|
+
|
|
346
|
+
#### `delete_group`
|
|
347
|
+
Delete an IAM group with optional force cleanup.
|
|
348
|
+
|
|
349
|
+
**Parameters:**
|
|
350
|
+
- `group_name`: The name of the IAM group to delete
|
|
351
|
+
- `force` (optional): Force delete by removing all members and policies first (default: false)
|
|
352
|
+
|
|
353
|
+
#### `add_user_to_group`
|
|
354
|
+
Add a user to an IAM group.
|
|
355
|
+
|
|
356
|
+
**Parameters:**
|
|
357
|
+
- `group_name`: The name of the IAM group
|
|
358
|
+
- `user_name`: The name of the IAM user
|
|
359
|
+
|
|
360
|
+
#### `remove_user_from_group`
|
|
361
|
+
Remove a user from an IAM group.
|
|
362
|
+
|
|
363
|
+
**Parameters:**
|
|
364
|
+
- `group_name`: The name of the IAM group
|
|
365
|
+
- `user_name`: The name of the IAM user
|
|
366
|
+
|
|
367
|
+
#### `attach_group_policy`
|
|
368
|
+
Attach a managed policy to an IAM group.
|
|
369
|
+
|
|
370
|
+
**Parameters:**
|
|
371
|
+
- `group_name`: The name of the IAM group
|
|
372
|
+
- `policy_arn`: The ARN of the policy to attach
|
|
373
|
+
|
|
374
|
+
#### `detach_group_policy`
|
|
375
|
+
Detach a managed policy from an IAM group.
|
|
376
|
+
|
|
377
|
+
**Parameters:**
|
|
378
|
+
- `group_name`: The name of the IAM group
|
|
379
|
+
- `policy_arn`: The ARN of the policy to detach
|
|
380
|
+
|
|
307
381
|
### Policy Management
|
|
308
382
|
|
|
309
383
|
#### `list_policies`
|
|
@@ -357,6 +431,64 @@ Simulate IAM policy evaluation for a principal to test permissions.
|
|
|
357
431
|
- `resource_arns` (optional): List of resource ARNs to test against
|
|
358
432
|
- `context_entries` (optional): Context entries for the simulation
|
|
359
433
|
|
|
434
|
+
### Inline Policy Management
|
|
435
|
+
|
|
436
|
+
#### `put_user_policy`
|
|
437
|
+
Create or update an inline policy for an IAM user.
|
|
438
|
+
|
|
439
|
+
**Parameters:**
|
|
440
|
+
- `user_name`: The name of the IAM user
|
|
441
|
+
- `policy_name`: The name of the inline policy
|
|
442
|
+
- `policy_document`: The policy document in JSON format (string or dict)
|
|
443
|
+
|
|
444
|
+
#### `get_user_policy`
|
|
445
|
+
Retrieve an inline policy for an IAM user.
|
|
446
|
+
|
|
447
|
+
**Parameters:**
|
|
448
|
+
- `user_name`: The name of the IAM user
|
|
449
|
+
- `policy_name`: The name of the inline policy
|
|
450
|
+
|
|
451
|
+
#### `delete_user_policy`
|
|
452
|
+
Delete an inline policy from an IAM user.
|
|
453
|
+
|
|
454
|
+
**Parameters:**
|
|
455
|
+
- `user_name`: The name of the IAM user
|
|
456
|
+
- `policy_name`: The name of the inline policy to delete
|
|
457
|
+
|
|
458
|
+
#### `list_user_policies`
|
|
459
|
+
List all inline policies for an IAM user.
|
|
460
|
+
|
|
461
|
+
**Parameters:**
|
|
462
|
+
- `user_name`: The name of the IAM user
|
|
463
|
+
|
|
464
|
+
#### `put_role_policy`
|
|
465
|
+
Create or update an inline policy for an IAM role.
|
|
466
|
+
|
|
467
|
+
**Parameters:**
|
|
468
|
+
- `role_name`: The name of the IAM role
|
|
469
|
+
- `policy_name`: The name of the inline policy
|
|
470
|
+
- `policy_document`: The policy document in JSON format (string or dict)
|
|
471
|
+
|
|
472
|
+
#### `get_role_policy`
|
|
473
|
+
Retrieve an inline policy for an IAM role.
|
|
474
|
+
|
|
475
|
+
**Parameters:**
|
|
476
|
+
- `role_name`: The name of the IAM role
|
|
477
|
+
- `policy_name`: The name of the inline policy
|
|
478
|
+
|
|
479
|
+
#### `delete_role_policy`
|
|
480
|
+
Delete an inline policy from an IAM role.
|
|
481
|
+
|
|
482
|
+
**Parameters:**
|
|
483
|
+
- `role_name`: The name of the IAM role
|
|
484
|
+
- `policy_name`: The name of the inline policy to delete
|
|
485
|
+
|
|
486
|
+
#### `list_role_policies`
|
|
487
|
+
List all inline policies for an IAM role.
|
|
488
|
+
|
|
489
|
+
**Parameters:**
|
|
490
|
+
- `role_name`: The name of the IAM role
|
|
491
|
+
|
|
360
492
|
## Usage Examples
|
|
361
493
|
|
|
362
494
|
### Basic User Management
|
|
@@ -398,6 +530,30 @@ role = await create_role(
|
|
|
398
530
|
)
|
|
399
531
|
```
|
|
400
532
|
|
|
533
|
+
### Group Management
|
|
534
|
+
```python
|
|
535
|
+
# Create a new group
|
|
536
|
+
group = await create_group(
|
|
537
|
+
group_name="Developers",
|
|
538
|
+
path="/teams/"
|
|
539
|
+
)
|
|
540
|
+
|
|
541
|
+
# Add users to the group
|
|
542
|
+
await add_user_to_group(
|
|
543
|
+
group_name="Developers",
|
|
544
|
+
user_name="john.doe"
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
# Attach a policy to the group
|
|
548
|
+
await attach_group_policy(
|
|
549
|
+
group_name="Developers",
|
|
550
|
+
policy_arn="arn:aws:iam::123456789012:policy/DeveloperPolicy"
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
# Get group details including members
|
|
554
|
+
group_details = await get_group(group_name="Developers")
|
|
555
|
+
```
|
|
556
|
+
|
|
401
557
|
### Policy Management
|
|
402
558
|
```python
|
|
403
559
|
# List customer managed policies
|
|
@@ -420,6 +576,58 @@ simulation = await simulate_principal_policy(
|
|
|
420
576
|
)
|
|
421
577
|
```
|
|
422
578
|
|
|
579
|
+
### Inline Policy Management
|
|
580
|
+
```python
|
|
581
|
+
# Create an inline policy for a user
|
|
582
|
+
policy_document = {
|
|
583
|
+
"Version": "2012-10-17",
|
|
584
|
+
"Statement": [
|
|
585
|
+
{
|
|
586
|
+
"Effect": "Allow",
|
|
587
|
+
"Action": ["s3:GetObject", "s3:PutObject"],
|
|
588
|
+
"Resource": "arn:aws:s3:::my-bucket/*"
|
|
589
|
+
}
|
|
590
|
+
]
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
await put_user_policy(
|
|
594
|
+
user_name="developer",
|
|
595
|
+
policy_name="S3AccessPolicy",
|
|
596
|
+
policy_document=policy_document
|
|
597
|
+
)
|
|
598
|
+
|
|
599
|
+
# Retrieve an inline policy
|
|
600
|
+
policy = await get_user_policy(
|
|
601
|
+
user_name="developer",
|
|
602
|
+
policy_name="S3AccessPolicy"
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
# List all inline policies for a user
|
|
606
|
+
policies = await list_user_policies(user_name="developer")
|
|
607
|
+
|
|
608
|
+
# Create an inline policy for a role
|
|
609
|
+
await put_role_policy(
|
|
610
|
+
role_name="EC2-S3-Access-Role",
|
|
611
|
+
policy_name="S3ReadOnlyPolicy",
|
|
612
|
+
policy_document={
|
|
613
|
+
"Version": "2012-10-17",
|
|
614
|
+
"Statement": [
|
|
615
|
+
{
|
|
616
|
+
"Effect": "Allow",
|
|
617
|
+
"Action": "s3:GetObject",
|
|
618
|
+
"Resource": "*"
|
|
619
|
+
}
|
|
620
|
+
]
|
|
621
|
+
}
|
|
622
|
+
)
|
|
623
|
+
|
|
624
|
+
# Delete an inline policy
|
|
625
|
+
await delete_user_policy(
|
|
626
|
+
user_name="developer",
|
|
627
|
+
policy_name="S3AccessPolicy"
|
|
628
|
+
)
|
|
629
|
+
```
|
|
630
|
+
|
|
423
631
|
## Security Best Practices
|
|
424
632
|
|
|
425
633
|
1. **Principle of Least Privilege**: Always grant the minimum permissions necessary
|
|
@@ -429,6 +637,8 @@ simulation = await simulate_principal_policy(
|
|
|
429
637
|
5. **Enable MFA**: Use multi-factor authentication where possible
|
|
430
638
|
6. **Permissions Boundaries**: Use permissions boundaries to set maximum permissions
|
|
431
639
|
7. **Policy Simulation**: Test policies before applying them to production
|
|
640
|
+
8. **Prefer Managed Policies**: Use managed policies over inline policies for reusable permissions
|
|
641
|
+
9. **Inline Policy Guidelines**: Use inline policies only for permissions unique to a single identity
|
|
432
642
|
|
|
433
643
|
## Error Handling
|
|
434
644
|
|
|
@@ -7,7 +7,9 @@ A Model Context Protocol (MCP) server for comprehensive AWS Identity and Access
|
|
|
7
7
|
### Core IAM Management
|
|
8
8
|
- **User Management**: Create, list, retrieve, and delete IAM users
|
|
9
9
|
- **Role Management**: Create, list, and manage IAM roles with trust policies
|
|
10
|
+
- **Group Management**: Create, list, retrieve, and delete IAM groups with member management
|
|
10
11
|
- **Policy Management**: List and manage IAM policies (managed and inline)
|
|
12
|
+
- **Inline Policy Management**: Full CRUD operations for user and role inline policies
|
|
11
13
|
- **Permission Management**: Attach/detach policies to users and roles
|
|
12
14
|
- **Access Key Management**: Create and delete access keys for users
|
|
13
15
|
- **Security Simulation**: Test policy permissions before applying them
|
|
@@ -74,6 +76,16 @@ The AWS credentials used by this server need the following IAM permissions:
|
|
|
74
76
|
"iam:GetRole",
|
|
75
77
|
"iam:CreateRole",
|
|
76
78
|
"iam:DeleteRole",
|
|
79
|
+
"iam:ListGroups",
|
|
80
|
+
"iam:GetGroup",
|
|
81
|
+
"iam:CreateGroup",
|
|
82
|
+
"iam:DeleteGroup",
|
|
83
|
+
"iam:AddUserToGroup",
|
|
84
|
+
"iam:RemoveUserFromGroup",
|
|
85
|
+
"iam:AttachGroupPolicy",
|
|
86
|
+
"iam:DetachGroupPolicy",
|
|
87
|
+
"iam:ListAttachedGroupPolicies",
|
|
88
|
+
"iam:ListGroupPolicies",
|
|
77
89
|
"iam:ListPolicies",
|
|
78
90
|
"iam:GetPolicy",
|
|
79
91
|
"iam:CreatePolicy",
|
|
@@ -86,13 +98,18 @@ The AWS credentials used by this server need the following IAM permissions:
|
|
|
86
98
|
"iam:ListAttachedRolePolicies",
|
|
87
99
|
"iam:ListUserPolicies",
|
|
88
100
|
"iam:ListRolePolicies",
|
|
101
|
+
"iam:GetUserPolicy",
|
|
102
|
+
"iam:GetRolePolicy",
|
|
103
|
+
"iam:PutUserPolicy",
|
|
104
|
+
"iam:PutRolePolicy",
|
|
89
105
|
"iam:GetGroupsForUser",
|
|
90
106
|
"iam:ListAccessKeys",
|
|
91
107
|
"iam:CreateAccessKey",
|
|
92
108
|
"iam:DeleteAccessKey",
|
|
93
109
|
"iam:SimulatePrincipalPolicy",
|
|
94
110
|
"iam:RemoveUserFromGroup",
|
|
95
|
-
"iam:DeleteUserPolicy"
|
|
111
|
+
"iam:DeleteUserPolicy",
|
|
112
|
+
"iam:DeleteRolePolicy"
|
|
96
113
|
],
|
|
97
114
|
"Resource": "*"
|
|
98
115
|
}
|
|
@@ -274,6 +291,63 @@ Create a new IAM role with a trust policy.
|
|
|
274
291
|
- `max_session_duration` (optional): Maximum session duration in seconds (default: 3600)
|
|
275
292
|
- `permissions_boundary` (optional): ARN of the permissions boundary policy
|
|
276
293
|
|
|
294
|
+
### Group Management
|
|
295
|
+
|
|
296
|
+
#### `list_groups`
|
|
297
|
+
List IAM groups in the account with optional filtering.
|
|
298
|
+
|
|
299
|
+
**Parameters:**
|
|
300
|
+
- `path_prefix` (optional): Path prefix to filter groups (e.g., "/division_abc/")
|
|
301
|
+
- `max_items` (optional): Maximum number of groups to return (default: 100)
|
|
302
|
+
|
|
303
|
+
#### `get_group`
|
|
304
|
+
Get detailed information about a specific IAM group including members, attached policies, and inline policies.
|
|
305
|
+
|
|
306
|
+
**Parameters:**
|
|
307
|
+
- `group_name`: The name of the IAM group to retrieve
|
|
308
|
+
|
|
309
|
+
#### `create_group`
|
|
310
|
+
Create a new IAM group.
|
|
311
|
+
|
|
312
|
+
**Parameters:**
|
|
313
|
+
- `group_name`: The name of the new IAM group
|
|
314
|
+
- `path` (optional): The path for the group (default: "/")
|
|
315
|
+
|
|
316
|
+
#### `delete_group`
|
|
317
|
+
Delete an IAM group with optional force cleanup.
|
|
318
|
+
|
|
319
|
+
**Parameters:**
|
|
320
|
+
- `group_name`: The name of the IAM group to delete
|
|
321
|
+
- `force` (optional): Force delete by removing all members and policies first (default: false)
|
|
322
|
+
|
|
323
|
+
#### `add_user_to_group`
|
|
324
|
+
Add a user to an IAM group.
|
|
325
|
+
|
|
326
|
+
**Parameters:**
|
|
327
|
+
- `group_name`: The name of the IAM group
|
|
328
|
+
- `user_name`: The name of the IAM user
|
|
329
|
+
|
|
330
|
+
#### `remove_user_from_group`
|
|
331
|
+
Remove a user from an IAM group.
|
|
332
|
+
|
|
333
|
+
**Parameters:**
|
|
334
|
+
- `group_name`: The name of the IAM group
|
|
335
|
+
- `user_name`: The name of the IAM user
|
|
336
|
+
|
|
337
|
+
#### `attach_group_policy`
|
|
338
|
+
Attach a managed policy to an IAM group.
|
|
339
|
+
|
|
340
|
+
**Parameters:**
|
|
341
|
+
- `group_name`: The name of the IAM group
|
|
342
|
+
- `policy_arn`: The ARN of the policy to attach
|
|
343
|
+
|
|
344
|
+
#### `detach_group_policy`
|
|
345
|
+
Detach a managed policy from an IAM group.
|
|
346
|
+
|
|
347
|
+
**Parameters:**
|
|
348
|
+
- `group_name`: The name of the IAM group
|
|
349
|
+
- `policy_arn`: The ARN of the policy to detach
|
|
350
|
+
|
|
277
351
|
### Policy Management
|
|
278
352
|
|
|
279
353
|
#### `list_policies`
|
|
@@ -327,6 +401,64 @@ Simulate IAM policy evaluation for a principal to test permissions.
|
|
|
327
401
|
- `resource_arns` (optional): List of resource ARNs to test against
|
|
328
402
|
- `context_entries` (optional): Context entries for the simulation
|
|
329
403
|
|
|
404
|
+
### Inline Policy Management
|
|
405
|
+
|
|
406
|
+
#### `put_user_policy`
|
|
407
|
+
Create or update an inline policy for an IAM user.
|
|
408
|
+
|
|
409
|
+
**Parameters:**
|
|
410
|
+
- `user_name`: The name of the IAM user
|
|
411
|
+
- `policy_name`: The name of the inline policy
|
|
412
|
+
- `policy_document`: The policy document in JSON format (string or dict)
|
|
413
|
+
|
|
414
|
+
#### `get_user_policy`
|
|
415
|
+
Retrieve an inline policy for an IAM user.
|
|
416
|
+
|
|
417
|
+
**Parameters:**
|
|
418
|
+
- `user_name`: The name of the IAM user
|
|
419
|
+
- `policy_name`: The name of the inline policy
|
|
420
|
+
|
|
421
|
+
#### `delete_user_policy`
|
|
422
|
+
Delete an inline policy from an IAM user.
|
|
423
|
+
|
|
424
|
+
**Parameters:**
|
|
425
|
+
- `user_name`: The name of the IAM user
|
|
426
|
+
- `policy_name`: The name of the inline policy to delete
|
|
427
|
+
|
|
428
|
+
#### `list_user_policies`
|
|
429
|
+
List all inline policies for an IAM user.
|
|
430
|
+
|
|
431
|
+
**Parameters:**
|
|
432
|
+
- `user_name`: The name of the IAM user
|
|
433
|
+
|
|
434
|
+
#### `put_role_policy`
|
|
435
|
+
Create or update an inline policy for an IAM role.
|
|
436
|
+
|
|
437
|
+
**Parameters:**
|
|
438
|
+
- `role_name`: The name of the IAM role
|
|
439
|
+
- `policy_name`: The name of the inline policy
|
|
440
|
+
- `policy_document`: The policy document in JSON format (string or dict)
|
|
441
|
+
|
|
442
|
+
#### `get_role_policy`
|
|
443
|
+
Retrieve an inline policy for an IAM role.
|
|
444
|
+
|
|
445
|
+
**Parameters:**
|
|
446
|
+
- `role_name`: The name of the IAM role
|
|
447
|
+
- `policy_name`: The name of the inline policy
|
|
448
|
+
|
|
449
|
+
#### `delete_role_policy`
|
|
450
|
+
Delete an inline policy from an IAM role.
|
|
451
|
+
|
|
452
|
+
**Parameters:**
|
|
453
|
+
- `role_name`: The name of the IAM role
|
|
454
|
+
- `policy_name`: The name of the inline policy to delete
|
|
455
|
+
|
|
456
|
+
#### `list_role_policies`
|
|
457
|
+
List all inline policies for an IAM role.
|
|
458
|
+
|
|
459
|
+
**Parameters:**
|
|
460
|
+
- `role_name`: The name of the IAM role
|
|
461
|
+
|
|
330
462
|
## Usage Examples
|
|
331
463
|
|
|
332
464
|
### Basic User Management
|
|
@@ -368,6 +500,30 @@ role = await create_role(
|
|
|
368
500
|
)
|
|
369
501
|
```
|
|
370
502
|
|
|
503
|
+
### Group Management
|
|
504
|
+
```python
|
|
505
|
+
# Create a new group
|
|
506
|
+
group = await create_group(
|
|
507
|
+
group_name="Developers",
|
|
508
|
+
path="/teams/"
|
|
509
|
+
)
|
|
510
|
+
|
|
511
|
+
# Add users to the group
|
|
512
|
+
await add_user_to_group(
|
|
513
|
+
group_name="Developers",
|
|
514
|
+
user_name="john.doe"
|
|
515
|
+
)
|
|
516
|
+
|
|
517
|
+
# Attach a policy to the group
|
|
518
|
+
await attach_group_policy(
|
|
519
|
+
group_name="Developers",
|
|
520
|
+
policy_arn="arn:aws:iam::123456789012:policy/DeveloperPolicy"
|
|
521
|
+
)
|
|
522
|
+
|
|
523
|
+
# Get group details including members
|
|
524
|
+
group_details = await get_group(group_name="Developers")
|
|
525
|
+
```
|
|
526
|
+
|
|
371
527
|
### Policy Management
|
|
372
528
|
```python
|
|
373
529
|
# List customer managed policies
|
|
@@ -390,6 +546,58 @@ simulation = await simulate_principal_policy(
|
|
|
390
546
|
)
|
|
391
547
|
```
|
|
392
548
|
|
|
549
|
+
### Inline Policy Management
|
|
550
|
+
```python
|
|
551
|
+
# Create an inline policy for a user
|
|
552
|
+
policy_document = {
|
|
553
|
+
"Version": "2012-10-17",
|
|
554
|
+
"Statement": [
|
|
555
|
+
{
|
|
556
|
+
"Effect": "Allow",
|
|
557
|
+
"Action": ["s3:GetObject", "s3:PutObject"],
|
|
558
|
+
"Resource": "arn:aws:s3:::my-bucket/*"
|
|
559
|
+
}
|
|
560
|
+
]
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
await put_user_policy(
|
|
564
|
+
user_name="developer",
|
|
565
|
+
policy_name="S3AccessPolicy",
|
|
566
|
+
policy_document=policy_document
|
|
567
|
+
)
|
|
568
|
+
|
|
569
|
+
# Retrieve an inline policy
|
|
570
|
+
policy = await get_user_policy(
|
|
571
|
+
user_name="developer",
|
|
572
|
+
policy_name="S3AccessPolicy"
|
|
573
|
+
)
|
|
574
|
+
|
|
575
|
+
# List all inline policies for a user
|
|
576
|
+
policies = await list_user_policies(user_name="developer")
|
|
577
|
+
|
|
578
|
+
# Create an inline policy for a role
|
|
579
|
+
await put_role_policy(
|
|
580
|
+
role_name="EC2-S3-Access-Role",
|
|
581
|
+
policy_name="S3ReadOnlyPolicy",
|
|
582
|
+
policy_document={
|
|
583
|
+
"Version": "2012-10-17",
|
|
584
|
+
"Statement": [
|
|
585
|
+
{
|
|
586
|
+
"Effect": "Allow",
|
|
587
|
+
"Action": "s3:GetObject",
|
|
588
|
+
"Resource": "*"
|
|
589
|
+
}
|
|
590
|
+
]
|
|
591
|
+
}
|
|
592
|
+
)
|
|
593
|
+
|
|
594
|
+
# Delete an inline policy
|
|
595
|
+
await delete_user_policy(
|
|
596
|
+
user_name="developer",
|
|
597
|
+
policy_name="S3AccessPolicy"
|
|
598
|
+
)
|
|
599
|
+
```
|
|
600
|
+
|
|
393
601
|
## Security Best Practices
|
|
394
602
|
|
|
395
603
|
1. **Principle of Least Privilege**: Always grant the minimum permissions necessary
|
|
@@ -399,6 +607,8 @@ simulation = await simulate_principal_policy(
|
|
|
399
607
|
5. **Enable MFA**: Use multi-factor authentication where possible
|
|
400
608
|
6. **Permissions Boundaries**: Use permissions boundaries to set maximum permissions
|
|
401
609
|
7. **Policy Simulation**: Test policies before applying them to production
|
|
610
|
+
8. **Prefer Managed Policies**: Use managed policies over inline policies for reusable permissions
|
|
611
|
+
9. **Inline Policy Guidelines**: Use inline policies only for permissions unique to a single identity
|
|
402
612
|
|
|
403
613
|
## Error Handling
|
|
404
614
|
|