Skip to content

Instantly share code, notes, and snippets.

@packetchef
Created March 20, 2020 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save packetchef/6ae33926d7e42756afeaf8102f64fc16 to your computer and use it in GitHub Desktop.
Save packetchef/6ae33926d7e42756afeaf8102f64fc16 to your computer and use it in GitHub Desktop.
Return the value for a tag with a specific name
tags = [{'Key': 'Name', 'Value': 'tag testing'}, {'Key': 'Ec2ImageBuilderArn', 'Value': 'arn:aws:imagebuilder:us-east-1:123412341234:image/my-build/1.0.0/1'}]
nameTagKey = 'Name'
tagName = [ x['Value'] for x in tags if x['Key'] == nameTagKey ][0]
# Should return 'tag testing'
print(tagName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment