Skip to content

Instantly share code, notes, and snippets.

@ranman
Last active November 18, 2019 22:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ranman/1c88aeadbb532850a1f99839f32d3f91 to your computer and use it in GitHub Desktop.
Save ranman/1c88aeadbb532850a1f99839f32d3f91 to your computer and use it in GitHub Desktop.
enable python3.8 in all region
import boto3
session = boto3.Session(profile_name='default')
regions = session.get_available_regions(service_name='lambda')
for region in regions:
print(region)
aws_lambda = session.client('lambda', region_name=region)
try:
paginator = aws_lambda.get_paginator('list_functions').paginate()
for page in paginator:
for function in page['Functions']:
if function['Runtime'] in ['python3.6', 'python3.7']:
print(f"Updating {function['FunctionName']} in {region} from {function['Runtime']}")
aws_lambda.update_function_configuration(
FunctionName=function['FunctionName'],
Runtime='python3.8'
)
except:
print(f"{region} not enabled")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment