From a212a4a88caf69b7b8b0a1e2cbd9cce3ae52ae85 Mon Sep 17 00:00:00 2001 From: Fabio Santos Date: Thu, 7 Jul 2022 16:15:16 +0100 Subject: [PATCH 1/4] Make aws_rds_cluster_instance resource support monthly performance insights retention period --- internal/service/rds/cluster_instance.go | 15 +++++++++++---- internal/service/rds/cluster_instance_test.go | 8 ++++++++ website/docs/r/rds_cluster_instance.html.markdown | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/internal/service/rds/cluster_instance.go b/internal/service/rds/cluster_instance.go index d0b03a42ba5..347e055ece7 100644 --- a/internal/service/rds/cluster_instance.go +++ b/internal/service/rds/cluster_instance.go @@ -210,10 +210,17 @@ func ResourceClusterInstance() *schema.Resource { }, "performance_insights_retention_period": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - ValidateFunc: validation.IntInSlice([]int{7, 731}), + Type: schema.TypeInt, + Optional: true, + Computed: true, + ValidateFunc: validation.Any( + validation.IntInSlice([]int{7, 731}), + validation.All( + validation.IntAtLeast(7), + validation.IntAtMost(731), + validation.IntDivisibleBy(31), + ), + ), }, "copy_tags_to_snapshot": { diff --git a/internal/service/rds/cluster_instance_test.go b/internal/service/rds/cluster_instance_test.go index 976de55c7ea..bdf1612b904 100644 --- a/internal/service/rds/cluster_instance_test.go +++ b/internal/service/rds/cluster_instance_test.go @@ -854,6 +854,14 @@ func TestAccRDSClusterInstance_performanceInsightsRetentionPeriod(t *testing.T) resource.TestCheckResourceAttr(resourceName, "performance_insights_retention_period", "7"), ), }, + { + Config: testAccClusterInstanceConfig_performanceInsightsRetentionPeriod(rName, 155), + Check: resource.ComposeTestCheckFunc( + testAccCheckClusterInstanceExists(resourceName, &dbInstance), + resource.TestCheckResourceAttr(resourceName, "performance_insights_enabled", "true"), + resource.TestCheckResourceAttr(resourceName, "performance_insights_retention_period", "155"), + ), + }, }, }) } diff --git a/website/docs/r/rds_cluster_instance.html.markdown b/website/docs/r/rds_cluster_instance.html.markdown index ff46dfb2ba4..32d4356ab5b 100644 --- a/website/docs/r/rds_cluster_instance.html.markdown +++ b/website/docs/r/rds_cluster_instance.html.markdown @@ -81,7 +81,7 @@ what IAM permissions are needed to allow Enhanced Monitoring for RDS Instances. * `auto_minor_version_upgrade` - (Optional) Indicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance window. Default `true`. * `performance_insights_enabled` - (Optional) Specifies whether Performance Insights is enabled or not. * `performance_insights_kms_key_id` - (Optional) ARN for the KMS key to encrypt Performance Insights data. When specifying `performance_insights_kms_key_id`, `performance_insights_enabled` needs to be set to true. -* `performance_insights_retention_period` - (Optional) Amount of time in days to retain Performance Insights data. Either 7 (7 days) or 731 (2 years). When specifying `performance_insights_retention_period`, `performance_insights_enabled` needs to be set to true. Defaults to '7'. +* `performance_insights_retention_period` - (Optional) Amount of time in days to retain Performance Insights data. The value must be at least 7 (7 days) and at most 731 (2 years) and multiple from 31. When specifying `performance_insights_retention_period`, `performance_insights_enabled` needs to be set to true. Defaults to '7'. * `copy_tags_to_snapshot` – (Optional, boolean) Indicates whether to copy all of the user-defined tags from the DB instance to snapshots of the DB instance. Default `false`. * `ca_cert_identifier` - (Optional) The identifier of the CA certificate for the DB instance. * `tags` - (Optional) A map of tags to assign to the instance. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. From ef357c110e89996401d0986726b68367fb7c7d5f Mon Sep 17 00:00:00 2001 From: Fabio Santos Date: Thu, 7 Jul 2022 16:18:12 +0100 Subject: [PATCH 2/4] Add changelog file --- .changelog/25729.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/25729.txt diff --git a/.changelog/25729.txt b/.changelog/25729.txt new file mode 100644 index 00000000000..61338f5ebd2 --- /dev/null +++ b/.changelog/25729.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_rds_cluster_instance: Add support to monthly performance insights retention period +``` From f1b16b79819a05d68b9457e81d0b611e070979fc Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 8 Jul 2022 15:35:42 -0400 Subject: [PATCH 3/4] Tweak CHANGELOG entry. --- .changelog/25729.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/25729.txt b/.changelog/25729.txt index 61338f5ebd2..4f64a5bbddf 100644 --- a/.changelog/25729.txt +++ b/.changelog/25729.txt @@ -1,3 +1,3 @@ ```release-note:enhancement -resource/aws_rds_cluster_instance: Add support to monthly performance insights retention period +resource/aws_rds_cluster_instance: Allow `performance_insights_retention_period` values that are multiples of `31` ``` From 072e42b2b79e29d70a3090773c32210fd3a6cb4c Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Fri, 8 Jul 2022 15:39:26 -0400 Subject: [PATCH 4/4] Tweak documentation. --- website/docs/r/rds_cluster_instance.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/rds_cluster_instance.html.markdown b/website/docs/r/rds_cluster_instance.html.markdown index 32d4356ab5b..8f5ffddf82f 100644 --- a/website/docs/r/rds_cluster_instance.html.markdown +++ b/website/docs/r/rds_cluster_instance.html.markdown @@ -81,7 +81,7 @@ what IAM permissions are needed to allow Enhanced Monitoring for RDS Instances. * `auto_minor_version_upgrade` - (Optional) Indicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance window. Default `true`. * `performance_insights_enabled` - (Optional) Specifies whether Performance Insights is enabled or not. * `performance_insights_kms_key_id` - (Optional) ARN for the KMS key to encrypt Performance Insights data. When specifying `performance_insights_kms_key_id`, `performance_insights_enabled` needs to be set to true. -* `performance_insights_retention_period` - (Optional) Amount of time in days to retain Performance Insights data. The value must be at least 7 (7 days) and at most 731 (2 years) and multiple from 31. When specifying `performance_insights_retention_period`, `performance_insights_enabled` needs to be set to true. Defaults to '7'. +* `performance_insights_retention_period` - (Optional) Amount of time in days to retain Performance Insights data. Valida values are `7`, `731` (2 years) or a multiple of `31`. When specifying `performance_insights_retention_period`, `performance_insights_enabled` needs to be set to true. Defaults to '7'. * `copy_tags_to_snapshot` – (Optional, boolean) Indicates whether to copy all of the user-defined tags from the DB instance to snapshots of the DB instance. Default `false`. * `ca_cert_identifier` - (Optional) The identifier of the CA certificate for the DB instance. * `tags` - (Optional) A map of tags to assign to the instance. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level.