Skip to content

Commit 4d2ff75

Browse files
committed
Support publish a specific layer to a specific region
1 parent 54c8c6f commit 4d2ff75

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

scripts/publish_layers.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
# Copyright 2019 Datadog, Inc.
77

88
# Publish the datadog python lambda layer across regions, using the AWS CLI
9-
# Usage: publish_layer.sh [region]
10-
# Specifying the region arg will publish the layer for the single specified region
9+
# Usage: publish_layer.sh [region] [layer]
10+
# Specifying the region and layer arg will publish the specified layer to the specified region
1111

1212
PYTHON_VERSIONS_FOR_AWS_CLI=("python2.7" "python3.6" "python3.7")
1313
LAYER_PATHS=(".layers/datadog_lambda_py2.7.zip" ".layers/datadog_lambda_py3.6.zip" ".layers/datadog_lambda_py3.7.zip")
14-
LAYER_NAMES=("Datadog-Python27" "Datadog-Python36" "Datadog-Python37")
14+
AVAILABLE_LAYER_NAMES=("Datadog-Python27" "Datadog-Python36" "Datadog-Python37")
1515
AVAILABLE_REGIONS=(us-east-2 us-east-1 us-west-1 us-west-2 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)
1616

1717
# Check that the layer files exist
@@ -38,7 +38,24 @@ else
3838
REGIONS=($1)
3939
fi
4040

41-
echo "Starting publishing layers for regions: ${REGIONS[*]}"
41+
echo "Publishing layers for regions: ${REGIONS[*]}"
42+
43+
# Check layer_name arg
44+
if [ -z "$2" ]; then
45+
echo "Layer name parameter not specified, running for all layer names."
46+
LAYER_NAMES=("${AVAILABLE_LAYER_NAMES[@]}")
47+
else
48+
echo "Layer name parameter specified: $2"
49+
if [[ ! " ${AVAILABLE_LAYER_NAMES[@]} " =~ " ${2} " ]]; then
50+
echo "Could not find $2 in available layer names: ${AVAILABLE_LAYER_NAMES[@]}"
51+
echo ""
52+
echo "EXITING SCRIPT."
53+
exit 1
54+
fi
55+
LAYER_NAMES=($2)
56+
fi
57+
58+
echo "Publishing layers: ${LAYER_NAMES[*]}"
4259

4360
for region in "${REGIONS[@]}"
4461
do

0 commit comments

Comments
 (0)