Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit aa6d4a8

Browse files
authored
Add placeholder update handler for CDI (#34)
1 parent 1c4ff15 commit aa6d4a8

File tree

6 files changed

+26
-8
lines changed

6 files changed

+26
-8
lines changed

aws-macie-customdataidentifier/aws-macie-customdataidentifier.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@
9999
"permissions": [
100100
"macie2:ListCustomDataIdentifiers"
101101
]
102+
},
103+
"update": {
104+
"permissions": []
102105
}
103106
}
104107
}

aws-macie-customdataidentifier/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<dependency>
2424
<groupId>software.amazon.cloudformation</groupId>
2525
<artifactId>aws-cloudformation-rpdk-java-plugin</artifactId>
26-
<version>2.0.0</version>
26+
<version>[2.0.0, 3.0.0)</version>
2727
</dependency>
2828
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
2929
<dependency>

aws-macie-customdataidentifier/src/main/java/software/amazon/macie/customdataidentifier/UpdateHandler.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import software.amazon.cloudformation.exceptions.CfnInvalidRequestException;
55
import software.amazon.cloudformation.proxy.AmazonWebServicesClientProxy;
66
import software.amazon.cloudformation.proxy.Logger;
7+
import software.amazon.cloudformation.proxy.OperationStatus;
78
import software.amazon.cloudformation.proxy.ProgressEvent;
89
import software.amazon.cloudformation.proxy.ProxyClient;
910
import software.amazon.cloudformation.proxy.ResourceHandlerRequest;
@@ -16,8 +17,12 @@ protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(
1617
final ProxyClient<Macie2Client> proxyClient,
1718
final Logger logger
1819
) {
19-
logger.log(String
20-
.format("Exception occurred for AWS account id [%s]. %s does not have an update handler.", request.getAwsAccountId(), ResourceModel.TYPE_NAME));
21-
throw new CfnInvalidRequestException(ResourceModel.TYPE_NAME);
20+
logger.log(String.format("AWS Account ID [%s] triggered %s dummy update handler",
21+
request.getAwsAccountId(), ResourceModel.TYPE_NAME));
22+
23+
return ProgressEvent.<ResourceModel, CallbackContext>builder()
24+
.resourceModel(request.getDesiredResourceState())
25+
.status(OperationStatus.SUCCESS)
26+
.build();
2227
}
2328
}

aws-macie-customdataidentifier/src/test/java/software/amazon/macie/customdataidentifier/UpdateHandlerTest.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
import software.amazon.awssdk.services.macie2.Macie2Client;
1010
import software.amazon.cloudformation.exceptions.CfnInvalidRequestException;
1111
import software.amazon.cloudformation.proxy.AmazonWebServicesClientProxy;
12+
import software.amazon.cloudformation.proxy.OperationStatus;
13+
import software.amazon.cloudformation.proxy.ProgressEvent;
1214
import software.amazon.cloudformation.proxy.ProxyClient;
1315
import software.amazon.cloudformation.proxy.ResourceHandlerRequest;
1416

1517
import java.time.Duration;
1618

19+
import static org.assertj.core.api.Assertions.assertThat;
1720
import static org.mockito.Mockito.mock;
1821

1922
@ExtendWith(MockitoExtension.class)
@@ -45,8 +48,15 @@ public void handleRequest_whenUpdateCalled_thenThrowInvalidRequestException() {
4548
.desiredResourceState(model)
4649
.build();
4750

48-
Assertions.assertThrows(CfnInvalidRequestException.class,
49-
() ->handler.handleRequest(proxy, request, new CallbackContext(), proxyClient, logger));
51+
final ProgressEvent<ResourceModel, CallbackContext> response = handler.handleRequest(proxy, request, new CallbackContext(), proxyClient, logger);
5052

53+
assertThat(response).isNotNull();
54+
assertThat(response.getStatus()).isEqualTo(OperationStatus.SUCCESS);
55+
assertThat(response.getCallbackContext()).isNull();
56+
assertThat(response.getCallbackDelaySeconds()).isEqualTo(0);
57+
assertThat(response.getResourceModel()).isEqualTo(ResourceModel.builder().build());
58+
assertThat(response.getResourceModels()).isNull();
59+
assertThat(response.getMessage()).isNull();
60+
assertThat(response.getErrorCode()).isNull();
5161
}
5262
}

aws-macie-findingsfilter/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<dependency>
2424
<groupId>software.amazon.cloudformation</groupId>
2525
<artifactId>aws-cloudformation-rpdk-java-plugin</artifactId>
26-
<version>2.0.0</version>
26+
<version>[2.0.0, 3.0.0)</version>
2727
</dependency>
2828
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
2929
<dependency>

aws-macie-session/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>software.amazon.cloudformation</groupId>
3232
<artifactId>aws-cloudformation-rpdk-java-plugin</artifactId>
33-
<version>2.0.0</version>
33+
<version>[2.0.0, 3.0.0)</version>
3434
</dependency>
3535
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
3636
<dependency>

0 commit comments

Comments
 (0)