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

custom-resources: PR:29648 caused Custom resources to be replaced #30121

Closed
p3tek opened this issue May 9, 2024 · 8 comments · Fixed by #30418 · 4 remaining pull requests
Closed

custom-resources: PR:29648 caused Custom resources to be replaced #30121

p3tek opened this issue May 9, 2024 · 8 comments · Fixed by #30418 · 4 remaining pull requests
Assignees
Labels
@aws-cdk/custom-resources Related to AWS CDK Custom Resources bug This issue is a bug.

Comments

@p3tek
Copy link

p3tek commented May 9, 2024

Describe the bug

the following PR - #29648 added an additional "logApiResponseData":true to the custom resource properties.

This triggered a replacement of existing custom resources which is not a good outcome for "onCreate" resources that are only meant to be executed once

Expected Behavior

Not have existing custom-resources replaced with this update.

Current Behavior

"logApiResponseData":true was not present prior to this PR and the custom resource was not triggered on stack update

Reproduction Steps

will trigger after an update of aws-cdk-lib

Possible Solution

allow this value to be suppressed so it doesn't trigger a resource replacement ?

Additional Information/Context

No response

CDK CLI Version

2.138.0

Framework Version

2.138.0

Node.js Version

18.16.1

OS

linux

Language

TypeScript

Language Version

No response

Other information

No response

@p3tek p3tek added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels May 9, 2024
@github-actions github-actions bot added the @aws-cdk/custom-resources Related to AWS CDK Custom Resources label May 9, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels May 9, 2024
@khushail khushail self-assigned this May 9, 2024
@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels May 17, 2024
@colifran
Copy link
Contributor

Hey @p3tek, thanks for raising this. From what I'm seeing the problem isn't necessarily the new event property being passed. What I mean is that any change we make to the underlying handler code (new property or not) will also trigger an update since it will force a change in the asset hash. This would lock us into a situation where we are unable to make any code changes because they would all force an update. Are you able to just duplicate whatever SDK call you're making for onUpdate so that you keep the same behavior in the event of an update?

@khushail khushail removed their assignment May 17, 2024
@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label May 17, 2024
@heikkis
Copy link

heikkis commented May 29, 2024

Basically the CDK version upgrade causes new parameter to be added -> CR onUpdate is executed -> random problem if the CR Update method is not tested/used a lot/never.

@heikkis
Copy link

heikkis commented May 29, 2024

@khushail is it known and accepted issue that CDK upgrade can trigger all custom resources update execution?

#29949 (comment)

@p3tek
Copy link
Author

p3tek commented May 29, 2024

@colifran

Thanks for the response and apologies for delay in getting back to you

I actually resolved it on my end by doing exactly as you recommended (added an onUpdate) and duplicated the onCreate

Idealy though when a new attribute is added it shouldn't be forced into the template when it's not specified (for custom resources at least where some custom code is going to get executed)

@heikkis
Copy link

heikkis commented May 29, 2024

@colifran Triggering all CR's is a big thing. The pipeline can be stuck for hours, onUpdate etc. method are not normally tested -> suddenly those are tested/used. What you think?

@colifran
Copy link
Contributor

@heikkis I was under the impression that any change to the handler code would have triggered an update, but I've learned that is not the case. That said I agree. I think this should be fixed so that the default is that no parameter is passed. Will work on a PR for this.

@colifran colifran self-assigned this Jun 1, 2024
@mergify mergify bot closed this as completed in #30418 Jun 6, 2024
mergify bot pushed a commit that referenced this issue Jun 6, 2024
…ce event properties by default (#30418)

Closes #30121, #29949

### Reason for this change

PR #29648 introduced a new resource property `logApiResponseData`. This resource property is `true` by default which forces an update for `AwsCustomResource`. For users without `onUpdate` configured an empty data object is returned if no SDK call is configured. This can cause an attribute error if the user is depending on a data from a specific SDK call.

### Description of changes

Made `logApiResponseData` undefined by default which will not trigger `onUpdate`. To maintain backwards compatibility with the original PR introducing `logApiResponseData` as true by default, I've also introduced a feature flag that will allow users to keep the current behavior so they aren't now forced into another `onUpdate` event.

### Description of how you validated changes

Updated unit tests where `logApiResponseData` was added as a resource property. Added new unit test to verify that `logApiResponseData` could be added to the event. Updated unit tests that test `_render()` to ensure that the default case will result in an empty object. Updated integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

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

github-actions bot commented Jun 6, 2024

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Leo10Gama pushed a commit to Leo10Gama/aws-cdk that referenced this issue Jun 11, 2024
…ce event properties by default (aws#30418)

Closes aws#30121, aws#29949

### Reason for this change

PR aws#29648 introduced a new resource property `logApiResponseData`. This resource property is `true` by default which forces an update for `AwsCustomResource`. For users without `onUpdate` configured an empty data object is returned if no SDK call is configured. This can cause an attribute error if the user is depending on a data from a specific SDK call.

### Description of changes

Made `logApiResponseData` undefined by default which will not trigger `onUpdate`. To maintain backwards compatibility with the original PR introducing `logApiResponseData` as true by default, I've also introduced a feature flag that will allow users to keep the current behavior so they aren't now forced into another `onUpdate` event.

### Description of how you validated changes

Updated unit tests where `logApiResponseData` was added as a resource property. Added new unit test to verify that `logApiResponseData` could be added to the event. Updated unit tests that test `_render()` to ensure that the default case will result in an empty object. Updated integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
mazyu36 pushed a commit to mazyu36/aws-cdk that referenced this issue Jun 22, 2024
…ce event properties by default (aws#30418)

Closes aws#30121, aws#29949

### Reason for this change

PR aws#29648 introduced a new resource property `logApiResponseData`. This resource property is `true` by default which forces an update for `AwsCustomResource`. For users without `onUpdate` configured an empty data object is returned if no SDK call is configured. This can cause an attribute error if the user is depending on a data from a specific SDK call.

### Description of changes

Made `logApiResponseData` undefined by default which will not trigger `onUpdate`. To maintain backwards compatibility with the original PR introducing `logApiResponseData` as true by default, I've also introduced a feature flag that will allow users to keep the current behavior so they aren't now forced into another `onUpdate` event.

### Description of how you validated changes

Updated unit tests where `logApiResponseData` was added as a resource property. Added new unit test to verify that `logApiResponseData` could be added to the event. Updated unit tests that test `_render()` to ensure that the default case will result in an empty object. Updated integ tests.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@aws-cdk-automation
Copy link
Collaborator

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.

@aws aws locked as resolved and limited conversation to collaborators Jul 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.