-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from buildkite/reduce-ci-costs
Reduce ci costs
- Loading branch information
Showing
4 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
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 "%" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule ecr
updated
from b5ea37 to 02c9f8