Skip to content

Commit

Permalink
Disable tagOnCreate
Browse files Browse the repository at this point in the history
  • Loading branch information
philicai authored and angusy29 committed Nov 8, 2024
1 parent 93c4015 commit cd03363
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion aws-rds-dbshardgroup/aws-rds-dbshardgroup.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"rds:RemoveTagsFromResource"
],
"taggable": true,
"tagOnCreate": true,
"tagOnCreate": false,
"tagUpdatable": true,
"tagProperty": "/properties/Tags"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,26 +59,18 @@ protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(
}

return ProgressEvent.progress(request.getDesiredResourceState(), callbackContext)
.then(progress -> Tagging.createWithTaggingFallback(proxy, proxyClient, this::createDbShardGroup, progress, allTags)
.then(p -> Commons.execOnce(p, () -> {
final Tagging.TagSet extraTags = Tagging.TagSet.builder()
.stackTags(allTags.getStackTags())
.resourceTags(allTags.getResourceTags())
.build();
return addTags(proxyClient, request, p, extraTags);
}, CallbackContext::isAddTagsComplete, CallbackContext::setAddTagsComplete))
)
.then(progress -> createDbShardGroup(proxy, proxyClient, progress))
.then(progress -> Commons.execOnce(progress, () -> addTags(proxyClient, request, progress, allTags), CallbackContext::isAddTagsComplete, CallbackContext::setAddTagsComplete))
.then(progress -> new ReadHandler().handleRequest(proxy, proxyClient, request, callbackContext));
}

private ProgressEvent<ResourceModel, CallbackContext> createDbShardGroup(
final AmazonWebServicesClientProxy proxy,
final ProxyClient<RdsClient> proxyClient,
final ProgressEvent<ResourceModel, CallbackContext> progress,
final Tagging.TagSet tags
final ProgressEvent<ResourceModel, CallbackContext> progress
) {
return proxy.initiate("rds::create-db-shard-group", proxyClient, progress.getResourceModel(), progress.getCallbackContext())
.translateToServiceRequest((resourceModel) -> Translator.createDbShardGroupRequest(resourceModel, tags))
.translateToServiceRequest((resourceModel) -> Translator.createDbShardGroupRequest(resourceModel))
.backoffDelay(config.getBackoff())
.makeServiceCall((createDbShardGroupRequest, proxyInvocation) -> proxyInvocation.injectCredentialsAndInvokeV2(createDbShardGroupRequest, proxyInvocation.client()::createDBShardGroup))
.stabilize((createRequest, createResponse, proxyInvocation, model, context) -> isDBShardGroupStabilizedAfterMutate(model, proxyInvocation))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@

public class Translator {

static CreateDbShardGroupRequest createDbShardGroupRequest(final ResourceModel model) {
return CreateDbShardGroupRequest.builder()
.computeRedundancy(model.getComputeRedundancy())
.dbClusterIdentifier(model.getDBClusterIdentifier())
.dbShardGroupIdentifier(model.getDBShardGroupIdentifier())
.maxACU(model.getMaxACU())
.minACU(model.getMinACU())
.publiclyAccessible(model.getPubliclyAccessible())
.build();
}

static CreateDbShardGroupRequest createDbShardGroupRequest(final ResourceModel model, final Tagging.TagSet tags) {
return CreateDbShardGroupRequest.builder()
.computeRedundancy(model.getComputeRedundancy())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void handleRequest_SimpleSuccess() {
Objects.equals(DB_SHARD_GROUP_CREATING.dbShardGroupIdentifier(), req.dbShardGroupIdentifier())
)
);
verify(proxyClient.client(), times(2)).describeDBShardGroups(
verify(proxyClient.client(), times(3)).describeDBShardGroups(
ArgumentMatchers.<DescribeDbShardGroupsRequest>argThat(req ->
Objects.equals(DB_SHARD_GROUP_CREATING.dbShardGroupIdentifier(), req.dbShardGroupIdentifier())
)
Expand Down Expand Up @@ -180,7 +180,7 @@ public void handleRequest_NoDbShardGroupIdentifier() {
Objects.equals(dbShardGroupIdentifier, req.dbShardGroupIdentifier())
)
);
verify(proxyClient.client(), times(2)).describeDBShardGroups(
verify(proxyClient.client(), times(3)).describeDBShardGroups(
ArgumentMatchers.<DescribeDbShardGroupsRequest>argThat(req ->
Objects.equals(dbShardGroupIdentifier, req.dbShardGroupIdentifier())
)
Expand Down Expand Up @@ -255,7 +255,7 @@ public void handleRequest_Stabilize() {
Objects.equals(DB_SHARD_GROUP_CREATING.dbShardGroupIdentifier(), req.dbShardGroupIdentifier())
)
);
verify(proxyClient.client(), times(3)).describeDBShardGroups(
verify(proxyClient.client(), times(4)).describeDBShardGroups(
ArgumentMatchers.<DescribeDbShardGroupsRequest>argThat(req ->
Objects.equals(DB_SHARD_GROUP_CREATING.dbShardGroupIdentifier(), req.dbShardGroupIdentifier())
)
Expand Down

0 comments on commit cd03363

Please sign in to comment.