Use AWS CLI to list certain managed policies

Viewed 175

I'm trying to list AWS (managed) policies related to CodeCommit using AWS CLI.

I found aws list-policies but it doesn't seem to have a way to filter. It just returns ALL the policies.

I would like to return the same as if I was using the console

  • AWSCodeCommitFullAccess
  • AWSCodeCommitPowerUser
  • AWSCodeCommitReadOnly

Anyone knows the proper way to do this? Thanks!

2 Answers
aws iam list-policies --query 'Policies[?starts_with(PolicyName,`AWSCodeCommit`)]'

when run commands to list anything in aws and then grep it with target information. as shown in below command.

aws iam list-policies --profile binsysmh  |grep -i commit

here you will also get arn for target policies which will help for next aws cli tasks. here in action !!

Note: this trick is only validate in Linux based terminal.

Related