Skip to content

Instantly share code, notes, and snippets.

@dserodio
Created June 24, 2019 20:10
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dserodio/52cb95a07a41a57ddbb675d1d23d2c8e to your computer and use it in GitHub Desktop.
"""Replace 'name' tag with 'Name' and 'application' with 'Application'
"""
import boto3
def uppercaseTagKeys(arn, name, application=None):
tags = {}
if name:
tags['Name'] = name
if application:
tags['Application'] = application
if tags:
client.tag_resource(
Resource=arn,
Tags=tags
)
# it seems there's no way to delete tags at the moment,
# see https://github.com/boto/boto3/issues/2018
for region in ['sa-east-1', 'us-west-2']:
client = boto3.client('lambda', region_name=region)
for func in client.list_functions()['Functions']:
arn = func['FunctionArn']
tags = client.list_tags(Resource=arn)['Tags']
print ("%s had tags %s" % (arn, str(tags)))
name = tags.get('name', None)
application = tags.get('application', None)
uppercaseTagKeys(arn, name, application)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment