diff --git a/aws-rds-globalcluster/src/main/java/software/amazon/rds/globalcluster/BaseHandlerStd.java b/aws-rds-globalcluster/src/main/java/software/amazon/rds/globalcluster/BaseHandlerStd.java index c779c757..aeb088d5 100644 --- a/aws-rds-globalcluster/src/main/java/software/amazon/rds/globalcluster/BaseHandlerStd.java +++ b/aws-rds-globalcluster/src/main/java/software/amazon/rds/globalcluster/BaseHandlerStd.java @@ -188,7 +188,8 @@ protected ProgressEvent removeFromGlobalCluster( protected ProgressEvent createGlobalClusterWithSourceDBCluster(final AmazonWebServicesClientProxy proxy, final ProxyClient proxyClient, - final ProgressEvent progress) { + final ProgressEvent progress, + final Tagging.TagSet tagSet) { if(progress.getCallbackContext().isGlobalClusterCreated()) return progress; //check if sourceDbCluster is not null and is in format of Identifier @@ -199,7 +200,7 @@ protected ProgressEvent createGlobalClusterWithS .done((describeDbClusterRequest, describeDbClusterResponse, proxyClient2, resourceModel, callbackContext) -> { final String arn = describeDbClusterResponse.dbClusters().get(0).dbClusterArn(); try { - proxyClient2.injectCredentialsAndInvokeV2(Translator.createGlobalClusterRequest(resourceModel, arn, Tagging.TagSet.emptySet()), proxyClient2.client()::createGlobalCluster); + proxyClient2.injectCredentialsAndInvokeV2(Translator.createGlobalClusterRequest(resourceModel, arn, tagSet), proxyClient2.client()::createGlobalCluster); callbackContext.setGlobalClusterCreated(true); } catch (GlobalClusterAlreadyExistsException e) { throw new CfnAlreadyExistsException(e); @@ -210,7 +211,8 @@ protected ProgressEvent createGlobalClusterWithS protected ProgressEvent createGlobalCluster(final AmazonWebServicesClientProxy proxy, final ProxyClient proxyClient, - final ProgressEvent progress) { + final ProgressEvent progress, + final Tagging.TagSet tagSet) { return proxy.initiate("rds::create-global-cluster", proxyClient, progress.getResourceModel(), progress.getCallbackContext()) // request to create global cluster diff --git a/aws-rds-globalcluster/src/main/java/software/amazon/rds/globalcluster/Translator.java b/aws-rds-globalcluster/src/main/java/software/amazon/rds/globalcluster/Translator.java index 7bacf3ad..2b6df294 100644 --- a/aws-rds-globalcluster/src/main/java/software/amazon/rds/globalcluster/Translator.java +++ b/aws-rds-globalcluster/src/main/java/software/amazon/rds/globalcluster/Translator.java @@ -20,8 +20,13 @@ public class Translator { +<<<<<<< HEAD static CreateGlobalClusterRequest createGlobalClusterRequest(final ResourceModel model) { return createGlobalClusterRequest(model, null, Tagging.TagSet.emptySet()); +======= + static CreateGlobalClusterRequest createGlobalClusterRequest(final ResourceModel model, final Tagging.TagSet tagSet) { + return createGlobalClusterRequest(model, null, tagSet); +>>>>>>> d618efc (add tagging parameter for createGlobalCluster) } static CreateGlobalClusterRequest createGlobalClusterRequest(final ResourceModel model, String dbClusterArn, final Tagging.TagSet tagSet) { @@ -86,4 +91,16 @@ static DescribeDbClustersRequest describeDbClustersRequest(final ResourceModel m .dbClusterIdentifier(model.getSourceDBClusterIdentifier()) .build(); } + + static Set translateTagsToSdk( + final Collection tags + ) { + return Optional.ofNullable(tags).orElse(Collections.emptySet()) + .stream() + .map(tag -> software.amazon.awssdk.services.rds.model.Tag.builder() + .key(tag.getKey()) + .value(tag.getValue()) + .build()) + .collect(Collectors.toSet()); + } }