diff --git a/.buildkite/steps/cleanup.sh b/.buildkite/steps/cleanup.sh index f24aaa9bf..149bcf705 100755 --- a/.buildkite/steps/cleanup.sh +++ b/.buildkite/steps/cleanup.sh @@ -1,5 +1,37 @@ #!/bin/bash -set -eu +# shellcheck disable=SC2016 +set -uo pipefail -echo "--- Deleting stack $AWS_STACK_NAME" -aws cloudformation delete-stack --stack-name "$AWS_STACK_NAME" \ No newline at end of file +if [[ $OSTYPE =~ ^darwin ]] ; then + cutoff_date=$(gdate --date='-2 days' +%Y-%m-%d) +else + cutoff_date=$(date --date='-2 days' +%Y-%m-%d) +fi + +if [[ -n "${AWS_STACK_NAME:-}" ]] ; then + echo "--- Deleting stack $AWS_STACK_NAME" + aws cloudformation delete-stack --stack-name "$AWS_STACK_NAME" +fi + +echo "--- Deleting test managed secrets buckets created" +aws s3api list-buckets \ + --output text \ + --query "$(printf 'Buckets[?CreationDate<`%s`].Name' "$cutoff_date" )" \ + | xargs -n1 \ + | grep -E 'buildkite-aws-stack-test-managedsecrets' \ + | xargs -n1 -t -I% aws s3 rb s3://% --force + +echo "--- Deleting old cloudformation stacks" +aws cloudformation describe-stacks \ + --output text \ + --query "$(printf 'Stacks[?CreationTime<`%s`].StackName' "$cutoff_date" )" \ + | xargs -n1 \ + | grep -E 'buildkite-aws-stack-test-\d+' \ + | xargs -n1 -t -I% aws cloudformation delete-stack --stack-name "%" + +echo "--- Deleting old packer builders" +aws ec2 describe-instances \ + --filters "Name=tag:Name,Values=Packer Builder" \ + --query "$(printf 'Reservations[].Instances[?LaunchTime<`%s`].InstanceId' "$cutoff_date")" \ + --output text \ + | xargs -n1 -t -I% aws ec2 terminate-instances --instance-ids "%" diff --git a/.buildkite/steps/test.sh b/.buildkite/steps/test.sh index c4422d9ff..c8aca1956 100755 --- a/.buildkite/steps/test.sh +++ b/.buildkite/steps/test.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC1117 set -eu vpc_id=$(aws ec2 describe-vpcs --filters "Name=isDefault,Values=true" --query "Vpcs[0].VpcId" --output text) @@ -58,6 +59,10 @@ cat << EOF > config.json { "ParameterKey": "ECRAccessPolicy", "ParameterValue": "readonly" + }, + { + "ParameterKey": "RootVolumeSize", + "ParameterValue": "10" } ] EOF diff --git a/packer/buildkite-ami.json b/packer/buildkite-ami.json index 762f512ea..7e7f431a5 100644 --- a/packer/buildkite-ami.json +++ b/packer/buildkite-ami.json @@ -4,7 +4,9 @@ "type": "amazon-ebs", "region": "us-east-1", "source_ami": "ami-643b1972", - "instance_type": "c4.large", + "instance_type": "i3.large", + "spot_price": "auto", + "spot_price_auto_product": "Linux/UNIX (Amazon VPC)", "ssh_username": "ec2-user", "ami_name": "buildkite-stack-{{isotime | clean_ami_name}}", "ami_description": "Buildkite CloudFormation Stack base image (Amazon Linux, buildkite-agent, docker, docker-compose, docker-gc, jq)", diff --git a/plugins/ecr b/plugins/ecr index b5ea37d22..02c9f8c80 160000 --- a/plugins/ecr +++ b/plugins/ecr @@ -1 +1 @@ -Subproject commit b5ea37d227d23cd1c4abdcbfef24115a3d04b78c +Subproject commit 02c9f8c8032103b5f9ef6c6a90bdb75d9da03b08