From 7ac1beec9460356c85b2e5e1041832f6d3d1445b Mon Sep 17 00:00:00 2001 From: ppapishe Date: Thu, 31 Oct 2024 00:09:37 -0700 Subject: [PATCH 1/8] Adding new output attribute to aws_rds_global_cluster resource --- CHANGELOG.md | 1 + internal/service/rds/global_cluster.go | 9 +++++++++ internal/service/rds/global_cluster_test.go | 1 + 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50d20a5973b..9b774b86274 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,6 +82,7 @@ FEATURES: ENHANCEMENTS: + * data-source/aws_imagebuilder_distribution_configuration: Add `distribution.s3_export_configuration` attribute ([#35492](https://github.com/hashicorp/terraform-provider-aws/issues/35492)) * data-source/aws_imagebuilder_image_recipe: Fix `block_device_mapping.0.ebs.0.delete_on_termination: '' expected type 'bool', got unconvertible type 'string'` errors ([#39928](https://github.com/hashicorp/terraform-provider-aws/issues/39928)) * resource/aws_codedeploy_deployment_group: Add `termination_hook_enabled` argument ([#35482](https://github.com/hashicorp/terraform-provider-aws/issues/35482)) diff --git a/internal/service/rds/global_cluster.go b/internal/service/rds/global_cluster.go index 4434722d9b3..b34e786e537 100644 --- a/internal/service/rds/global_cluster.go +++ b/internal/service/rds/global_cluster.go @@ -128,6 +128,10 @@ func resourceGlobalCluster() *schema.Resource { Computed: true, ForceNew: true, }, + "endpoint": { + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -219,6 +223,11 @@ func resourceGlobalClusterRead(ctx context.Context, d *schema.ResourceData, meta d.Set("global_cluster_resource_id", globalCluster.GlobalClusterResourceId) d.Set(names.AttrStorageEncrypted, globalCluster.StorageEncrypted) + // Set the endpoint attribute + if err := d.Set("endpoint", globalCluster.Endpoint); err != nil { + return sdkdiag.AppendErrorf(diags, "setting endpoint: %s", err) + } + oldEngineVersion, newEngineVersion := d.Get(names.AttrEngineVersion).(string), aws.ToString(globalCluster.EngineVersion) // For example a configured engine_version of "5.6.10a" and a returned engine_version of "5.6.global_10a". diff --git a/internal/service/rds/global_cluster_test.go b/internal/service/rds/global_cluster_test.go index 8bdaea1ee58..aa9bf2bc3c9 100644 --- a/internal/service/rds/global_cluster_test.go +++ b/internal/service/rds/global_cluster_test.go @@ -124,6 +124,7 @@ func TestAccRDSGlobalCluster_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "global_cluster_identifier", rName), resource.TestMatchResourceAttr(resourceName, "global_cluster_resource_id", regexache.MustCompile(`cluster-.+`)), resource.TestCheckResourceAttr(resourceName, names.AttrStorageEncrypted, acctest.CtFalse), + resource.TestCheckResourceAttrSet(resourceName, "endpoint"), ), }, { From 72d6b9865bdb48d7ae8d293aba300561c17a3c24 Mon Sep 17 00:00:00 2001 From: ppapishe Date: Thu, 31 Oct 2024 00:15:17 -0700 Subject: [PATCH 2/8] updated change log --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b774b86274..b180e48c0ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,7 +82,7 @@ FEATURES: ENHANCEMENTS: - +* resource/aws_rds_global_cluster: Add new `Endpoint` output attribute ([#39862](https://github.com/hashicorp/terraform-provider-aws/issues/39862)) * data-source/aws_imagebuilder_distribution_configuration: Add `distribution.s3_export_configuration` attribute ([#35492](https://github.com/hashicorp/terraform-provider-aws/issues/35492)) * data-source/aws_imagebuilder_image_recipe: Fix `block_device_mapping.0.ebs.0.delete_on_termination: '' expected type 'bool', got unconvertible type 'string'` errors ([#39928](https://github.com/hashicorp/terraform-provider-aws/issues/39928)) * resource/aws_codedeploy_deployment_group: Add `termination_hook_enabled` argument ([#35482](https://github.com/hashicorp/terraform-provider-aws/issues/35482)) From 8e9386a33885f2da6bad07b50dfb87edc0b91d18 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 14 Nov 2024 14:53:38 -0500 Subject: [PATCH 3/8] rds/global_cluster: Reorder arguments --- internal/service/rds/global_cluster.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/rds/global_cluster.go b/internal/service/rds/global_cluster.go index b34e786e537..25574243e65 100644 --- a/internal/service/rds/global_cluster.go +++ b/internal/service/rds/global_cluster.go @@ -61,6 +61,10 @@ func resourceGlobalCluster() *schema.Resource { Optional: true, Default: false, }, + "endpoint": { + Type: schema.TypeString, + Computed: true, + }, names.AttrEngine: { Type: schema.TypeString, Optional: true, @@ -128,10 +132,6 @@ func resourceGlobalCluster() *schema.Resource { Computed: true, ForceNew: true, }, - "endpoint": { - Type: schema.TypeString, - Computed: true, - }, }, } } From bb1d16fa083481231ad196c25d1865399d264e67 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 14 Nov 2024 15:02:42 -0500 Subject: [PATCH 4/8] Restore changelog --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b180e48c0ec..50d20a5973b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,7 +82,6 @@ FEATURES: ENHANCEMENTS: -* resource/aws_rds_global_cluster: Add new `Endpoint` output attribute ([#39862](https://github.com/hashicorp/terraform-provider-aws/issues/39862)) * data-source/aws_imagebuilder_distribution_configuration: Add `distribution.s3_export_configuration` attribute ([#35492](https://github.com/hashicorp/terraform-provider-aws/issues/35492)) * data-source/aws_imagebuilder_image_recipe: Fix `block_device_mapping.0.ebs.0.delete_on_termination: '' expected type 'bool', got unconvertible type 'string'` errors ([#39928](https://github.com/hashicorp/terraform-provider-aws/issues/39928)) * resource/aws_codedeploy_deployment_group: Add `termination_hook_enabled` argument ([#35482](https://github.com/hashicorp/terraform-provider-aws/issues/35482)) From 8c97183b521ab68d167749f4a9217e6a24fb81be Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 14 Nov 2024 15:02:54 -0500 Subject: [PATCH 5/8] Add changelog --- .changelog/39960.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/39960.txt diff --git a/.changelog/39960.txt b/.changelog/39960.txt new file mode 100644 index 00000000000..d50d8d26697 --- /dev/null +++ b/.changelog/39960.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_rds_global_cluster: Add `endpoint` argument to point to the writer DB instance in the current primary cluster +``` \ No newline at end of file From ca876c019ba36f8d93d121ee799889ae3433e575 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 14 Nov 2024 15:03:26 -0500 Subject: [PATCH 6/8] docs/rds_global_cluster: Add endpoint attribute --- website/docs/r/rds_global_cluster.html.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/website/docs/r/rds_global_cluster.html.markdown b/website/docs/r/rds_global_cluster.html.markdown index 7c8b5d5ae74..66e04170e59 100644 --- a/website/docs/r/rds_global_cluster.html.markdown +++ b/website/docs/r/rds_global_cluster.html.markdown @@ -217,6 +217,7 @@ This resource supports the following arguments: This resource exports the following attributes in addition to the arguments above: * `arn` - RDS Global Cluster Amazon Resource Name (ARN) +* `endpoint` - Writer endpoint for the new global database cluster. This endpoint always points to the writer DB instance in the current primary cluster. * `global_cluster_members` - Set of objects containing Global Cluster members. * `db_cluster_arn` - Amazon Resource Name (ARN) of member DB Cluster * `is_writer` - Whether the member is the primary DB Cluster From 10632250d145f5b5101a5c67fc6e47bd688aa6d1 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 14 Nov 2024 15:04:03 -0500 Subject: [PATCH 7/8] Use constants --- internal/service/rds/global_cluster.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/internal/service/rds/global_cluster.go b/internal/service/rds/global_cluster.go index 25574243e65..5777288899e 100644 --- a/internal/service/rds/global_cluster.go +++ b/internal/service/rds/global_cluster.go @@ -61,7 +61,7 @@ func resourceGlobalCluster() *schema.Resource { Optional: true, Default: false, }, - "endpoint": { + names.AttrEndpoint: { Type: schema.TypeString, Computed: true, }, @@ -214,6 +214,7 @@ func resourceGlobalClusterRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrARN, globalCluster.GlobalClusterArn) d.Set(names.AttrDatabaseName, globalCluster.DatabaseName) d.Set(names.AttrDeletionProtection, globalCluster.DeletionProtection) + d.Set(names.AttrEndpoint, globalCluster.Endpoint) d.Set(names.AttrEngine, globalCluster.Engine) d.Set("engine_lifecycle_support", globalCluster.EngineLifecycleSupport) d.Set("global_cluster_identifier", globalCluster.GlobalClusterIdentifier) @@ -223,11 +224,6 @@ func resourceGlobalClusterRead(ctx context.Context, d *schema.ResourceData, meta d.Set("global_cluster_resource_id", globalCluster.GlobalClusterResourceId) d.Set(names.AttrStorageEncrypted, globalCluster.StorageEncrypted) - // Set the endpoint attribute - if err := d.Set("endpoint", globalCluster.Endpoint); err != nil { - return sdkdiag.AppendErrorf(diags, "setting endpoint: %s", err) - } - oldEngineVersion, newEngineVersion := d.Get(names.AttrEngineVersion).(string), aws.ToString(globalCluster.EngineVersion) // For example a configured engine_version of "5.6.10a" and a returned engine_version of "5.6.global_10a". From 82251e9700abfc9a445cf3a8a5f6186ec9404646 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Thu, 14 Nov 2024 15:04:16 -0500 Subject: [PATCH 8/8] Use constants --- internal/service/rds/global_cluster_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/rds/global_cluster_test.go b/internal/service/rds/global_cluster_test.go index aa9bf2bc3c9..83e53ad8493 100644 --- a/internal/service/rds/global_cluster_test.go +++ b/internal/service/rds/global_cluster_test.go @@ -124,7 +124,7 @@ func TestAccRDSGlobalCluster_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "global_cluster_identifier", rName), resource.TestMatchResourceAttr(resourceName, "global_cluster_resource_id", regexache.MustCompile(`cluster-.+`)), resource.TestCheckResourceAttr(resourceName, names.AttrStorageEncrypted, acctest.CtFalse), - resource.TestCheckResourceAttrSet(resourceName, "endpoint"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrEndpoint), ), }, {