feat(ecs): log retention for FireLensLogDriver#28354
Conversation
…fix-firelens-publogpolicy
…fix-firelens-publogpolicy
lpizzinidev
left a comment
There was a problem hiding this comment.
Looks good to me! 👍
I think that this should be a feat: feat(ecs): support log retention for FireLensLogDriver.
You could add some documentation about the newly supported option here.
|
@lpizzinidev |
lpizzinidev
left a comment
There was a problem hiding this comment.
Small documentation nit.
| See the [Fluent Bit CloudWatch Configuration Parameters](https://docs.fluentbit.io/manual/pipeline/outputs/cloudwatch#configuration-parameters) | ||
| for more information about `log_retention_days`. |
There was a problem hiding this comment.
| See the [Fluent Bit CloudWatch Configuration Parameters](https://docs.fluentbit.io/manual/pipeline/outputs/cloudwatch#configuration-parameters) | |
| for more information about `log_retention_days`. | |
| > Visit [Fluent Bit CloudWatch Configuration Parameters](https://docs.fluentbit.io/manual/pipeline/outputs/cloudwatch#configuration-parameters) | |
| for more details. |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
This PR resolves the missing
logs:PutRetentionPolicypermission issue when usingFireLensLogDriverwith CloudWatch Logs.Description
When using
FireLensLogDriverto send logs to CloudWatch Logs, we can specify the retention period for newly created Log Groups by specifyinglog_retention_daysin theFireLensLogDriverProps.options.https://docs.fluentbit.io/manual/pipeline/outputs/cloudwatch#configuration-parameters
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.FireLensLogDriverProps.html#options
If you have not added a FluentBit container, CDK will automatically add it to the task definition, and the IAM permissions required for this are added to the task role.
aws-cdk/packages/aws-cdk-lib/aws-ecs/lib/base/task-definition.ts
Line 816 in db22b85
aws-cdk/packages/aws-cdk-lib/aws-ecs/lib/firelens-log-router.ts
Line 170 in db22b85
While
FireLensLogDriverallows specifyinglog_retention_daysfor Log Groups, FluentBit cannot set the retention period due to the absence of thelogs:PutRetentionPolicypolicy. Consequently, it results in anAccessDeniedException.To address this, the PR adds the necessary
logs:PutRetentionPolicypermission to the task role whenlog_retention_daysis set inFireLensLogDriverProps.options, ensuring FluentBit has the required permissions to set the retention period for Log Groups.Relates to #28258
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license