From 5a35925dfb3632a3a29b802eb03431045393134a Mon Sep 17 00:00:00 2001 From: Ben Moskovitz Date: Mon, 20 Nov 2023 16:38:26 +1100 Subject: [PATCH] Launch elastic test elastic stacks using templates from S3 We were previously using templates as a cli param, but there's a 51KB limit on that, which we've recently hit --- .buildkite/steps/launch.sh | 23 +++++++++++++++++++++-- Makefile | 5 ----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.buildkite/steps/launch.sh b/.buildkite/steps/launch.sh index f002e009f..23fbadad9 100755 --- a/.buildkite/steps/launch.sh +++ b/.buildkite/steps/launch.sh @@ -107,11 +107,30 @@ EOF echo "--- Building templates" make "mappings-for-${os}-${arch}-image" build/aws-stack.yml "IMAGE_ID=$image_id" +echo "--- Uploading test template to S3" +s3_bucket="buildkite-agent-elastic-stack-test-templates" +s3_key="templates/build-${BUILDKITE_BUILD_NUMBER}/${os}-${arch}/${BUILDKITE_COMMIT}.aws-stack.yml" + +# s3 cp requires old path style, cloudformation requires new http style. sigh. +upload_location="s3://${s3_bucket}/${s3_key}" +download_location="https://s3.amazonaws.com/${s3_bucket}/${s3_key}" + +aws s3 cp --content-type 'text/yaml' "build/aws-stack.yml" "$upload_location" + echo "--- Validating templates" -make validate +aws --no-cli-pager cloudformation validate-template \ + --output text \ + --template-url "$download_location" echo "--- Creating stack ${stack_name}" -make create-stack "STACK_NAME=$stack_name" "SERVICE_ROLE=$service_role" +aws cloudformation create-stack \ + --output text \ + --stack-name "${stack_name}" \ + --template-url "$download_location" \ + --disable-rollback \ + --capabilities CAPABILITY_IAM CAPABILITY_NAMED_IAM CAPABILITY_AUTO_EXPAND \ + --parameters "$(cat config.json)" \ + --role-arn "$service_role" echo "+++ ⌛️ Waiting for update to complete" ./parfait watch-stack "${stack_name}" diff --git a/Makefile b/Makefile index 5bd6d4e22..7a33078b1 100644 --- a/Makefile +++ b/Makefile @@ -243,11 +243,6 @@ bump-agent-version: $(SED) -Ei "s/AGENT_VERSION=.+/AGENT_VERSION=$(AGENT_VERSION)/g" packer/linux/scripts/install-buildkite-agent.sh $(SED) -Ei "s/\\\$$AGENT_VERSION = \".+\"/\$$AGENT_VERSION = \"$(AGENT_VERSION)\"/g" packer/windows/scripts/install-buildkite-agent.ps1 -validate: build/aws-stack.yml - aws --no-cli-pager cloudformation validate-template \ - --output text \ - --template-body "file://$(PWD)/build/aws-stack.yml" - generate-toc: docker run -it --rm -v "$(PWD):/app" node:slim bash \ -c "npm install -g markdown-toc && cd /app && markdown-toc -i README.md"