From 07958811c87a27ea2511f31b2304d5c88e98e684 Mon Sep 17 00:00:00 2001 From: Richard Hurt Date: Thu, 26 Dec 2024 04:41:03 -0500 Subject: [PATCH] Update large CFN templates from S3 --- lib/stack-functions | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/stack-functions b/lib/stack-functions index ffbff5af..54c1b4fc 100644 --- a/lib/stack-functions +++ b/lib/stack-functions @@ -258,9 +258,19 @@ stack-update() { local capabilities_value=$(_bma_stack_capabilities $stack) [[ -z "${capabilities_value}" ]] || capabilities="--capabilities ${capabilities_value}" + local template_size=$(cat $template | wc -c) + if [ ${template_size} -gt 51200 ]; then + local filename="$(date -u "+%Y-%m-%dT%s")-$(basename $template)" + echo " template too large ... uploading to S3 ..." + aws s3 cp --quiet $template s3://$CFN_BUCKET/$filename + local template_path="--template-url https://${CFN_BUCKET}.s3.amazonaws.com/${filename}" + else + local template_path="--template-body file://$template" + fi + if aws cloudformation update-stack \ --stack-name $stack \ - --template-body file://$template \ + $template_path \ $parameters \ $capabilities \ --output text; then