forked from DataDog/datadog-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist_layers.sh
More file actions
executable file
·55 lines (49 loc) · 1.88 KB
/
list_layers.sh
File metadata and controls
executable file
·55 lines (49 loc) · 1.88 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# Unless explicitly stated otherwise all files in this repository are licensed
# under the Apache License Version 2.0.
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2019 Datadog, Inc.
# Lists most recent layers ARNs across regions to STDOUT
# Optionals args: [layer-name] [region]
LAYER_NAMES=("Datadog-Python27" "Datadog-Python36" "Datadog-Python37" "Datadog-Python38")
AVAILABLE_REGIONS=(us-east-2 us-east-1 us-west-1 us-west-2 ap-east-1 ap-south-1 ap-northeast-2 ap-southeast-1 ap-southeast-2 ap-northeast-1 ca-central-1 eu-north-1 eu-central-1 eu-west-1 eu-west-2 eu-west-3 sa-east-1)
# Check region arg
if [ -z "$2" ]; then
>&2 echo "Region parameter not specified, running for all available regions."
REGIONS=("${AVAILABLE_REGIONS[@]}")
else
>&2 echo "Region parameter specified: $2"
if [[ ! " ${AVAILABLE_REGIONS[@]} " =~ " ${2} " ]]; then
>&2 echo "Could not find $2 in available regions: ${AVAILABLE_REGIONS[@]}"
>&2 echo ""
>&2 echo "EXITING SCRIPT."
return 1
fi
REGIONS=($2)
fi
# Check region arg
if [ -z "$1" ]; then
>&2 echo "Layer parameter not specified, running for all layers "
LAYERS=("${LAYER_NAMES[@]}")
else
>&2 echo "Layer parameter specified: $1"
if [[ ! " ${LAYER_NAMES[@]} " =~ " ${1} " ]]; then
>&2 echo "Could not find $1 in layers: ${LAYER_NAMES[@]}"
>&2 echo ""
>&2 echo "EXITING SCRIPT."
return 1
fi
LAYERS=($1)
fi
for region in "${REGIONS[@]}"
do
for layer_name in "${LAYERS[@]}"
do
last_layer_arn=$(aws lambda list-layer-versions --layer-name $layer_name --region $region | jq -r ".LayerVersions | .[0] | .LayerVersionArn")
if [ -z $last_layer_arn ]; then
>&2 echo "No layer found for $region, $layer_name"
else
echo $last_layer_arn
fi
done
done