Skip to content

Commit

Permalink
Store the built template on S3 for validation and create-stack
Browse files Browse the repository at this point in the history
  • Loading branch information
keithduncan committed Nov 26, 2021
1 parent ca7ef36 commit 3b081bb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
5 changes: 2 additions & 3 deletions .buildkite/steps/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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 \
Expand Down

0 comments on commit 3b081bb

Please sign in to comment.