Skip to content

Instantly share code, notes, and snippets.

@bahrmichael
Created January 2, 2020 14:01
Show Gist options
  • Save bahrmichael/95f68843dcc8cf70e7c5e666c446b0f8 to your computer and use it in GitHub Desktop.
Save bahrmichael/95f68843dcc8cf70e7c5e666c446b0f8 to your computer and use it in GitHub Desktop.
import sys
import boto3
region = 'us-east-1'
target_tag = 'project'
client = boto3.client('lambda', region)
functions = client.list_functions().get('Functions', [])
for function in functions:
tags = client.list_tags(Resource=function['FunctionArn']).get('Tags', [])
if target_tag not in tags:
print(f"Lambda {function['FunctionArn']} is missing tag {target_tag}")
tag_value = None
if 'aws-scheduler' in function['FunctionArn']:
tag_value = 'serverless-scheduler'
elif 'testing-mail' in function['FunctionArn']:
tag_value = 'research'
if tag_value is not None:
client.tag_resource(Resource=function['FunctionArn'], Tags={target_tag: tag_value})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment