fix(cloudformation-module): Use physicalResourceId when not provided by custom resource#1082
fix(cloudformation-module): Use physicalResourceId when not provided by custom resource#1082msailes merged 15 commits intoaws-powertools:masterfrom msailes:cfn-fix
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 <117538+jeromevdl@users.noreply.github.com>
|
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
scottgerring
left a comment
There was a problem hiding this comment.
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.
mriccia
left a comment
There was a problem hiding this comment.
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.
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.