Profile Applicability:
• Level 2
Description:
Creating AWS IAM policies allows administrators to define fine-grained permissions for AWS services and resources. Policies should be crafted to ensure least privilege access and to restrict permissions based on the roles and responsibilities of users, groups, and roles.
Rationale:
Custom IAM policies help improve security by restricting access to only the required resources. By creating policies that enforce the principle of least privilege, organizations can minimize the risk of unauthorized access, privilege escalation, and potential misuse of AWS services.
Impact:
Pros:
Enforces the principle of least privilege
Enhances security by restricting unnecessary permissions
Custom policies provide precise access control over AWS services and resources
Cons:
Complex policies may result in misconfigurations that could break services
Requires expertise to write policies and maintain them as the environment evolves
Increased overhead to ensure policies are kept up to date
Default Value:
AWS does not automatically create custom IAM policies; predefined AWS-managed policies are provided, but custom policies must be created manually.
Pre-requisites:
IAM permissions to create and manage IAM policies (e.g., iam:CreatePolicy)
Knowledge of AWS services and their corresponding permissions
Organizational approval for custom policies if applicable
Defined access control strategies and role definitions
Remediation:
Test Plan:
Using AWS Console:
Sign in to the AWS Management Console
Navigate to IAM > Policies
Verify that the required custom IAM policies exist
Review the policy document for compliance with least privilege
Confirm the policy is correctly attached to the required users, roles, or groups
Using AWS CLI:
List existing IAM policies:
aws iam list-policies --scope Local
Get the policy document for review:
aws iam get-policy-version --policy-arn <policy-arn> --version-id <version-id>
List attached entities:
aws iam list-entities-for-policy --policy-arn <policy-arn>
Implementation Plan:
Using AWS Console:
Go to IAM > Policies
Click Create Policy
Choose the JSON tab and define the policy document
Review and validate permissions
Name the policy clearly (e.g., S3ReadOnlyAccessPolicy)
Create the policy and attach it to the appropriate users, groups, or roles
Using AWS CLI:
Save the policy JSON to a file named policy.json. Example:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:GetObject" ], "Resource": [ "arn:aws:s3:::my-bucket", "arn:aws:s3:::my-bucket/*" ] } ] }
Create the IAM policy:
aws iam create-policy --policy-name S3ReadOnlyAccessPolicy --policy-document file://policy.json
Attach the policy to a user, group, or role:
aws iam attach-user-policy --user-name <username> --policy-arn arn:aws:iam::<account-id>:policy/S3ReadOnlyAccessPolicy
Backout Plan:
Using AWS Console:
Navigate to IAM > Policies
Search for the custom policy by name
Detach the policy from all users, roles, or groups
Delete the policy from the system
Using AWS CLI:
Detach the policy from a user:
aws iam detach-user-policy --user-name <username> --policy-arn arn:aws:iam::<account-id>:policy/S3ReadOnlyAccessPolicy
Delete the policy:
aws iam delete-policy --policy-arn arn:aws:iam::<account-id>:policy/S3ReadOnlyAccessPolicy