Skip to content

Commit

Permalink
more doc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mriccia committed Mar 16, 2023
1 parent d697967 commit 0373c1c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/utilities/custom_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Inside the methods, implement your custom provisioning logic, and return a `Resp

Custom resources notify cloudformation either of `SUCCESS` or `FAILED` status. You have 2 utility methods to represent these responses: `Response.success(physicalResourceId)` and `Response.failed(physicalResourceId)`.
The `physicalResourceId` is an identifier that is used during the lifecycle operations of the Custom Resource.
You should supply a `physicalResourceId` during the `CREATE` operation, CloudFormation stores the `physicalResourceId` and includes it `UPDATE` and `DELETE` events.
You should generate a `physicalResourceId` during the `CREATE` operation, CloudFormation stores the `physicalResourceId` and includes it `UPDATE` and `DELETE` events.

Here an example of how to implement a Custom Resource using the powertools-cloudformation library:

Expand Down Expand Up @@ -167,7 +167,10 @@ with the Fn::GetAtt function.
public class SensitiveDataHandler extends AbstractResourceHandler {
@Override
protected Response create(CloudFormationCustomResourceEvent createEvent, Context context) {
String physicalResourceId = "my-sensitive-resource-" + UUID.randomUUID(); //Create a unique ID
return Response.builder()
.status(Response.Status.SUCCESS)
.physicalResourceId(physicalResourceId)
.value(Map.of("SomeSecret", sensitiveValue))
.noEcho(true)
.build();
Expand Down Expand Up @@ -201,8 +204,11 @@ public class CustomSerializationHandler extends AbstractResourceHandler {

@Override
protected Response create(CloudFormationCustomResourceEvent createEvent, Context context) {
String physicalResourceId = "my-policy-name-" + UUID.randomUUID(); //Create a unique ID
Policy policy = new Policy();
return Response.builder()
.status(Response.Status.SUCCESS)
.physicalResourceId(physicalResourceId)
.value(policy)
.objectMapper(policyMapper) // customize serialization
.build();
Expand Down

0 comments on commit 0373c1c

Please sign in to comment.