Skip to content

Get list of regions from AWS #77

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions scripts/publish_layers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ trap "pkill -P $$; exit 1;" INT
PYTHON_VERSIONS_FOR_AWS_CLI=("python2.7" "python3.6" "python3.7" "python3.8")
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")
AVAILABLE_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)
AVAILABLE_REGIONS=$(aws ec2 describe-regions | jq -r '.[] | .[] | .RegionName')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, maybe wanna avoid this if $1 is given


# Check that the layer files exist
for layer_file in "${LAYER_PATHS[@]}"
Expand All @@ -30,19 +30,19 @@ done
# Check region arg
if [ -z "$1" ]; then
echo "Region parameter not specified, running for all available regions."
REGIONS=("${AVAILABLE_REGIONS[@]}")
REGIONS=$AVAILABLE_REGIONS
else
echo "Region parameter specified: $1"
if [[ ! " ${AVAILABLE_REGIONS[@]} " =~ " ${1} " ]]; then
echo "Could not find $1 in available regions: ${AVAILABLE_REGIONS[@]}"
if [[ ! "$AVAILABLE_REGIONS" == *"$1"* ]]; then
echo "Could not find $1 in available regions: $AVAILABLE_REGIONS"
echo ""
echo "EXITING SCRIPT."
exit 1
fi
REGIONS=($1)
fi

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

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

BATCH_SIZE=60
BATCH_SIZE=1
PIDS=()

wait_for_processes() {
Expand All @@ -95,7 +95,7 @@ wait_for_processes() {
PIDS=()
}

for region in "${REGIONS[@]}"
for region in $REGIONS
do
echo "Starting publishing layer for region $region..."

Expand Down