Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit e3dc121

Browse files
author
Ray Janoka
committed
Making $CF_PARAMETERS in the deploy script backward compatible with any version of the main CF template
1 parent cb718f2 commit e3dc121

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

deploy_autotag.sh

+11-4
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ function select-release-version () {
177177
}
178178

179179
function cf-parameters () {
180+
# If we rename or delete parameters from the CF template, do not remove them from this list,
181+
# logic below keeps this list backward-compatible for older CF templates
180182
CF_PARAMETERS=$(cat <<EOF
181183
[
182184
{
@@ -210,6 +212,11 @@ function cf-parameters () {
210212
]
211213
EOF
212214
)
215+
216+
TEMPLATE_PARAMETER_KEYS=$(echo "$MAIN_TEMPLATE" | jq -r '.Parameters | [keys[]]')
217+
218+
# For backward-compatibility remove any CF_PARAMETERS that don't exist in the MAIN_TEMPLATE that has been selected
219+
CF_PARAMETERS=$(echo "$CF_PARAMETERS" | jq --argjson tpk "$TEMPLATE_PARAMETER_KEYS" -r '[.[] | select( .[] as $in | $tpk | index($in))]')
213220
}
214221

215222
function wait-for-stack () {
@@ -270,13 +277,13 @@ EOF
270277
ZIP_FILE="autotag-$MANAGE_RELEASE_VERSION.zip"
271278
S3_PATH="releases/$ZIP_FILE"
272279

280+
# TODO: this doesn't work before v0.5.1 because the JSON template wasn't in the repo
281+
MAIN_TEMPLATE=$(curl -sS ${GITHUB_URL}/${RELEASE_COMMIT}/cloud_formation/event_multi_region_template/autotag_event_main-template.json)
282+
273283
echo "Creating the Main CloudFormation Stack..."
274284

275285
cf-parameters
276286

277-
# TODO: this doesn't work before v0.5.1 because the template wasn't in the repo
278-
MAIN_TEMPLATE=$(curl -sS ${GITHUB_URL}/${RELEASE_COMMIT}/cloud_formation/event_multi_region_template/autotag_event_main-template.json)
279-
280287
aws cloudformation create-stack \
281288
$AWS_CREDENTIALS \
282289
--template-body "$MAIN_TEMPLATE" \
@@ -753,7 +760,7 @@ else
753760
S3_AWS_CREDENTIALS="$AWS_CREDENTIALS"
754761
fi
755762

756-
# defaults
763+
# CF template defaults
757764
[ -z "$LOG_RETENTION_DAYS" ] && export LOG_RETENTION_DAYS=90
758765
[ -z "$LOG_LEVEL_DEBUG" ] && export LOG_LEVEL_DEBUG=Disabled
759766
[ -z "$CREATE_TIME" ] && export CREATE_TIME=Enabled

0 commit comments

Comments
 (0)