Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ecs): log retention for FireLensLogDriver #28354

Merged
merged 9 commits into from
Dec 19, 2023

Conversation

sakurai-ryo
Copy link
Contributor

This PR resolves the missing logs:PutRetentionPolicy permission issue when using FireLensLogDriver with CloudWatch Logs.

Description

When using FireLensLogDriver to send logs to CloudWatch Logs, we can specify the retention period for newly created Log Groups by specifying log_retention_days in the FireLensLogDriverProps.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.

// add firelens log router container if any application container is using firelens log driver,

if (logName === 'cloudwatch') {

While FireLensLogDriver allows specifying log_retention_days for Log Groups, FluentBit cannot set the retention period due to the absence of the logs:PutRetentionPolicy policy. Consequently, it results in an AccessDeniedException.
To address this, the PR adds the necessary logs:PutRetentionPolicy permission to the task role when log_retention_days is set in FireLensLogDriverProps.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

@aws-cdk-automation aws-cdk-automation requested a review from a team December 13, 2023 15:11
@github-actions github-actions bot added valued-contributor [Pilot] contributed between 6-12 PRs to the CDK p2 labels Dec 13, 2023
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 13, 2023
Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@sakurai-ryo sakurai-ryo changed the title fix(ecs): add logs:PutRetentionPolicy permission for FireLensLogDriver feat(ecs): support log retention for FireLensLogDriver Dec 14, 2023
@sakurai-ryo
Copy link
Contributor Author

@lpizzinidev
Thanks again for your review 👍
I added docs to the README.

Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small documentation nit.

Comment on lines 1132 to 1133
See the [Fluent Bit CloudWatch Configuration Parameters](https://docs.fluentbit.io/manual/pipeline/outputs/cloudwatch#configuration-parameters)
for more information about `log_retention_days`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Dec 14, 2023
Copy link
Contributor

@lpizzinidev lpizzinidev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 👍

@aws-cdk-automation aws-cdk-automation added the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Dec 14, 2023
sumupitchayan
sumupitchayan previously approved these changes Dec 18, 2023
Copy link
Contributor

mergify bot commented Dec 18, 2023

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).

@aws-cdk-automation aws-cdk-automation removed the pr/needs-maintainer-review This PR needs a review from a Core Team Member label Dec 18, 2023
@kaizencc kaizencc changed the title feat(ecs): support log retention for FireLensLogDriver feat(ecs): log retention for FireLensLogDriver Dec 19, 2023
@mergify mergify bot dismissed sumupitchayan’s stale review December 19, 2023 00:52

Pull request has been modified.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: fa05233
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

mergify bot commented Dec 19, 2023

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).

@mergify mergify bot merged commit 52a5579 into aws:main Dec 19, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 valued-contributor [Pilot] contributed between 6-12 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants