File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change 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
1212PYTHON_VERSIONS_FOR_AWS_CLI=(" python2.7" " python3.6" " python3.7" )
1313LAYER_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" )
1515AVAILABLE_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
3838 REGIONS=($1 )
3939fi
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
4360for region in " ${REGIONS[@]} "
4461do
You can’t perform that action at this time.
0 commit comments