Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions aws-rds-globalcluster/aws-rds-globalcluster.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
"aurora-postgresql"
]
},
"Tags": {
"type": "array",
"maxItems": 50,
"uniqueItems": true,
"insertionOrder": false,
"description": "An array of key-value pairs to apply to this resource.",
"items": {
"$ref": "#/definitions/Tag"
}
},
"EngineLifecycleSupport": {
"description": "The life cycle type of the global cluster. You can use this setting to enroll your global cluster into Amazon RDS Extended Support.",
"type": "string"
Expand Down Expand Up @@ -46,6 +56,30 @@
"type": "boolean"
}
},
"definitions": {
"Tag": {
"description": "A key-value pair to associate with a resource.",
"type": "object",
"additionalProperties": false,
"properties": {
"Key": {
"type": "string",
"description": "The key name of the tag. You can specify a value that is 1 to 128 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -. ",
"minLength": 1,
"maxLength": 128
},
"Value": {
"type": "string",
"description": "The value for the tag. You can specify a value that is 0 to 256 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -. ",
"minLength": 0,
"maxLength": 256
}
},
"required": [
"Key"
]
}
},
"oneOf": [
{
"required": [
Expand Down Expand Up @@ -87,7 +121,9 @@
"update": {
"permissions": [
"rds:ModifyGlobalCluster",
"rds:DescribeGlobalClusters"
"rds:DescribeGlobalClusters",
"rds:AddTagsToResource",
"rds:RemoveTagsFromResource"
]
},
"delete": {
Expand All @@ -105,6 +141,14 @@
}
},
"tagging": {
"taggable": false
"taggable": true,
"tagOnCreate": true,
"tagUpdatable": true,
"cloudFormationSystemTags": true,
"tagProperty": "/properties/Tags",
"permissions": [
"rds:AddTagsToResource",
"rds:RemoveTagsFromResource"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ protected ProgressEvent<ResourceModel, CallbackContext> removeFromGlobalCluster(

protected ProgressEvent<ResourceModel, CallbackContext> createGlobalClusterWithSourceDBCluster(final AmazonWebServicesClientProxy proxy,
final ProxyClient<RdsClient> proxyClient,
final ProgressEvent<ResourceModel, CallbackContext> progress) {
final ProgressEvent<ResourceModel, CallbackContext> progress,
final Tagging.TagSet tagSet) {

if(progress.getCallbackContext().isGlobalClusterCreated()) return progress;
//check if sourceDbCluster is not null and is in format of Identifier
Expand All @@ -199,7 +200,7 @@ protected ProgressEvent<ResourceModel, CallbackContext> createGlobalClusterWithS
.done((describeDbClusterRequest, describeDbClusterResponse, proxyClient2, resourceModel, callbackContext) -> {
final String arn = describeDbClusterResponse.dbClusters().get(0).dbClusterArn();
try {
proxyClient2.injectCredentialsAndInvokeV2(Translator.createGlobalClusterRequest(resourceModel, arn), proxyClient2.client()::createGlobalCluster);
proxyClient2.injectCredentialsAndInvokeV2(Translator.createGlobalClusterRequest(resourceModel, arn, tagSet), proxyClient2.client()::createGlobalCluster);
callbackContext.setGlobalClusterCreated(true);
} catch (GlobalClusterAlreadyExistsException e) {
throw new CfnAlreadyExistsException(e);
Expand All @@ -210,7 +211,8 @@ protected ProgressEvent<ResourceModel, CallbackContext> createGlobalClusterWithS

protected ProgressEvent<ResourceModel, CallbackContext> createGlobalCluster(final AmazonWebServicesClientProxy proxy,
final ProxyClient<RdsClient> proxyClient,
final ProgressEvent<ResourceModel, CallbackContext> progress) {
final ProgressEvent<ResourceModel, CallbackContext> progress,
final Tagging.TagSet tagSet) {

return proxy.initiate("rds::create-global-cluster", proxyClient, progress.getResourceModel(), progress.getCallbackContext())
// request to create global cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@

public class Translator {

<<<<<<< HEAD
static CreateGlobalClusterRequest createGlobalClusterRequest(final ResourceModel model) {
return createGlobalClusterRequest(model, null);
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) {
static CreateGlobalClusterRequest createGlobalClusterRequest(final ResourceModel model, String dbClusterArn, final Tagging.TagSet tagSet) {
return CreateGlobalClusterRequest.builder()
.engine(model.getEngine())
.engineVersion(model.getEngineVersion())
Expand All @@ -33,6 +38,7 @@ static CreateGlobalClusterRequest createGlobalClusterRequest(final ResourceModel
.sourceDBClusterIdentifier(StringUtils.isBlank(dbClusterArn) ? model.getSourceDBClusterIdentifier() : dbClusterArn)
.storageEncrypted(model.getStorageEncrypted())
.engineLifecycleSupport(model.getEngineLifecycleSupport())
.tags(Tagging.translateTagsToSdk(tagSet))
.build();
}

Expand Down Expand Up @@ -85,4 +91,16 @@ static DescribeDbClustersRequest describeDbClustersRequest(final ResourceModel m
.dbClusterIdentifier(model.getSourceDBClusterIdentifier())
.build();
}

static Set<software.amazon.awssdk.services.rds.model.Tag> translateTagsToSdk(
final Collection<Tag> 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());
}
}