Skip to content

Commit

Permalink
Publish one architecture at a time to the sandbox (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhinsch authored Nov 8, 2021
1 parent eb5cade commit 6319d59
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
2 changes: 1 addition & 1 deletion scripts/build_binary_and_layer_dockerized.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ elif [ "$ARCHITECTURE" == "arm64" ]; then
echo "Building for arm64 only"
docker_build_zip arm64
else
echo "No valid ARCHITECTURE variable found (allowed values are: amd64, arm64), building for both amd64 and arm64"
echo "Building for both amd64 and arm64"
docker_build_zip amd64
docker_build_zip arm64
fi
46 changes: 29 additions & 17 deletions scripts/publish_layers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,32 @@
# Copyright 2020 Datadog, Inc.

# Publish the datadog lambda layer across regions, using the AWS CLI
# Usage: VERSION=5 REGIONS=us-east-1 publish_layers.sh
# Usage: VERSION=5 REGIONS=us-east-1 ARCHITECTURE=amd64 publish_layers.sh

# VERSION is required.
# REGIONS is optional. By default, publish to all regions.
# ARCHITECTURE is optional. By default, publish both architectures.

set -e

# Move into the root directory, so this script can be called from any directory
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $SCRIPTS_DIR/..

LAYER_PATHS=(".layers/datadog_extension-amd64.zip" ".layers/datadog_extension-arm64.zip")
LAYER_NAMES=("Datadog-Extension" "Datadog-Extension-ARM")
if [ "$ARCHITECTURE" == "amd64" ]; then
echo "Publishing for amd64 only"
LAYER_PATHS=(".layers/datadog_extension-amd64.zip")
LAYER_NAMES=("Datadog-Extension")
elif [ "$ARCHITECTURE" == "arm64" ]; then
echo "Publishing for arm64 only"
LAYER_PATHS=(".layers/datadog_extension-arm64.zip")
LAYER_NAMES=("Datadog-Extension-ARM")
else
echo "Publishing for both amd64 and arm64"
LAYER_PATHS=(".layers/datadog_extension-amd64.zip" ".layers/datadog_extension-arm64.zip")
LAYER_NAMES=("Datadog-Extension" "Datadog-Extension-ARM")
fi

AVAILABLE_REGIONS=$(aws ec2 describe-regions | jq -r '.[] | .[] | .RegionName')

# Check that the layer files exist
Expand All @@ -41,19 +57,7 @@ else
fi
fi

# Determine the target layers
if [ -z "$LAYERS" ]; then
echo "Layer not specified, running for all layers."
LAYERS=("${LAYER_NAMES[@]}")
else
echo "Layer specified: $LAYERS"
if [[ ! " ${LAYER_NAMES[@]} " =~ " ${LAYERS} " ]]; then
echo "Could not find $LAYERS in available layers: ${LAYER_NAMES[@]}"
echo ""
echo "EXITING SCRIPT."
exit 1
fi
fi
LAYERS=("${LAYER_NAMES[@]}")

# Determine the target layer version
if [ -z "$VERSION" ]; then
Expand All @@ -65,7 +69,15 @@ else
echo "Layer version specified: $VERSION"
fi

read -p "Ready to publish layer $LAYER_NAME version $VERSION to regions ${REGIONS[*]} (y/n)?" CONT
if [ "$ARCHITECTURE" == "amd64" ]; then
ARCHITECTURE_MESSAGE="amd64 only"
elif [ "$ARCHITECTURE" == "arm64" ]; then
ARCHITECTURE_MESSAGE="arm64 only"
else
ARCHITECTURE_MESSAGE="both architectures"
fi
read -p "Ready to publish Lambda Extension version $VERSION (for $ARCHITECTURE_MESSAGE) to regions ${REGIONS[*]} (y/n)?" CONT

if [ "$CONT" != "y" ]; then
echo "Exiting"
exit 1
Expand Down
7 changes: 6 additions & 1 deletion scripts/publish_sandbox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
# This product includes software developed at Datadog (https://www.datadoghq.com/).
# Copyright 2021 Datadog, Inc.

# Usage: VERSION=5 ./scripts/publish_sandbox.sh
# Usage: VERSION=5 ARCHITECTURE=amd64 ./scripts/publish_sandbox.sh

set -e

# Move into the root directory
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $SCRIPTS_DIR/..

if [ "$ARCHITECTURE" != "amd64" -a "$ARCHITECTURE" != "arm64" ]; then
echo "ERROR: For sandbox deploys, you must specify an architecture (amd64 or arm64)"
exit 1
fi

./scripts/build_binary_and_layer_dockerized.sh
REGIONS=sa-east-1 aws-vault exec sandbox-account-admin -- ./scripts/publish_layers.sh

Expand Down

0 comments on commit 6319d59

Please sign in to comment.