Skip to content

Commit cb0d33b

Browse files
committed
Make the template own and delete the log group
1 parent 4c26d00 commit cb0d33b

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

.buildkite/steps/cleanup.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,4 @@ aws ec2 describe-instances \
6161
--filters "Name=tag:Name,Values=Packer Builder" \
6262
--query "$(printf 'Reservations[].Instances[?LaunchTime<`%s`].[InstanceId]' "$cutoff_date")" \
6363
--output text \
64-
| 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 "%"
64+
| xargs -n1 -t -I% aws ec2 terminate-instances --instance-ids "%"

templates/aws-stack.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,14 @@ Resources:
10681068
Role: !GetAtt AsgProcessSuspenderRole.Arn
10691069
Runtime: 'python3.7'
10701070

1071+
# This mirrors the group that would be created by the lambda, but enforces
1072+
# a retention period and also ensures it's removed when the stack is removed
1073+
AzRebalancingSuspenderFunctionLogGroup:
1074+
Type: AWS::Logs::LogGroup
1075+
Properties:
1076+
LogGroupName: !Sub "/aws/lambda/${AzRebalancingSuspenderFunction}"
1077+
RetentionInDays: 1
1078+
10711079
AzRebalancingSuspender:
10721080
Type: AWS::CloudFormation::CustomResource
10731081
Version: 1.0

0 commit comments

Comments
 (0)