@@ -59,6 +59,8 @@ Metadata:
59
59
- BuildkiteWindowsAdministrator
60
60
- BuildkiteAgentScalerServerlessARN
61
61
- BuildkiteAgentScalerVersion
62
+ - EnableEC2LogRetentionPolicy
63
+ - EC2LogRetentionDays
62
64
- LogRetentionDays
63
65
- BuildkiteAgentEnableGracefulShutdown
64
66
@@ -234,10 +236,27 @@ Parameters:
234
236
Type : Number
235
237
Default : 3600
236
238
239
+ EnableEC2LogRetentionPolicy :
240
+ Type : String
241
+ Default : " false"
242
+ AllowedValues : ["true", "false"]
243
+ Description : >
244
+ Enable CloudWatch log retention policy for EC2 instance logs managed by the CloudWatch agent.
245
+ When enabled, EC2 logs older than EC2LogRetentionDays will be automatically deleted to reduce storage costs.
246
+ This only affects logs from Buildkite agents, system logs, and other EC2-generated logs - not Lambda or other AWS service logs.
247
+ WARNING: For existing stacks, this will delete historical EC2 logs older than the retention period. This action cannot be undone.
248
+
249
+ EC2LogRetentionDays :
250
+ Type : Number
251
+ Description : The number of days to retain CloudWatch Logs for EC2 instances managed by the CloudWatch agent (Buildkite agents, system logs, etc).
252
+ Default : 7
253
+ AllowedValues : [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653]
254
+
237
255
LogRetentionDays :
238
256
Type : Number
239
- Description : The number of days to retain the Cloudwatch Logs of the lambda.
240
- Default : " 1"
257
+ Description : The number of days to retain CloudWatch Logs for Lambda functions in the stack.
258
+ Default : 1
259
+ AllowedValues : [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653]
241
260
242
261
BuildkiteAgentEnableGracefulShutdown :
243
262
Description : >
@@ -895,13 +914,13 @@ Conditions:
895
914
896
915
UseInstanceType7 :
897
916
!Not [ !Equals [ !Select [ "6", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
898
-
917
+
899
918
UseInstanceType8 :
900
919
!Not [ !Equals [ !Select [ "7", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
901
-
920
+
902
921
UseInstanceType9 :
903
922
!Not [ !Equals [ !Select [ "8", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
904
-
923
+
905
924
UseInstanceType10 :
906
925
!Not [ !Equals [ !Select [ "9", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
907
926
@@ -910,13 +929,13 @@ Conditions:
910
929
911
930
UseInstanceType12 :
912
931
!Not [ !Equals [ !Select [ "11", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
913
-
932
+
914
933
UseInstanceType13 :
915
934
!Not [ !Equals [ !Select [ "12", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
916
935
917
936
UseInstanceType14 :
918
937
!Not [ !Equals [ !Select [ "13", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
919
-
938
+
920
939
UseInstanceType15 :
921
940
!Not [ !Equals [ !Select [ "14", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
922
941
@@ -925,13 +944,13 @@ Conditions:
925
944
926
945
UseInstanceType17 :
927
946
!Not [ !Equals [ !Select [ "16", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
928
-
947
+
929
948
UseInstanceType18 :
930
949
!Not [ !Equals [ !Select [ "17", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
931
-
950
+
932
951
UseInstanceType19 :
933
952
!Not [ !Equals [ !Select [ "18", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
934
-
953
+
935
954
UseInstanceType20 :
936
955
!Not [ !Equals [ !Select [ "19", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
937
956
@@ -943,7 +962,7 @@ Conditions:
943
962
944
963
UseInstanceType23 :
945
964
!Not [ !Equals [ !Select [ "22", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
946
-
965
+
947
966
UseInstanceType24 :
948
967
!Not [ !Equals [ !Select [ "23", !Split [ ",", !Join [ ",", [ !Ref InstanceTypes, "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""] ] ] ], ""] ]
949
968
@@ -1336,6 +1355,7 @@ Resources:
1336
1355
- logs:PutLogEvents
1337
1356
- logs:DescribeLogGroups
1338
1357
- logs:DescribeLogStreams
1358
+ - logs:PutRetentionPolicy
1339
1359
Resource : " *"
1340
1360
- Sid : Ssm
1341
1361
Effect : Allow
@@ -1597,6 +1617,8 @@ Resources:
1597
1617
$Env:ECR_PLUGIN_ENABLED="${EnableECRPlugin}"
1598
1618
$Env:DOCKER_LOGIN_PLUGIN_ENABLED="${EnableDockerLoginPlugin}"
1599
1619
$Env:AWS_REGION="${AWS::Region}"
1620
+ $Env:ENABLE_EC2_LOG_RETENTION_POLICY="${EnableEC2LogRetentionPolicy}"
1621
+ $Env:EC2_LOG_RETENTION_DAYS="${EC2LogRetentionDays}"
1600
1622
powershell -file C:\buildkite-agent\bin\bk-install-elastic-stack.ps1 >> C:\buildkite-agent\elastic-stack.log
1601
1623
</powershell>
1602
1624
- LocalSecretsBucket : !If
@@ -1686,6 +1708,8 @@ Resources:
1686
1708
RESOURCE_LIMITS_CPU_WEIGHT="${ResourceLimitsCPUWeight}" \
1687
1709
RESOURCE_LIMITS_CPU_QUOTA="${ResourceLimitsCPUQuota}" \
1688
1710
RESOURCE_LIMITS_IO_WEIGHT="${ResourceLimitsIOWeight}" \
1711
+ ENABLE_EC2_LOG_RETENTION_POLICY="${EnableEC2LogRetentionPolicy}" \
1712
+ EC2_LOG_RETENTION_DAYS="${EC2LogRetentionDays}" \
1689
1713
/usr/local/bin/bk-install-elastic-stack.sh
1690
1714
--==BOUNDARY==--
1691
1715
- LocalSecretsBucket : !If
0 commit comments