Skip to content

Instantly share code, notes, and snippets.

@jftuga
Created January 19, 2023 15:57
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 jftuga/d3d6835fe08ea7344be5d375cbc63819 to your computer and use it in GitHub Desktop.
Save jftuga/d3d6835fe08ea7344be5d375cbc63819 to your computer and use it in GitHub Desktop.
create boto3 tags from dict
import json
def create_boto3_tags(all_tags:dict) -> list:
boto3_tags = []
for tag in all_tags:
for key, val in tag.items():
boto3_tags.append({"Key": key, "Value": val})
return boto3_tags
def main():
all_tags = [
{"Name": "domain_name"},
{"Department": "Online Services"},
{"Infrastructure_Group": "Standard Hosting"},
{"Product": "Pro"},
{"Asset": "instance_name"},
]
boto3_tags = create_boto3_tags(all_tags)
print(json.dumps(boto3_tags, indent=4))
if __name__ == "__main__":
main()
[
{
"Key": "Name",
"Value": "domain_name"
},
{
"Key": "Department",
"Value": "Online Services"
},
{
"Key": "Infrastructure_Group",
"Value": "Standard Hosting"
},
{
"Key": "Product",
"Value": "Pro"
},
{
"Key": "Asset",
"Value": "instance_name"
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment