forked from keithrozario/Klayers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_arns.py
executable file
·27 lines (22 loc) · 1009 Bytes
/
get_arns.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /usr/bin/env python3
import boto3
import json
session = boto3.Session(profile_name='LayerUploader')
regions = ['ap-northeast-1', 'ap-northeast-2', 'ap-south-1',
'ap-southeast-1', 'ap-southeast-2', 'ca-central-1',
'eu-central-1', 'eu-north-1', 'eu-west-1',
'eu-west-2', 'eu-west-3', 'sa-east-1',
'us-east-1', 'us-east-2','us-west-1',
'us-west-2']
output = dict()
for region in regions:
client = session.client('lambda', region_name=region)
output[region] = dict()
# every version of every layer
for layer in client.list_layers()['Layers']:
output[region][layer['LayerName']] = []
for version in client.list_layer_versions(LayerName=layer['LayerName'])['LayerVersions']:
output[region][layer['LayerName']].append(version['LayerVersionArn'])
print("{}: {}".format(region, version['LayerVersionArn']))
with open('arns.json', 'w') as f:
f.write(json.dumps(output, indent=4, sort_keys=True))