Skip to content

Commit dcb4eab

Browse files
committed
Improve sandbox deploy script
1 parent 7616feb commit dcb4eab

File tree

1 file changed

+40
-10
lines changed

1 file changed

+40
-10
lines changed

scripts/publish_sandbox.sh

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,52 @@
55
# This product includes software developed at Datadog (https://www.datadoghq.com/).
66
# Copyright 2021 Datadog, Inc.
77

8-
# Usage: VERSION=5 ARCHITECTURE=amd64 ./scripts/publish_sandbox.sh
8+
# Usage: VERSION=5 ARCHITECTURE=[amd64|arm64] ./scripts/publish_sandbox.sh
9+
10+
# VERSION is optional. By default, increment the version by 1.
11+
# ARCHITECTURE is optional. The default is amd64.
912

1013
set -e
1114

12-
# Move into the root directory
13-
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
14-
cd $SCRIPTS_DIR/..
15+
if [ -z $ARCHITECTURE ]; then
16+
echo "No architecture specified, defaulting to amd64"
17+
ARCHITECTURE="amd64"
18+
fi
1519

1620
if [ "$ARCHITECTURE" != "amd64" -a "$ARCHITECTURE" != "arm64" ]; then
17-
echo "ERROR: For sandbox deploys, you must specify an architecture (amd64 or arm64)"
21+
echo "ERROR: Invalid architecture (must be amd64 OR arm64 for sandbox deploys)"
1822
exit 1
1923
fi
2024

21-
./scripts/build_binary_and_layer_dockerized.sh
22-
REGIONS=sa-east-1 aws-vault exec sandbox-account-admin -- ./scripts/publish_layers.sh
25+
if [ "$ARCHITECTURE" == "amd64" ]; then
26+
LAYER_NAME="Datadog-Extension"
27+
fi
28+
if [ "$ARCHITECTURE" == "arm64" ]; then
29+
LAYER_NAME="Datadog-Extension-ARM"
30+
fi
31+
32+
if [ -z $VERSION ]; then
33+
echo "No version specified, automatically incrementing version number"
34+
35+
LAST_LAYER_VERSION=$(
36+
aws-vault exec sandbox-account-admin -- \
37+
aws lambda list-layer-versions \
38+
--layer-name $LAYER_NAME \
39+
--region sa-east-1 \
40+
| jq -r ".LayerVersions | .[0] | .Version" \
41+
)
42+
if [ "$LAST_LAYER_VERSION" == "null" ]; then
43+
echo "Error auto-detecting the last layer version"
44+
exit 1
45+
else
46+
VERSION=$(($LAST_LAYER_VERSION+1))
47+
echo "Will publish new layer version as $VERSION"
48+
fi
49+
fi
50+
51+
# Move into the root directory
52+
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
53+
cd $SCRIPTS_DIR/..
2354

24-
# Automatically create PR against github.com/DataDog/documentation
25-
# If you'd like to test, please uncomment the below line
26-
# VERSION=$VERSION LAYER=datadog-lambda-extension ./scripts/create_documentation_pr.sh
55+
VERSION=$VERSION ARCHITECTURE=$ARCHITECTURE ./scripts/build_binary_and_layer_dockerized.sh
56+
VERSION=$VERSION ARCHITECTURE=$ARCHITECTURE REGIONS=sa-east-1 aws-vault exec sandbox-account-admin -- ./scripts/publish_layers.sh

0 commit comments

Comments
 (0)