Skip to content

Commit da49573

Browse files
authored
Merge pull request #907 from buildkite/keithduncan/update-cleanup-logic
Make the template own and delete the log group
2 parents c063fa2 + 5021ddb commit da49573

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

.buildkite/steps/cleanup.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ aws s3api list-buckets \
4848
| grep -E 'buildkite-aws-stack-test-.*-managedsecretsbucket' \
4949
| xargs -n1 -t -I% aws s3 rb s3://% --force
5050

51+
# Do this before deleting the stacks so we don't race with stack-managed log
52+
# groups
53+
echo "--- Deleting old lambda logs after ${cutoff_date_milli}"
54+
aws logs describe-log-groups \
55+
--log-group-name-prefix "/aws/lambda/buildkite-aws-stack-test-" \
56+
--query "$(printf 'logGroups[?creationTime<`%s`].[logGroupName]' "$cutoff_date_milli" )" \
57+
--output text \
58+
| xargs -n1 -t -I% aws logs delete-log-group --log-group-name "%"
59+
5160
echo "--- Deleting old cloudformation stacks"
5261
aws cloudformation describe-stacks \
5362
--output text \
@@ -62,10 +71,3 @@ aws ec2 describe-instances \
6271
--query "$(printf 'Reservations[].Instances[?LaunchTime<`%s`].[InstanceId]' "$cutoff_date")" \
6372
--output text \
6473
| xargs -n1 -t -I% aws ec2 terminate-instances --instance-ids "%"
65-
66-
echo "--- Deleting old lambda logs after ${cutoff_date_milli}"
67-
aws logs describe-log-groups \
68-
--log-group-name-prefix "/aws/lambda/buildkite-aws-stack-test-" \
69-
--query "$(printf 'logGroups[?creationTime<`%s`].[logGroupName]' "$cutoff_date_milli" )" \
70-
--output text \
71-
| xargs -n1 -t -I% aws logs delete-log-group --log-group-name "%"

0 commit comments

Comments
 (0)