From b2bb56b10c1e5d14a30df9b55d769e9debde6822 Mon Sep 17 00:00:00 2001 From: roleyfoley Date: Tue, 21 Nov 2023 15:01:58 +1100 Subject: [PATCH] feat(db): add storage type configuration support - Adds options for provisioned Iops and throughput on rds instances --- aws/components/db/id.ftl | 33 +++++++++++++++++++++++++++++++++ aws/components/db/setup.ftl | 3 +++ aws/services/rds/resource.ftl | 23 +++++++++++++++++++---- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/aws/components/db/id.ftl b/aws/components/db/id.ftl index 91189f959..9e92087e2 100644 --- a/aws/components/db/id.ftl +++ b/aws/components/db/id.ftl @@ -14,3 +14,36 @@ AWS_AUTOSCALING_SERVICE ] /] + + +[@addResourceGroupAttributeValues + type=DB_COMPONENT_TYPE + provider=AWS_PROVIDER + extensions=[ + { + "Names" : "Storage", + "Description" : "Additional storage configuration options", + "Children" : [ + { + "Names": "Type", + "Description": "The type of storage to use for the database", + "Types": STRING_TYPE, + "Values" : ["gp2", "gp3", "io1", "standard"], + "Default": "gp2" + }, + { + "Names": "Throughput", + "Description": "Specifiy the throughput you want for gp-3 volumes", + "Types" : NUMBER_TYPE, + "Default" : -1 + }, + { + "Names" : "Iops", + "Description" : "Specify the IOPS you want for types that support it", + "Types" : NUMBER_TYPE, + "Default": -1 + } + ] + } + ] +/] diff --git a/aws/components/db/setup.ftl b/aws/components/db/setup.ftl index 200236413..26e930dba 100644 --- a/aws/components/db/setup.ftl +++ b/aws/components/db/setup.ftl @@ -1197,6 +1197,9 @@ copyTagsToSnapshot=true deletionProtection=deletionProtection cloudWatchLogExports=cloudWatchLogExports + storageType=solution["aws:Storage"].Type + storageIops=solution["aws:Storage"].Iops + storageThroughput=solution["aws:Storage"].Throughput maintenanceWindow= solution.MaintenanceWindow.Configured?then( getAmazonRdsMaintenanceWindow( diff --git a/aws/services/rds/resource.ftl b/aws/services/rds/resource.ftl index 9ec4fae5e..722bc6ac5 100644 --- a/aws/services/rds/resource.ftl +++ b/aws/services/rds/resource.ftl @@ -142,6 +142,9 @@ databaseName="" port="" retentionPeriod="" + storageType="" + storageIops=0 + storageThroughput=0 size="" snapshotArn="" dependencies="" @@ -183,7 +186,7 @@ size, size?c?string ), - "StorageType" : "gp2", + "StorageType" : storageType, "BackupRetentionPeriod" : retentionPeriod, "DBInstanceIdentifier": name, "VPCSecurityGroups": asArray( getReference(securityGroupId)), @@ -191,7 +194,19 @@ "EngineVersion": engineVersion, "CopyTagsToSnapshot": copyTagsToSnapshot, "DeletionProtection": deletionProtection - }, + } + + valueIfTrue( + { + "Iops": storageIops + }, + (["gp3", "io1"]?seq_contains(storageType) && storageIops > 0 ) + ) + + valueIfTrue( + { + "StorageThroughput": storageThroughput + }, + ( storageType == "gp3" && storageThroughput > 0 ) + ), ( !clusterMember ), { "DBClusterIdentifier" : getReference(clusterId), @@ -202,7 +217,7 @@ attributeIfContent( "EnableCloudwatchLogsExports", cloudWatchLogExports - ) + + ) + valueIfTrue( { "MultiAZ": true @@ -317,7 +332,7 @@ attributeIfContent( "EnableCloudwatchLogsExports", cloudWatchLogExports - ) + + ) + attributeIfContent( "PreferredMaintenanceWindow", maintenanceWindow