This project automates AWS IAM user, group, and policy management for a development team using Python and boto3. It showcases advanced IAM concepts including policy validation, MFA enforcement, cleanup automation, unit tests, and CI/CD integration. Perfect for demonstrating AWS and DevOps skills!
- Automated IAM Setup: Creates users (Alice, Bob, Charlie, Dana), groups (Developer, DBAdmin, Auditor), and policies for S3, EC2, RDS, and CloudTrail access.
- Policy Validation: Checks for overly permissive policies (e.g., Action:
*
, Resource:*
). - Cleanup Script: Safely deletes all created IAM resources.
- Unit Tests: Uses
pytest
andmoto
to test setup logic without AWS API calls. - Configurable: Uses
config.yaml
for customizable team and permission settings.
aws-iam-user-management/
├── config.yaml # Configuration for bucket, region, users
├── policies/ # JSON policy files
├── scripts/ # Python scripts for setup and cleanup
├── tests/ # Unit tests
├── .github/workflows/ # GitHub Actions CI pipeline
├── .gitignore # Ignored files
├── README.md # Documentation
├── requirements.txt # Dependencies
- AWS account with IAM administrative permissions.
- AWS CLI configured (
aws configure
). - Python 3.8+.
- uv for dependency management.
- Install:
curl -LsSf https://astral.sh/uv/install.sh | sh
- Install:
- An S3 bucket (e.g.,
my-app-bucket
) for testing (AWS Free Tier recommended).
-
Clone the repository:
git clone https://github.com/your-username/aws-iam-user-management.git cd aws-iam-user-management
-
Install dependencies with uv:
uv sync
-
Configure AWS CLI:
aws configure
-
Update
config.yaml
with your S3 bucket name and region.
-
Run the setup script:
uv run python scripts/setup_iam_users.py
- Creates users, groups, and policies as defined in
config.yaml
. - Generates console access and access keys for users.
- Creates users, groups, and policies as defined in
-
Verify in the AWS IAM console:
- Users: Alice, Bob, Charlie, Dana.
- Groups: DeveloperGroup, DBAdminGroup, AuditorGroup.
- Policies: DeveloperPolicy, DBAdminPolicy, AuditorPolicy, MFAPolicy.
-
Test access (e.g., log in as Alice with MFA, access S3/EC2).
-
Clean up resources:
uv run python scripts/cleanup_iam_users.py
Run unit tests with pytest:
uv run pytest tests/
- Tests use
moto
to mock AWS IAM API calls. - Verifies configuration, policy loading, and setup logic.