Skip to content

Commit

Permalink
Launch elastic test elastic stacks using templates from S3
Browse files Browse the repository at this point in the history
We were previously using templates as a cli param, but there's a 51KB limit on that, which we've recently hit
  • Loading branch information
moskyb committed Nov 21, 2023
1 parent 477e418 commit 5a35925
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
23 changes: 21 additions & 2 deletions .buildkite/steps/launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit 5a35925

Please # to comment.