-
Notifications
You must be signed in to change notification settings - Fork 90
fix(cloudformation-module): Use physicalResourceId when not provided by custom resource #1082
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
Conversation
* Variant 2: Use the request's physicalResourceId when in doubt and it isn't null
...n/src/main/java/software/amazon/lambda/powertools/cloudformation/CloudFormationResponse.java
Show resolved
Hide resolved
...n/src/main/java/software/amazon/lambda/powertools/cloudformation/CloudFormationResponse.java
Outdated
Show resolved
Hide resolved
...n/src/main/java/software/amazon/lambda/powertools/cloudformation/CloudFormationResponse.java
Show resolved
Hide resolved
...-cloudformation/src/main/java/software/amazon/lambda/powertools/cloudformation/Response.java
Show resolved
Hide resolved
...-cloudformation/src/main/java/software/amazon/lambda/powertools/cloudformation/Response.java
Show resolved
Hide resolved
...software/amazon/lambda/powertools/cloudformation/handlers/RuntimeExceptionThrownHandler.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Jérôme Van Der Linden <[email protected]>
Please can we add the following tests:
Adding these tests will ensure that we are indeed sending the provided |
A further improvement on this functionality would be to allow Powertools users to specify which A few scenarios where this would be useful:
Example: a custom resource creates an S3 bucket and with a specified lifecycle rule for expiring objects.
|
@mriccia good idea! I've added tests to cover both SUCCESS/FAILED responses specifying physicalResourceId from the user's handler. |
...n/src/main/java/software/amazon/lambda/powertools/cloudformation/CloudFormationResponse.java
Show resolved
Hide resolved
...ain/java/software/amazon/lambda/powertools/cloudformation/AbstractCustomResourceHandler.java
Show resolved
Hide resolved
...n/src/main/java/software/amazon/lambda/powertools/cloudformation/CloudFormationResponse.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks like it satisfies our goals of 1/ resolving #1081 while 2/ not introducing breaking changes; both extensive discussion and reviewing of the code and our new test coverage help ensure this.
I have one outstanding question inline about the logic for physicalResourceId choice being spread about. This might just how it has to be to maintain the interfaces, but I wanted to raise for discussion before we merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding in the additional tests Scott.
We should make 1 modification before pushing, in CloudFormationResponse.java here and here we should also retrieve the physicalResourceId
from the event if present.
Separately, I agree that we need to centralise the logic on assigning physicalResourceId
to a single place, in my view this can be done in V2.
...ain/java/software/amazon/lambda/powertools/cloudformation/AbstractCustomResourceHandler.java
Show resolved
Hide resolved
...n/src/main/java/software/amazon/lambda/powertools/cloudformation/CloudFormationResponse.java
Outdated
Show resolved
Hide resolved
...n/src/main/java/software/amazon/lambda/powertools/cloudformation/CloudFormationResponse.java
Outdated
Show resolved
Hide resolved
...est/java/software/amazon/lambda/powertools/cloudformation/CloudFormationIntegrationTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Issue #, if available:
#1081
Description of changes:
Use physicalResourceId when not provided by custom resource.
Checklist
Breaking change checklist
No breaking changes
Response.success() and Response.failed are deprecated
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.