aws sts get-caller-identityThe quickest trust-but-verify command for active credentials.
AWS CLI IAM and STS commands for users, groups, roles, policies, access keys, caller identity, and assume-role workflows.
Confirm who you are and assume roles.
aws sts get-caller-identityThe quickest trust-but-verify command for active credentials.
aws sts assume-role --role-arn arn:aws:iam::123456789012:role/AdminRole --role-session-name admin-cliReturns temporary access key, secret key, and session token values.
aws sts assume-role-with-web-identity --role-arn arn:aws:iam::123456789012:role/GitHubOIDC --role-session-name ci --web-identity-token file://token.jwtCommon in OIDC-based CI/CD integrations.
aws sts get-session-token --duration-seconds 3600Often used with MFA-enforced IAM user workflows.
Inspect and manage IAM users, groups, and memberships.
aws iam list-usersCore account identity inventory command.
aws iam get-userWithout `--user-name`, this can return details for the current IAM user identity.
aws iam create-user --user-name deploy-botLong-term IAM users should be minimized when role-based access is available.
aws iam delete-user --user-name deploy-botThe user must have dependent resources removed first.
aws iam list-groupsUseful in older user/group-based access models.
aws iam add-user-to-group --user-name deploy-bot --group-name DevelopersAdds inherited permissions from the group to the user.
aws iam remove-user-from-group --user-name deploy-bot --group-name DevelopersUseful during access cleanup.
Create, attach, and inspect IAM policies.
aws iam list-policies --scope LocalUse `--scope Local` to focus on customer-managed policies.
aws iam get-policy --policy-arn arn:aws:iam::123456789012:policy/ReadOnlyS3Returns default version ID and attachment counts.
aws iam get-policy-version --policy-arn arn:aws:iam::123456789012:policy/ReadOnlyS3 --version-id v1Use this when you need the actual statement document.
aws iam create-policy --policy-name ReadOnlyS3 --policy-document file://readonly-s3-policy.jsonManaged policies can be attached to users, groups, and roles.
aws iam attach-role-policy --role-name AppRole --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccessCommon role permission workflow.
aws iam detach-role-policy --role-name AppRole --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccessUsed during least-privilege cleanup.
aws iam simulate-principal-policy --policy-source-arn arn:aws:iam::123456789012:role/AppRole --action-names s3:GetObject --resource-arns arn:aws:s3:::my-bucket/*Very useful when debugging access denied errors.
Role creation, trust policies, and access key workflows.
aws iam list-rolesCore inventory command for role-based access setups.
aws iam create-role --role-name AppRole --assume-role-policy-document file://trust-policy.jsonThe trust policy defines who can assume the role.
aws iam update-assume-role-policy --role-name AppRole --policy-document file://trust-policy.jsonUseful when adding or tightening OIDC and cross-account trust.
aws iam create-access-key --user-name deploy-botHandle returned secrets carefully; long-lived keys should be minimized.
aws iam list-access-keys --user-name deploy-botUseful for rotation and audit workflows.
aws iam update-access-key --user-name deploy-bot --access-key-id AKIAIOSFODNN7EXAMPLE --status InactiveUseful during rotation or incident response.
aws iam delete-access-key --user-name deploy-bot --access-key-id AKIAIOSFODNN7EXAMPLEUse after confirming replacement credentials work.