Interview Prep/AWS/Rapid-Fire AWS CLI

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.

aws All AWS questions

More on Rapid-Fire AWS CLI