From 3b081bba6908a8a6398f6d37679636ce5d2ba360 Mon Sep 17 00:00:00 2001 From: Keith Duncan Date: Fri, 26 Nov 2021 13:14:21 +1000 Subject: [PATCH] Store the built template on S3 for validation and create-stack --- .buildkite/steps/launch.sh | 5 ++--- Makefile | 10 ++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.buildkite/steps/launch.sh b/.buildkite/steps/launch.sh index 76d5a2abe..bd5659562 100755 --- a/.buildkite/steps/launch.sh +++ b/.buildkite/steps/launch.sh @@ -103,11 +103,10 @@ echo "--- Building templates" make "mappings-for-${os}-${arch}-image" build/aws-stack.yml "IMAGE_ID=$image_id" echo "--- Validating templates" -# 2021-11-25 KD: template larger than template-body supports, needs moving to s3 -# make validate +make validate "BUCKET_PREFIX=$stack_name" echo "--- Creating stack ${stack_name}" -make create-stack "STACK_NAME=$stack_name" "SERVICE_ROLE=$service_role" +make create-stack "BUCKET_PREFIX=$stack_name" "STACK_NAME=$stack_name" "SERVICE_ROLE=$service_role" echo "+++ ⌛️ Waiting for update to complete" ./parfait watch-stack "${stack_name}" diff --git a/Makefile b/Makefile index a2249c48c..4c6ec17fa 100644 --- a/Makefile +++ b/Makefile @@ -143,12 +143,13 @@ ifdef SERVICE_ROLE role_arn="--role-arn=$(SERVICE_ROLE)" endif -create-stack: build/aws-stack.yml env-STACK_NAME +create-stack: build/aws-stack.yml env-STACK_NAME env-BUILDKITE_AWS_STACK_BUCKET env-BUCKET_PREFIX + aws s3 cp --content-type 'text/yaml' --acl public-read build/aws-stack.yml "s3://$(BUILDKITE_AWS_STACK_BUCKET)/$(BUCKET_PREFIX)/aws-stack.yml" aws cloudformation create-stack \ --output text \ --stack-name $(STACK_NAME) \ --disable-rollback \ - --template-body "file://$(PWD)/build/aws-stack.yml" \ + --template-url "s3://$(BUILDKITE_AWS_STACK_BUCKET)/$(BUCKET_PREFIX)/aws-stack.yml" \ --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \ --parameters "$$(cat config.json)" \ "$(role_arn)" @@ -175,10 +176,11 @@ bump-agent-version: git add README.md packer/linux/scripts/install-buildkite-agent.sh packer/windows/scripts/install-buildkite-agent.ps1 git commit -m "Bump buildkite-agent to v$(AGENT_VERSION)" -validate: build/aws-stack.yml +validate: build/aws-stack.yml env-BUILDKITE_AWS_STACK_BUCKET env-BUCKET_PREFIX + aws s3 cp --content-type 'text/yaml' --acl public-read build/aws-stack.yml "s3://$(BUILDKITE_AWS_STACK_BUCKET)/$(BUCKET_PREFIX)/aws-stack.yml" aws cloudformation validate-template \ --output text \ - --template-body "file://$(PWD)/build/aws-stack.yml" + --template-url "s3://$(BUILDKITE_AWS_STACK_BUCKET)/$(BUCKET_PREFIX)/aws-stack.yml" generate-toc: docker run -it --rm -v "$(PWD):/app" node:slim bash \