How Do You Use the AWS CLI to Return IAM Information with the AssumePolicyDocument Nested JSON?

Problem scenario
You want to craft an AWS CLI command to return the principal services of your IAM roles. You want the name and the ARN values of the roles to be printed along with the principal services. You the principal services data is in the AssumePolicyDocument. Your previous attempts have returned "None" for this value. What do you do?

Run a command like this:

aws iam list-roles --output text --query 'Roles[*].[RoleName,Arn,AssumeRolePolicyDocument.Statement[*].Principal]'

Leave a comment

Your email address will not be published. Required fields are marked *