Skip to content

Conversation

QuantumNeuralCoder
Copy link
Contributor

same as #34331 but clean copy with feedback addressed

Issue # (if applicable)

Creates a loggroup if not specified by the user without waiting for the first run of lambda to create the loggroup by the service. this enables function tags to be applied to the loggroups.

Closes #.
#17533

Reason for this change

Refer README and issue.

Description of changes

Added a feature flag USE_CDK_MANAGED_LOGGROUP
Refer README section on ## Customizing Log Group Creation for more details

Describe any new or updated permissions being added

N/A

Description of how you validated changes

Unit and integ tests are added to this PR

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@QuantumNeuralCoder QuantumNeuralCoder changed the title feat(aws-lambda): add loggroup tag inherit using USE_CDK_MANAGED_LOGG… feat(lambda): add loggroup tag inherit using USE_CDK_MANAGED_LOGG… May 15, 2025
@github-actions github-actions bot added the p2 label May 15, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team May 15, 2025 23:19
@QuantumNeuralCoder QuantumNeuralCoder changed the title feat(lambda): add loggroup tag inherit using USE_CDK_MANAGED_LOGG… feat(lambda): allow propagating function tags to loggroup May 15, 2025
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label May 15, 2025
Copy link
Contributor

@GavinZZ GavinZZ left a comment

Choose a reason for hiding this comment

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

Approved with one comment

| **logRetention prop** | Legacy approach using Custom Resource | False | False | False | Does not support TPA |
| **logGroup prop** | Explicitly supplied by user in CDK app | True | True | True | Full support for TPA |
| **Lazy creation** | Lambda service creates logGroup on first invocation | False | False | False | Occurs when both logRetention and logGroup are undefined and USE_CDK_MANAGED_LOGGROUP is false |
| **USE_CDK_MANAGED_LOGGROUP** | CDK Lambda function construct creates log group with default props | True | True | True | Feature flag must be enabled |
Copy link
Contributor

@GavinZZ GavinZZ May 16, 2025

Choose a reason for hiding this comment

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

I think you missed my last comment on How is prop injection enabled for the USE_CDK_MANAGED_LOGGROUP enabled use case?

Copy link
Contributor Author

@QuantumNeuralCoder QuantumNeuralCoder May 16, 2025

Choose a reason for hiding this comment

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

follows the same pattern as current constructs added to construct tree. I have not tested Prop Injectors and Aspects for this change since this focussed on Tag propagation. The statements on support for these features stated in readme come from the fact that the new logGroup is being added to the construct tree and follows the same support of CDK features as a logGroup created in the CDK app by the user.

`,
introducedIn: { v2: 'V2_NEXT' },
recommendedValue: true,
compatibilityWithOldBehaviorMd: 'Disable the feature flag to let lambda service create logGroup or specify logGroup or logRetention',
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this helpful for the users? Isn't this supposed to explain to customers how to turn on the feature flag and still have a working stack without issues? In that case, this should somehow explain how to import the existing log group into the stack, no? I might be wrong, or it might be too complicated, but I wanted to double-check.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes I agree we should put (or at least link to) migration instructions here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure why we need an instruction here? Existing users would always maintain their current behaviours as is without this feature flag. New users by default opt in with this feature flag enabled. This compaibility with old behaviour IMO is for new users who wish to use the old behaviour and the description makes sense here to disable the feature flag.

@samson-keung samson-keung self-assigned this May 22, 2025
@QuantumNeuralCoder QuantumNeuralCoder force-pushed the new-lambda-loggroup-tag-inherit branch from d67e56c to 92ad68a Compare May 22, 2025 20:57
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2025
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter fails with the following errors:

❌ Features must contain a change to a README file.
❌ Features must contain a change to a test file.
❌ Features must contain a change to an integration test file and the resulting snapshot.

If you believe this pull request should receive an exemption, please comment and provide a justification. A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed, add Clarification Request to a comment.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution/core This is a PR that came from AWS. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants