@@ -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
@@ -236,10 +238,27 @@ Parameters:
236
238
Type : Number
237
239
Default : 3600
238
240
241
+ EnableEC2LogRetentionPolicy :
242
+ Type : String
243
+ Default : " false"
244
+ AllowedValues : ["true", "false"]
245
+ Description : >
246
+ Enable CloudWatch log retention policy for EC2 instance logs managed by the CloudWatch agent.
247
+ When enabled, EC2 logs older than EC2LogRetentionDays will be automatically deleted to reduce storage costs.
248
+ This only affects logs from Buildkite agents, system logs, and other EC2-generated logs - not Lambda or other AWS service logs.
249
+ WARNING: For existing stacks, this will delete historical EC2 logs older than the retention period. This action cannot be undone.
250
+
251
+ EC2LogRetentionDays :
252
+ Type : Number
253
+ Description : The number of days to retain CloudWatch Logs for EC2 instances managed by the CloudWatch agent (Buildkite agents, system logs, etc).
254
+ Default : 7
255
+ AllowedValues : [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653]
256
+
239
257
LogRetentionDays :
240
258
Type : Number
241
- Description : The number of days to retain the Cloudwatch Logs of the lambda.
242
- Default : " 1"
259
+ Description : The number of days to retain CloudWatch Logs for Lambda functions in the stack.
260
+ Default : 1
261
+ AllowedValues : [1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1827, 3653]
243
262
244
263
BuildkiteAgentEnableGracefulShutdown :
245
264
Description : >
@@ -1358,6 +1377,7 @@ Resources:
1358
1377
- logs:PutLogEvents
1359
1378
- logs:DescribeLogGroups
1360
1379
- logs:DescribeLogStreams
1380
+ - logs:PutRetentionPolicy
1361
1381
Resource : " *"
1362
1382
- Sid : Ssm
1363
1383
Effect : Allow
@@ -1622,6 +1642,8 @@ Resources:
1622
1642
$Env:ECR_PLUGIN_ENABLED="${EnableECRPlugin}"
1623
1643
$Env:DOCKER_LOGIN_PLUGIN_ENABLED="${EnableDockerLoginPlugin}"
1624
1644
$Env:AWS_REGION="${AWS::Region}"
1645
+ $Env:ENABLE_EC2_LOG_RETENTION_POLICY="${EnableEC2LogRetentionPolicy}"
1646
+ $Env:EC2_LOG_RETENTION_DAYS="${EC2LogRetentionDays}"
1625
1647
powershell -file C:\buildkite-agent\bin\bk-install-elastic-stack.ps1 >> C:\buildkite-agent\elastic-stack.log
1626
1648
</powershell>
1627
1649
- LocalSecretsBucket : !If
@@ -1721,6 +1743,8 @@ Resources:
1721
1743
RESOURCE_LIMITS_CPU_WEIGHT="${ResourceLimitsCPUWeight}" \
1722
1744
RESOURCE_LIMITS_CPU_QUOTA="${ResourceLimitsCPUQuota}" \
1723
1745
RESOURCE_LIMITS_IO_WEIGHT="${ResourceLimitsIOWeight}" \
1746
+ ENABLE_EC2_LOG_RETENTION_POLICY="${EnableEC2LogRetentionPolicy}" \
1747
+ EC2_LOG_RETENTION_DAYS="${EC2LogRetentionDays}" \
1724
1748
/usr/local/bin/bk-install-elastic-stack.sh
1725
1749
--==BOUNDARY==--
1726
1750
- LocalSecretsBucket : !If
0 commit comments