How do you test an IAM policy against specific actions before granting it?
IntermediateProductionRapid-Fire AWS CLI
Answer
aws iam simulate-principal-policy \
--policy-source-arn arn:aws:iam::111122223333:role/orders-api \
--action-names s3:GetObject s3:PutObject kms:Decrypt \
--resource-arns arn:aws:s3:::orders-data-prod/* \
--query 'EvaluationResults[].[EvalActionName,EvalDecision]' --output table
aws accessanalyzer validate-policy --policy-type IDENTITY_POLICY --policy-document file://policy.json
The simulator does not evaluate SCPs from other accounts or all resource policies, so treat it as a first check.
More on Rapid-Fire AWS CLI
How do you check which identity and account the CLI is using?BeginnerHow do you log in with Identity Center (SSO) from the CLI?BeginnerHow do you assume a role manually and export the credentials?IntermediateHow do you list running instances with name, ID, type and private IP in a table?BeginnerHow do you find the latest Amazon Linux 2023 AMI without hard-coding an ID?BeginnerHow do you open a shell or port-forward to a private instance without SSH?Beginner