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

fix(cloudwatch-actions): multiple alarms with LambdaAction for the same Lambda fail (under feature flag) #28712

Merged
merged 10 commits into from
Jan 25, 2024

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Jan 15, 2024

Multiple alarms with LambdaAction for the same Lambda fail, because of the same logical IDs for generated lambda permissions.

alarmConcurrentLambdasMaximumReached.addAlarmAction(new awsCloudWatchActions.LambdaAction(lambda));
alarmRdsCpuUtilizationMaximumReached.addAlarmAction(new awsCloudWatchActions.LambdaAction(lambda));
throw new Error(`There is already a Construct with name '${childName}' in ${typeName}${name.length > 0 ? ' [' + name + ']' : ''}`);
            ^
Error: There is already a Construct with name 'AlarmPermission' in NodejsFunction [...]

Since the existing logical IDs would change, I implemented this with a feature flag.


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

@github-actions github-actions bot added the p2 label Jan 15, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team January 15, 2024 10:55
@github-actions github-actions bot added the distinguished-contributor [Pilot] contributed 50+ PRs to the CDK label Jan 15, 2024
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 has failed. See the aws-cdk-automation comment below for failure reasons. 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.

@go-to-k go-to-k changed the title fix(cloudwatch-actions): multiple alarms for the same Lambda actions fail fix(cloudwatch-actions): multiple alarms for the same Lambda fail Jan 15, 2024
@go-to-k go-to-k changed the title fix(cloudwatch-actions): multiple alarms for the same Lambda fail fix(cloudwatch-actions): multiple alarms for same Lambda fail Jan 15, 2024
@go-to-k go-to-k changed the title fix(cloudwatch-actions): multiple alarms for same Lambda fail fix(cloudwatch-actions): multiple alarms for same Lambda fail (under feature flag) Jan 15, 2024
@go-to-k go-to-k marked this pull request as ready for review January 15, 2024 12:32
@aws-cdk-automation aws-cdk-automation dismissed their stale review January 15, 2024 12:32

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@go-to-k go-to-k changed the title fix(cloudwatch-actions): multiple alarms for same Lambda fail (under feature flag) fix(cloudwatch-actions): multiple alarms for same Lambda with LambdaAction fail (under feature flag) Jan 15, 2024
@go-to-k go-to-k changed the title fix(cloudwatch-actions): multiple alarms for same Lambda with LambdaAction fail (under feature flag) fix(cloudwatch-actions): multiple alarms with LambdaAction for same Lambda fail (under feature flag) Jan 15, 2024
@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 Jan 15, 2024
@go-to-k go-to-k changed the title fix(cloudwatch-actions): multiple alarms with LambdaAction for same Lambda fail (under feature flag) fix(cloudwatch-actions): multiple alarms with LambdaAction for the same Lambda fail (under feature flag) Jan 15, 2024
change README

change README
@go-to-k go-to-k force-pushed the fix-cw-alarm-lambda branch from cf77df9 to 5e4ec23 Compare January 19, 2024 06:58
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.

Changes look good other than some minor feedback. Thanks for contributing and fixing this issue!

@go-to-k go-to-k requested a review from GavinZZ January 24, 2024 03:54
change test name

fix trailing-spaces
@go-to-k go-to-k force-pushed the fix-cw-alarm-lambda branch from c943d8c to ad877ac Compare January 24, 2024 04:24
@go-to-k
Copy link
Contributor Author

go-to-k commented Jan 24, 2024

@GavinZZ

Thanks for your review. I fixed, could you please take a look them?

@GavinZZ
Copy link
Contributor

GavinZZ commented Jan 24, 2024

Thanks for the quick turnaround, changes look good. Seems that one of the CI is failing though.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@go-to-k
Copy link
Contributor Author

go-to-k commented Jan 25, 2024

@GavinZZ I tried CI again and it seems successful. could you please take a look it?

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.

LGTM, thanks for the contribution!

Copy link
Contributor

mergify bot commented Jan 25, 2024

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 b1e3dfd into aws:main Jan 25, 2024
10 checks passed
@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 Jan 25, 2024
@go-to-k go-to-k deleted the fix-cw-alarm-lambda branch January 25, 2024 01:14
Vandita2020 pushed a commit to Vandita2020/aws-cdk that referenced this pull request Jan 30, 2024
…me Lambda fail (under feature flag) (aws#28712)

Multiple alarms with LambdaAction for the same Lambda fail, because of the same logical IDs for generated lambda permissions.

```ts
alarmConcurrentLambdasMaximumReached.addAlarmAction(new awsCloudWatchActions.LambdaAction(lambda));
alarmRdsCpuUtilizationMaximumReached.addAlarmAction(new awsCloudWatchActions.LambdaAction(lambda));
```

```
throw new Error(`There is already a Construct with name '${childName}' in ${typeName}${name.length > 0 ? ' [' + name + ']' : ''}`);
            ^
Error: There is already a Construct with name 'AlarmPermission' in NodejsFunction [...]
```

Since the existing logical IDs would change, I implemented this with a feature flag.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
SankyRed pushed a commit that referenced this pull request Feb 8, 2024
…me Lambda fail (under feature flag) (#28712)

Multiple alarms with LambdaAction for the same Lambda fail, because of the same logical IDs for generated lambda permissions.

```ts
alarmConcurrentLambdasMaximumReached.addAlarmAction(new awsCloudWatchActions.LambdaAction(lambda));
alarmRdsCpuUtilizationMaximumReached.addAlarmAction(new awsCloudWatchActions.LambdaAction(lambda));
```

```
throw new Error(`There is already a Construct with name '${childName}' in ${typeName}${name.length > 0 ? ' [' + name + ']' : ''}`);
            ^
Error: There is already a Construct with name 'AlarmPermission' in NodejsFunction [...]
```

Since the existing logical IDs would change, I implemented this with a feature flag.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants