Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

288
Views
How do I list tags for all roles using AWS CLI

I would like to list tags for all of my roles within IAM.

aws iam list-role-tags --role-name role123 will only list tags for single role.

aws iam list-roles will list all the roles.

How do I concatenate these two cli commands to list all the tags in all roles?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You can do this with the following shell script:

# Get all role names as text
roles=$(aws iam list-roles \
        --query 'Roles[*].RoleName' \
        --output text)

# Loop through role names and get tags
for role in $roles
do
    aws iam list-role-tags --role-name $role
done

If the respective role's tag lists were too long and got truncated you would have to do some extra work. But I think this is a good starting point.

over 4 years ago · Santiago Trujillo Report

0

Or if you just want to grab Tags and single-line command then try this

for rolename in $(aws iam list-roles --query 'Roles[*].RoleName' --output text);do aws iam list-role-tags --role-name $rolename --query "Tags";done

Output

[
    {
        "Key": "Name",
        "Value": "test"
    }
]
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!