Skip to content

Instantly share code, notes, and snippets.

@pjaudiomv
Created July 11, 2022 19:47
Show Gist options
  • Save pjaudiomv/254c36db2575706167f4445409e32ab8 to your computer and use it in GitHub Desktop.
Save pjaudiomv/254c36db2575706167f4445409e32ab8 to your computer and use it in GitHub Desktop.
Convert boto3 tags to a dict
tags = [
{'Key': 'Environment', 'Value': 'staging'},
{'Key': 'Name', 'Value': 'STAGING TOOLS'}
]
tag_dict = {tag['Key']: tag['Value'] for tag in tags}
# {
# "Environment": "staging",
# "Name": "STAGING TOOLS"
# }
def instance_tags(instance):
return {tag['Key']: tag['Value'] for tag in instance.tags}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment