Skip to content

Commit aa2cad9

Browse files
authored
Get list of regions from AWS (#77)
1 parent f6a3022 commit aa2cad9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

scripts/publish_layers.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ trap "pkill -P $$; exit 1;" INT
1616
PYTHON_VERSIONS_FOR_AWS_CLI=("python2.7" "python3.6" "python3.7" "python3.8")
1717
LAYER_PATHS=(".layers/datadog_lambda_py2.7.zip" ".layers/datadog_lambda_py3.6.zip" ".layers/datadog_lambda_py3.7.zip" ".layers/datadog_lambda_py3.8.zip")
1818
AVAILABLE_LAYER_NAMES=("Datadog-Python27" "Datadog-Python36" "Datadog-Python37" "Datadog-Python38")
19-
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)
19+
AVAILABLE_REGIONS=$(aws ec2 describe-regions | jq -r '.[] | .[] | .RegionName')
2020

2121
# Check that the layer files exist
2222
for layer_file in "${LAYER_PATHS[@]}"
@@ -30,19 +30,19 @@ done
3030
# Check region arg
3131
if [ -z "$1" ]; then
3232
echo "Region parameter not specified, running for all available regions."
33-
REGIONS=("${AVAILABLE_REGIONS[@]}")
33+
REGIONS=$AVAILABLE_REGIONS
3434
else
3535
echo "Region parameter specified: $1"
36-
if [[ ! " ${AVAILABLE_REGIONS[@]} " =~ " ${1} " ]]; then
37-
echo "Could not find $1 in available regions: ${AVAILABLE_REGIONS[@]}"
36+
if [[ ! "$AVAILABLE_REGIONS" == *"$1"* ]]; then
37+
echo "Could not find $1 in available regions: $AVAILABLE_REGIONS"
3838
echo ""
3939
echo "EXITING SCRIPT."
4040
exit 1
4141
fi
4242
REGIONS=($1)
4343
fi
4444

45-
echo "Publishing layers for regions: ${REGIONS[*]}"
45+
echo "Starting publishing layers for regions: $REGIONS"
4646

4747
# Check layer_name arg
4848
if [ -z "$2" ]; then
@@ -85,7 +85,7 @@ publish_layer() {
8585
echo "Published layer for region $region, python version $aws_version_key, layer_name $layer_name, layer_version $version_nbr"
8686
}
8787

88-
BATCH_SIZE=60
88+
BATCH_SIZE=1
8989
PIDS=()
9090

9191
wait_for_processes() {
@@ -95,7 +95,7 @@ wait_for_processes() {
9595
PIDS=()
9696
}
9797

98-
for region in "${REGIONS[@]}"
98+
for region in $REGIONS
9999
do
100100
echo "Starting publishing layer for region $region..."
101101

0 commit comments

Comments
 (0)