From f5cf47361c39eef6c3b51a7d2bd5b5b98ef96e6c Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Tue, 14 Jan 2025 14:33:49 -0800 Subject: [PATCH 1/6] `firehose` --- .ci/semgrep/acctest/checks/arn.yml | 1 - internal/service/firehose/delivery_stream_test.go | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.ci/semgrep/acctest/checks/arn.yml b/.ci/semgrep/acctest/checks/arn.yml index c7a60b1cd2a..7d7d694fb9d 100644 --- a/.ci/semgrep/acctest/checks/arn.yml +++ b/.ci/semgrep/acctest/checks/arn.yml @@ -5,7 +5,6 @@ rules: paths: exclude: - "internal/service/controltower" - - "internal/service/firehose" - "internal/service/globalaccelerator" - "internal/service/guardduty" - "internal/service/iam" diff --git a/internal/service/firehose/delivery_stream_test.go b/internal/service/firehose/delivery_stream_test.go index c17a38ba46c..6699bc3a512 100644 --- a/internal/service/firehose/delivery_stream_test.go +++ b/internal/service/firehose/delivery_stream_test.go @@ -40,7 +40,7 @@ func TestAccFirehoseDeliveryStream_basic(t *testing.T) { Config: testAccDeliveryStreamConfig_extendedS3basic(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckDeliveryStreamExists(ctx, resourceName, &stream), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "firehose", "deliverystream/{name}"), resource.TestCheckResourceAttr(resourceName, names.AttrDestination, "extended_s3"), resource.TestCheckResourceAttrSet(resourceName, "destination_id"), resource.TestCheckResourceAttr(resourceName, "elasticsearch_configuration.#", "0"), @@ -81,6 +81,7 @@ func TestAccFirehoseDeliveryStream_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "extended_s3_configuration.0.s3_backup_mode", "Disabled"), resource.TestCheckResourceAttr(resourceName, "http_endpoint_configuration.#", "0"), resource.TestCheckResourceAttr(resourceName, "iceberg_configuration.#", "0"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrID, resourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "kinesis_source_configuration.#", "0"), resource.TestCheckResourceAttr(resourceName, "msk_source_configuration.#", "0"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), @@ -1245,7 +1246,7 @@ func TestAccFirehoseDeliveryStream_snowflakeUpdates(t *testing.T) { Config: testAccDeliveryStreamConfig_snowflakeBasic(rName, key), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckDeliveryStreamExists(ctx, resourceName, &stream), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "firehose", "deliverystream/{name}"), resource.TestCheckResourceAttr(resourceName, names.AttrDestination, "snowflake"), resource.TestCheckResourceAttrSet(resourceName, "destination_id"), resource.TestCheckResourceAttr(resourceName, "elasticsearch_configuration.#", "0"), @@ -1314,7 +1315,7 @@ func TestAccFirehoseDeliveryStream_snowflakeUpdates(t *testing.T) { Config: testAccDeliveryStreamConfig_snowflakeUpdate(rName, key), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckDeliveryStreamExists(ctx, resourceName, &stream), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "firehose", "deliverystream/{name}"), resource.TestCheckResourceAttr(resourceName, names.AttrDestination, "snowflake"), resource.TestCheckResourceAttrSet(resourceName, "destination_id"), resource.TestCheckResourceAttr(resourceName, "elasticsearch_configuration.#", "0"), @@ -1390,7 +1391,7 @@ func TestAccFirehoseDeliveryStream_snowflakeUpdates(t *testing.T) { Config: testAccDeliveryStreamConfig_snowflakeUpdateSecretsManager(rName, key), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckDeliveryStreamExists(ctx, resourceName, &stream), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "firehose", "deliverystream/{name}"), resource.TestCheckResourceAttr(resourceName, names.AttrDestination, "snowflake"), resource.TestCheckResourceAttrSet(resourceName, "destination_id"), resource.TestCheckResourceAttr(resourceName, "elasticsearch_configuration.#", "0"), @@ -2249,7 +2250,7 @@ func TestAccFirehoseDeliveryStream_openSearchServerlessUpdates(t *testing.T) { Config: testAccDeliveryStreamConfig_openSearchServerlessBasic(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckDeliveryStreamExists(ctx, resourceName, &stream), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "firehose", "deliverystream/{name}"), resource.TestCheckResourceAttr(resourceName, names.AttrDestination, "opensearchserverless"), resource.TestCheckResourceAttrSet(resourceName, "destination_id"), resource.TestCheckResourceAttr(resourceName, "elasticsearch_configuration.#", "0"), @@ -2309,7 +2310,7 @@ func TestAccFirehoseDeliveryStream_openSearchServerlessUpdates(t *testing.T) { Config: testAccDeliveryStreamConfig_openSearchServerlessUpdate(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckDeliveryStreamExists(ctx, resourceName, &stream), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "firehose", "deliverystream/{name}"), resource.TestCheckResourceAttr(resourceName, names.AttrDestination, "opensearchserverless"), resource.TestCheckResourceAttrSet(resourceName, "destination_id"), resource.TestCheckResourceAttr(resourceName, "elasticsearch_configuration.#", "0"), From 9f485b31927d54d96e9d0f2553b8bc461308d162 Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Tue, 14 Jan 2025 15:34:46 -0800 Subject: [PATCH 2/6] `guardduty` --- .ci/semgrep/acctest/checks/arn.yml | 1 - internal/service/guardduty/malware_protection_plan_test.go | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.ci/semgrep/acctest/checks/arn.yml b/.ci/semgrep/acctest/checks/arn.yml index 7d7d694fb9d..b5ac02828a8 100644 --- a/.ci/semgrep/acctest/checks/arn.yml +++ b/.ci/semgrep/acctest/checks/arn.yml @@ -6,7 +6,6 @@ rules: exclude: - "internal/service/controltower" - "internal/service/globalaccelerator" - - "internal/service/guardduty" - "internal/service/iam" - "internal/service/iot" - "internal/service/kafka" diff --git a/internal/service/guardduty/malware_protection_plan_test.go b/internal/service/guardduty/malware_protection_plan_test.go index e69bd27d420..2de34745d57 100644 --- a/internal/service/guardduty/malware_protection_plan_test.go +++ b/internal/service/guardduty/malware_protection_plan_test.go @@ -53,7 +53,7 @@ func TestAccGuardDutyMalwareProtectionPlan_basic(t *testing.T) { Config: testAccMalwareProtectionPlanConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckMalwareProtectionPlanExists(ctx, resourceName, &malwareProtectionPlan), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "guardduty", "malware-protection-plan/{id}"), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreatedAt), resource.TestCheckResourceAttrSet(resourceName, names.AttrID), resource.TestCheckResourceAttrPair(resourceName, names.AttrRole, "aws_iam_role.test", names.AttrARN), From 23ec20b74321482ce47940a7e703ede384cb990f Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Tue, 14 Jan 2025 15:43:33 -0800 Subject: [PATCH 3/6] `iam` --- .ci/semgrep/acctest/checks/arn.yml | 1 - .../iam/server_certificate_data_source_test.go | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.ci/semgrep/acctest/checks/arn.yml b/.ci/semgrep/acctest/checks/arn.yml index b5ac02828a8..bef251a31a5 100644 --- a/.ci/semgrep/acctest/checks/arn.yml +++ b/.ci/semgrep/acctest/checks/arn.yml @@ -6,7 +6,6 @@ rules: exclude: - "internal/service/controltower" - "internal/service/globalaccelerator" - - "internal/service/iam" - "internal/service/iot" - "internal/service/kafka" - "internal/service/kafkaconnect" diff --git a/internal/service/iam/server_certificate_data_source_test.go b/internal/service/iam/server_certificate_data_source_test.go index 8ce7f7006f5..85afe7edd6c 100644 --- a/internal/service/iam/server_certificate_data_source_test.go +++ b/internal/service/iam/server_certificate_data_source_test.go @@ -21,6 +21,9 @@ func TestAccIAMServerCertificateDataSource_basic(t *testing.T) { key := acctest.TLSRSAPrivateKeyPEM(t, 2048) certificate := acctest.TLSRSAX509SelfSignedCertificatePEM(t, key, "example.com") + dataSourceName := "data.aws_iam_server_certificate.test" + resourceName := "aws_iam_server_certificate.test_cert" + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.IAMServiceID), @@ -30,14 +33,13 @@ func TestAccIAMServerCertificateDataSource_basic(t *testing.T) { { Config: testAccServerCertificateDataSourceConfig_cert(rName, key, certificate), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("aws_iam_server_certificate.test_cert", names.AttrARN), - resource.TestCheckResourceAttrSet("data.aws_iam_server_certificate.test", names.AttrARN), - resource.TestCheckResourceAttrSet("data.aws_iam_server_certificate.test", names.AttrID), - resource.TestCheckResourceAttrSet("data.aws_iam_server_certificate.test", names.AttrName), - resource.TestCheckResourceAttrSet("data.aws_iam_server_certificate.test", names.AttrPath), - resource.TestCheckResourceAttrSet("data.aws_iam_server_certificate.test", "upload_date"), - resource.TestCheckResourceAttr("data.aws_iam_server_certificate.test", names.AttrCertificateChain, ""), - resource.TestMatchResourceAttr("data.aws_iam_server_certificate.test", "certificate_body", regexache.MustCompile("^-----BEGIN CERTIFICATE-----")), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrARN, resourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrID, resourceName, names.AttrID), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrName, resourceName, names.AttrName), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrPath, resourceName, names.AttrPath), + resource.TestCheckResourceAttrPair(dataSourceName, "upload_date", resourceName, "upload_date"), + resource.TestCheckResourceAttr(dataSourceName, names.AttrCertificateChain, ""), + resource.TestMatchResourceAttr(dataSourceName, "certificate_body", regexache.MustCompile("^-----BEGIN CERTIFICATE-----")), ), }, }, From da19df65c67f48047fb227febb36afeda1685e44 Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Tue, 14 Jan 2025 16:23:43 -0800 Subject: [PATCH 4/6] `globalaccelerator` --- .changelog/placeholder.txt | 15 ++++++++ .ci/semgrep/acctest/checks/arn.yml | 1 - .../service/globalaccelerator/accelerator.go | 5 +++ .../accelerator_data_source_test.go | 2 +- .../globalaccelerator/accelerator_test.go | 3 ++ .../cross_account_attachment_test.go | 5 ++- .../custom_routing_accelerator.go | 5 +++ ...om_routing_accelerator_data_source_test.go | 2 +- .../custom_routing_accelerator_test.go | 3 ++ .../custom_routing_endpoint_group_test.go | 21 ++++++----- .../custom_routing_listener.go | 6 ++++ .../custom_routing_listener_test.go | 6 +++- .../globalaccelerator/endpoint_group_test.go | 36 +++++++++---------- .../service/globalaccelerator/listener.go | 5 +++ .../globalaccelerator/listener_test.go | 8 +++-- .../shield/protection_data_source_test.go | 2 +- internal/service/shield/protection_test.go | 2 +- ...lobalaccelerator_accelerator.html.markdown | 1 + ...r_custom_routing_accelerator.html.markdown | 1 + ...ustom_routing_endpoint_group.html.markdown | 2 +- ...ator_custom_routing_listener.html.markdown | 2 +- ...alaccelerator_endpoint_group.html.markdown | 2 +- .../globalaccelerator_listener.html.markdown | 3 +- 23 files changed, 98 insertions(+), 40 deletions(-) create mode 100644 .changelog/placeholder.txt diff --git a/.changelog/placeholder.txt b/.changelog/placeholder.txt new file mode 100644 index 00000000000..64df89839d3 --- /dev/null +++ b/.changelog/placeholder.txt @@ -0,0 +1,15 @@ +```release-note:enhancement +resource/aws_globalaccelerator_accelerator: Add `arn` attribute +``` + +```release-note:enhancement +resource/aws_globalaccelerator_custom_routing_accelerator: Add `arn` attribute +``` + +```release-note:enhancement +resource/aws_globalaccelerator_custom_routing_listener: Add `arn` attribute +``` + +```release-note:enhancement +resource/aws_globalaccelerator_listener: Add `arn` attribute +``` diff --git a/.ci/semgrep/acctest/checks/arn.yml b/.ci/semgrep/acctest/checks/arn.yml index bef251a31a5..b3b1bc0025c 100644 --- a/.ci/semgrep/acctest/checks/arn.yml +++ b/.ci/semgrep/acctest/checks/arn.yml @@ -5,7 +5,6 @@ rules: paths: exclude: - "internal/service/controltower" - - "internal/service/globalaccelerator" - "internal/service/iot" - "internal/service/kafka" - "internal/service/kafkaconnect" diff --git a/internal/service/globalaccelerator/accelerator.go b/internal/service/globalaccelerator/accelerator.go index 9263261d210..0f553de9c48 100644 --- a/internal/service/globalaccelerator/accelerator.go +++ b/internal/service/globalaccelerator/accelerator.go @@ -47,6 +47,10 @@ func resourceAccelerator() *schema.Resource { }, Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, names.AttrAttributes: { Type: schema.TypeList, Optional: true, @@ -202,6 +206,7 @@ func resourceAcceleratorRead(ctx context.Context, d *schema.ResourceData, meta i return sdkdiag.AppendErrorf(diags, "reading Global Accelerator Accelerator (%s): %s", d.Id(), err) } + d.Set(names.AttrARN, accelerator.AcceleratorArn) d.Set(names.AttrDNSName, accelerator.DnsName) d.Set("dual_stack_dns_name", accelerator.DualStackDnsName) d.Set(names.AttrEnabled, accelerator.Enabled) diff --git a/internal/service/globalaccelerator/accelerator_data_source_test.go b/internal/service/globalaccelerator/accelerator_data_source_test.go index c8cc0845210..d269ca027f3 100644 --- a/internal/service/globalaccelerator/accelerator_data_source_test.go +++ b/internal/service/globalaccelerator/accelerator_data_source_test.go @@ -84,7 +84,7 @@ resource "aws_globalaccelerator_accelerator" "test" { } data "aws_globalaccelerator_accelerator" "test_by_arn" { - arn = aws_globalaccelerator_accelerator.test.id + arn = aws_globalaccelerator_accelerator.test.arn } data "aws_globalaccelerator_accelerator" "test_by_name" { diff --git a/internal/service/globalaccelerator/accelerator_test.go b/internal/service/globalaccelerator/accelerator_test.go index 58566233bfd..615a028be97 100644 --- a/internal/service/globalaccelerator/accelerator_test.go +++ b/internal/service/globalaccelerator/accelerator_test.go @@ -21,6 +21,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" tfglobalaccelerator "github.com/hashicorp/terraform-provider-aws/internal/service/globalaccelerator" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" + "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -41,6 +42,7 @@ func TestAccGlobalAcceleratorAccelerator_basic(t *testing.T) { Config: testAccAcceleratorConfig_basic(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckAcceleratorExists(ctx, resourceName), + acctest.MatchResourceAttrGlobalARN(ctx, resourceName, names.AttrARN, "globalaccelerator", regexache.MustCompile(`accelerator/`+verify.UUIDRegexPattern+`$`)), resource.TestCheckResourceAttr(resourceName, "attributes.#", "1"), resource.TestCheckResourceAttr(resourceName, "attributes.0.flow_logs_enabled", acctest.CtFalse), resource.TestCheckResourceAttr(resourceName, "attributes.0.flow_logs_s3_bucket", ""), @@ -49,6 +51,7 @@ func TestAccGlobalAcceleratorAccelerator_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "dual_stack_dns_name", ""), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, names.AttrHostedZoneID, "Z2BJ6XQ5FK7U4H"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrID, resourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrIPAddressType, "IPV4"), resource.TestCheckResourceAttr(resourceName, "ip_addresses.#", "0"), resource.TestCheckResourceAttr(resourceName, "ip_sets.#", "1"), diff --git a/internal/service/globalaccelerator/cross_account_attachment_test.go b/internal/service/globalaccelerator/cross_account_attachment_test.go index aea7d266dc6..ae842489203 100644 --- a/internal/service/globalaccelerator/cross_account_attachment_test.go +++ b/internal/service/globalaccelerator/cross_account_attachment_test.go @@ -8,6 +8,7 @@ import ( "fmt" "testing" + "github.com/YakDriver/regexache" awstypes "github.com/aws/aws-sdk-go-v2/service/globalaccelerator/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -16,6 +17,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" tfglobalaccelerator "github.com/hashicorp/terraform-provider-aws/internal/service/globalaccelerator" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" + "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -36,8 +38,9 @@ func TestAccGlobalAcceleratorCrossAccountAttachment_basic(t *testing.T) { Config: testAccCrossAccountAttachmentConfig_basic(rName1), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckCrossAccountAttachmentExists(ctx, resourceName, &v), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.MatchResourceAttrGlobalARN(ctx, resourceName, names.AttrARN, "globalaccelerator", regexache.MustCompile(`attachment/`+verify.UUIDRegexPattern+`$`)), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreatedTime), + resource.TestCheckResourceAttrPair(resourceName, names.AttrID, resourceName, names.AttrARN), resource.TestCheckResourceAttrSet(resourceName, "last_modified_time"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName1), resource.TestCheckResourceAttr(resourceName, "principals.#", "0"), diff --git a/internal/service/globalaccelerator/custom_routing_accelerator.go b/internal/service/globalaccelerator/custom_routing_accelerator.go index ff3837de545..d4cd06955d6 100644 --- a/internal/service/globalaccelerator/custom_routing_accelerator.go +++ b/internal/service/globalaccelerator/custom_routing_accelerator.go @@ -47,6 +47,10 @@ func resourceCustomRoutingAccelerator() *schema.Resource { }, Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, names.AttrAttributes: { Type: schema.TypeList, Optional: true, @@ -196,6 +200,7 @@ func resourceCustomRoutingAcceleratorRead(ctx context.Context, d *schema.Resourc return sdkdiag.AppendErrorf(diags, "reading Global Accelerator Custom Routing Accelerator (%s): %s", d.Id(), err) } + d.Set(names.AttrARN, accelerator.AcceleratorArn) d.Set(names.AttrDNSName, accelerator.DnsName) d.Set(names.AttrEnabled, accelerator.Enabled) d.Set(names.AttrHostedZoneID, meta.(*conns.AWSClient).GlobalAcceleratorHostedZoneID(ctx)) diff --git a/internal/service/globalaccelerator/custom_routing_accelerator_data_source_test.go b/internal/service/globalaccelerator/custom_routing_accelerator_data_source_test.go index 0d66bf94b4c..caaa15ff10b 100644 --- a/internal/service/globalaccelerator/custom_routing_accelerator_data_source_test.go +++ b/internal/service/globalaccelerator/custom_routing_accelerator_data_source_test.go @@ -60,7 +60,7 @@ resource "aws_globalaccelerator_custom_routing_accelerator" "test" { } data "aws_globalaccelerator_custom_routing_accelerator" "test_by_arn" { - arn = aws_globalaccelerator_custom_routing_accelerator.test.id + arn = aws_globalaccelerator_custom_routing_accelerator.test.arn } data "aws_globalaccelerator_custom_routing_accelerator" "test_by_name" { diff --git a/internal/service/globalaccelerator/custom_routing_accelerator_test.go b/internal/service/globalaccelerator/custom_routing_accelerator_test.go index 8b48aaeb7fe..f7d009d6b51 100644 --- a/internal/service/globalaccelerator/custom_routing_accelerator_test.go +++ b/internal/service/globalaccelerator/custom_routing_accelerator_test.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" tfglobalaccelerator "github.com/hashicorp/terraform-provider-aws/internal/service/globalaccelerator" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" + "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -36,6 +37,7 @@ func TestAccGlobalAcceleratorCustomRoutingAccelerator_basic(t *testing.T) { Config: testAccCustomRoutingAcceleratorConfig_basic(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckCustomRoutingAcceleratorExists(ctx, resourceName), + acctest.MatchResourceAttrGlobalARN(ctx, resourceName, names.AttrARN, "globalaccelerator", regexache.MustCompile(`accelerator/`+verify.UUIDRegexPattern+`$`)), resource.TestCheckResourceAttr(resourceName, "attributes.#", "1"), resource.TestCheckResourceAttr(resourceName, "attributes.0.flow_logs_enabled", acctest.CtFalse), resource.TestCheckResourceAttr(resourceName, "attributes.0.flow_logs_s3_bucket", ""), @@ -43,6 +45,7 @@ func TestAccGlobalAcceleratorCustomRoutingAccelerator_basic(t *testing.T) { resource.TestMatchResourceAttr(resourceName, names.AttrDNSName, dnsNameRegex), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, names.AttrHostedZoneID, "Z2BJ6XQ5FK7U4H"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrID, resourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrIPAddressType, "IPV4"), resource.TestCheckResourceAttr(resourceName, "ip_addresses.#", "0"), resource.TestCheckResourceAttr(resourceName, "ip_sets.#", "1"), diff --git a/internal/service/globalaccelerator/custom_routing_endpoint_group_test.go b/internal/service/globalaccelerator/custom_routing_endpoint_group_test.go index 680b00e4c7c..136bd579677 100644 --- a/internal/service/globalaccelerator/custom_routing_endpoint_group_test.go +++ b/internal/service/globalaccelerator/custom_routing_endpoint_group_test.go @@ -8,6 +8,7 @@ import ( "fmt" "testing" + "github.com/YakDriver/regexache" awstypes "github.com/aws/aws-sdk-go-v2/service/globalaccelerator/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -16,6 +17,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" tfglobalaccelerator "github.com/hashicorp/terraform-provider-aws/internal/service/globalaccelerator" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" + "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -35,7 +37,7 @@ func TestAccGlobalAcceleratorCustomRoutingEndpointGroup_basic(t *testing.T) { Config: testAccCustomRoutingEndpointGroupConfig_basic(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckCustomRoutingEndpointGroupExists(ctx, resourceName, &v), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.MatchResourceAttrGlobalARN(ctx, resourceName, names.AttrARN, "globalaccelerator", regexache.MustCompile(`accelerator/`+verify.UUIDRegexPattern+`/listener/[a-z0-9]{8}/endpoint-group/[a-z0-9]{12}$`)), resource.TestCheckResourceAttr(resourceName, "destination_configuration.#", "1"), resource.TestCheckResourceAttr(resourceName, "destination_configuration.0.from_port", "443"), resource.TestCheckResourceAttr(resourceName, "destination_configuration.0.protocols.#", "1"), @@ -43,6 +45,7 @@ func TestAccGlobalAcceleratorCustomRoutingEndpointGroup_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "destination_configuration.0.to_port", "8443"), resource.TestCheckResourceAttr(resourceName, "endpoint_configuration.#", "0"), resource.TestCheckResourceAttr(resourceName, "endpoint_group_region", acctest.Region()), + resource.TestCheckResourceAttrPair(resourceName, names.AttrID, resourceName, names.AttrARN), ), }, { @@ -94,7 +97,7 @@ func TestAccGlobalAcceleratorCustomRoutingEndpointGroup_endpointConfiguration(t Config: testAccCustomRoutingEndpointGroupConfig_endpointConfiguration(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckCustomRoutingEndpointGroupExists(ctx, resourceName, &v), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.MatchResourceAttrGlobalARN(ctx, resourceName, names.AttrARN, "globalaccelerator", regexache.MustCompile(`accelerator/`+verify.UUIDRegexPattern+`/listener/[a-z0-9]{8}/endpoint-group/[a-z0-9]{12}$`)), resource.TestCheckResourceAttr(resourceName, "destination_configuration.#", "1"), resource.TestCheckResourceAttr(resourceName, "destination_configuration.0.from_port", "8080"), resource.TestCheckResourceAttr(resourceName, "destination_configuration.0.protocols.#", "1"), @@ -130,7 +133,7 @@ func TestAccGlobalAcceleratorCustomRoutingEndpointGroup_endpointGroupRegion(t *t Config: testAccCustomRoutingEndpointGroupConfig_endpointGroupRegion(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckCustomRoutingEndpointGroupExists(ctx, resourceName, &v), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.MatchResourceAttrGlobalARN(ctx, resourceName, names.AttrARN, "globalaccelerator", regexache.MustCompile(`accelerator/`+verify.UUIDRegexPattern+`/listener/[a-z0-9]{8}/endpoint-group/[a-z0-9]{12}$`)), resource.TestCheckResourceAttr(resourceName, "destination_configuration.#", "1"), resource.TestCheckResourceAttr(resourceName, "destination_configuration.0.from_port", "443"), resource.TestCheckResourceAttr(resourceName, "destination_configuration.0.protocols.#", "1"), @@ -202,7 +205,7 @@ resource "aws_globalaccelerator_custom_routing_accelerator" "test" { } resource "aws_globalaccelerator_custom_routing_listener" "test" { - accelerator_arn = aws_globalaccelerator_custom_routing_accelerator.test.id + accelerator_arn = aws_globalaccelerator_custom_routing_accelerator.test.arn port_range { from_port = 443 @@ -211,7 +214,7 @@ resource "aws_globalaccelerator_custom_routing_listener" "test" { } resource "aws_globalaccelerator_custom_routing_endpoint_group" "test" { - listener_arn = aws_globalaccelerator_custom_routing_listener.test.id + listener_arn = aws_globalaccelerator_custom_routing_listener.test.arn destination_configuration { from_port = 443 @@ -229,7 +232,7 @@ resource "aws_globalaccelerator_custom_routing_accelerator" "test" { } resource "aws_globalaccelerator_custom_routing_listener" "test" { - accelerator_arn = aws_globalaccelerator_custom_routing_accelerator.test.id + accelerator_arn = aws_globalaccelerator_custom_routing_accelerator.test.arn port_range { from_port = 1 @@ -238,7 +241,7 @@ resource "aws_globalaccelerator_custom_routing_listener" "test" { } resource "aws_globalaccelerator_custom_routing_endpoint_group" "test" { - listener_arn = aws_globalaccelerator_custom_routing_listener.test.id + listener_arn = aws_globalaccelerator_custom_routing_listener.test.arn destination_configuration { from_port = 8080 @@ -288,7 +291,7 @@ resource "aws_globalaccelerator_custom_routing_accelerator" "test" { } resource "aws_globalaccelerator_custom_routing_listener" "test" { - accelerator_arn = aws_globalaccelerator_custom_routing_accelerator.test.id + accelerator_arn = aws_globalaccelerator_custom_routing_accelerator.test.arn port_range { from_port = 443 @@ -297,7 +300,7 @@ resource "aws_globalaccelerator_custom_routing_listener" "test" { } resource "aws_globalaccelerator_custom_routing_endpoint_group" "test" { - listener_arn = aws_globalaccelerator_custom_routing_listener.test.id + listener_arn = aws_globalaccelerator_custom_routing_listener.test.arn destination_configuration { from_port = 443 diff --git a/internal/service/globalaccelerator/custom_routing_listener.go b/internal/service/globalaccelerator/custom_routing_listener.go index 3f4e50137ca..06f05f53cb3 100644 --- a/internal/service/globalaccelerator/custom_routing_listener.go +++ b/internal/service/globalaccelerator/custom_routing_listener.go @@ -20,6 +20,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" + "github.com/hashicorp/terraform-provider-aws/names" ) // @SDKResource("aws_globalaccelerator_custom_routing_listener", name="Custom Routing Listener") @@ -46,6 +47,10 @@ func resourceCustomRoutingListener() *schema.Resource { Required: true, ForceNew: true, }, + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, "port_range": { Type: schema.TypeSet, Required: true, @@ -119,6 +124,7 @@ func resourceCustomRoutingListenerRead(ctx context.Context, d *schema.ResourceDa } d.Set("accelerator_arn", acceleratorARN) + d.Set(names.AttrARN, listener.ListenerArn) if err := d.Set("port_range", flattenPortRanges(listener.PortRanges)); err != nil { return sdkdiag.AppendErrorf(diags, "setting port_range: %s", err) } diff --git a/internal/service/globalaccelerator/custom_routing_listener_test.go b/internal/service/globalaccelerator/custom_routing_listener_test.go index 157500351cb..6fd17e8b35b 100644 --- a/internal/service/globalaccelerator/custom_routing_listener_test.go +++ b/internal/service/globalaccelerator/custom_routing_listener_test.go @@ -8,6 +8,7 @@ import ( "fmt" "testing" + "github.com/YakDriver/regexache" awstypes "github.com/aws/aws-sdk-go-v2/service/globalaccelerator/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -16,6 +17,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" tfglobalaccelerator "github.com/hashicorp/terraform-provider-aws/internal/service/globalaccelerator" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" + "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -35,6 +37,8 @@ func TestAccGlobalAcceleratorCustomRoutingListener_basic(t *testing.T) { Config: testAccCustomRoutingListenerConfig_basic(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckCustomRoutingListenerExists(ctx, resourceName, &v), + acctest.MatchResourceAttrGlobalARN(ctx, resourceName, names.AttrARN, "globalaccelerator", regexache.MustCompile(`accelerator/`+verify.UUIDRegexPattern+`/listener/[a-z0-9]{8}$`)), + resource.TestCheckResourceAttrPair(resourceName, names.AttrID, resourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "port_range.#", "2"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "port_range.*", map[string]string{ "from_port": "443", @@ -132,7 +136,7 @@ resource "aws_globalaccelerator_custom_routing_accelerator" "test" { } resource "aws_globalaccelerator_custom_routing_listener" "test" { - accelerator_arn = aws_globalaccelerator_custom_routing_accelerator.test.id + accelerator_arn = aws_globalaccelerator_custom_routing_accelerator.test.arn port_range { from_port = 443 diff --git a/internal/service/globalaccelerator/endpoint_group_test.go b/internal/service/globalaccelerator/endpoint_group_test.go index a03a938fd3f..e9f5d5d7ece 100644 --- a/internal/service/globalaccelerator/endpoint_group_test.go +++ b/internal/service/globalaccelerator/endpoint_group_test.go @@ -555,7 +555,7 @@ resource "aws_globalaccelerator_accelerator" "test" { } resource "aws_globalaccelerator_listener" "test" { - accelerator_arn = aws_globalaccelerator_accelerator.test.id + accelerator_arn = aws_globalaccelerator_accelerator.test.arn protocol = "TCP" port_range { @@ -565,7 +565,7 @@ resource "aws_globalaccelerator_listener" "test" { } resource "aws_globalaccelerator_endpoint_group" "test" { - listener_arn = aws_globalaccelerator_listener.test.id + listener_arn = aws_globalaccelerator_listener.test.arn } `, rName) } @@ -628,7 +628,7 @@ resource "aws_globalaccelerator_accelerator" "test" { } resource "aws_globalaccelerator_listener" "test" { - accelerator_arn = aws_globalaccelerator_accelerator.test.id + accelerator_arn = aws_globalaccelerator_accelerator.test.arn protocol = "TCP" port_range { @@ -638,7 +638,7 @@ resource "aws_globalaccelerator_listener" "test" { } resource "aws_globalaccelerator_endpoint_group" "test" { - listener_arn = aws_globalaccelerator_listener.test.id + listener_arn = aws_globalaccelerator_listener.test.arn endpoint_configuration { endpoint_id = aws_lb.test.id @@ -687,7 +687,7 @@ resource "aws_globalaccelerator_accelerator" "test" { } resource "aws_globalaccelerator_listener" "test" { - accelerator_arn = aws_globalaccelerator_accelerator.test.id + accelerator_arn = aws_globalaccelerator_accelerator.test.arn protocol = "TCP" port_range { @@ -697,7 +697,7 @@ resource "aws_globalaccelerator_listener" "test" { } resource "aws_globalaccelerator_endpoint_group" "test" { - listener_arn = aws_globalaccelerator_listener.test.id + listener_arn = aws_globalaccelerator_listener.test.arn endpoint_configuration { endpoint_id = aws_instance.test.id @@ -724,7 +724,7 @@ resource "aws_globalaccelerator_accelerator" "test" { } resource "aws_globalaccelerator_listener" "test" { - accelerator_arn = aws_globalaccelerator_accelerator.test.id + accelerator_arn = aws_globalaccelerator_accelerator.test.arn protocol = "TCP" port_range { @@ -744,7 +744,7 @@ resource "aws_eip" "test" { } resource "aws_globalaccelerator_endpoint_group" "test" { - listener_arn = aws_globalaccelerator_listener.test.id + listener_arn = aws_globalaccelerator_listener.test.arn endpoint_configuration { endpoint_id = aws_eip.test.id @@ -771,7 +771,7 @@ resource "aws_globalaccelerator_accelerator" "test" { } resource "aws_globalaccelerator_listener" "test" { - accelerator_arn = aws_globalaccelerator_accelerator.test.id + accelerator_arn = aws_globalaccelerator_accelerator.test.arn protocol = "TCP" port_range { @@ -781,7 +781,7 @@ resource "aws_globalaccelerator_listener" "test" { } resource "aws_globalaccelerator_endpoint_group" "test" { - listener_arn = aws_globalaccelerator_listener.test.id + listener_arn = aws_globalaccelerator_listener.test.arn health_check_port = 80 @@ -802,7 +802,7 @@ resource "aws_globalaccelerator_accelerator" "test" { } resource "aws_globalaccelerator_listener" "test" { - accelerator_arn = aws_globalaccelerator_accelerator.test.id + accelerator_arn = aws_globalaccelerator_accelerator.test.arn protocol = "TCP" port_range { @@ -812,7 +812,7 @@ resource "aws_globalaccelerator_listener" "test" { } resource "aws_globalaccelerator_endpoint_group" "test" { - listener_arn = aws_globalaccelerator_listener.test.id + listener_arn = aws_globalaccelerator_listener.test.arn port_override { endpoint_port = 8081 @@ -836,7 +836,7 @@ resource "aws_globalaccelerator_accelerator" "test" { } resource "aws_globalaccelerator_listener" "test" { - accelerator_arn = aws_globalaccelerator_accelerator.test.id + accelerator_arn = aws_globalaccelerator_accelerator.test.arn protocol = "TCP" port_range { @@ -856,7 +856,7 @@ resource "aws_eip" "test" { data "aws_region" "current" {} resource "aws_globalaccelerator_endpoint_group" "test" { - listener_arn = aws_globalaccelerator_listener.test.id + listener_arn = aws_globalaccelerator_listener.test.arn endpoint_configuration { endpoint_id = aws_eip.test.id @@ -882,7 +882,7 @@ resource "aws_globalaccelerator_accelerator" "test" { } resource "aws_globalaccelerator_listener" "test" { - accelerator_arn = aws_globalaccelerator_accelerator.test.id + accelerator_arn = aws_globalaccelerator_accelerator.test.arn protocol = "TCP" port_range { @@ -900,7 +900,7 @@ resource "aws_eip" "test" { } resource "aws_globalaccelerator_endpoint_group" "test" { - listener_arn = aws_globalaccelerator_listener.test.id + listener_arn = aws_globalaccelerator_listener.test.arn endpoint_configuration { endpoint_id = aws_eip.test.id @@ -1034,7 +1034,7 @@ resource "aws_globalaccelerator_accelerator" "test" { } resource "aws_globalaccelerator_listener" "test" { - accelerator_arn = aws_globalaccelerator_accelerator.test.id + accelerator_arn = aws_globalaccelerator_accelerator.test.arn protocol = "TCP" port_range { @@ -1044,7 +1044,7 @@ resource "aws_globalaccelerator_listener" "test" { } resource "aws_globalaccelerator_endpoint_group" "test" { - listener_arn = aws_globalaccelerator_listener.test.id + listener_arn = aws_globalaccelerator_listener.test.arn endpoint_configuration { endpoint_id = aws_lb.alt_test.arn diff --git a/internal/service/globalaccelerator/listener.go b/internal/service/globalaccelerator/listener.go index fffbcda4a05..eeee770bdbb 100644 --- a/internal/service/globalaccelerator/listener.go +++ b/internal/service/globalaccelerator/listener.go @@ -48,6 +48,10 @@ func resourceListener() *schema.Resource { Required: true, ForceNew: true, }, + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, "client_affinity": { Type: schema.TypeString, Optional: true, @@ -134,6 +138,7 @@ func resourceListenerRead(ctx context.Context, d *schema.ResourceData, meta inte } d.Set("accelerator_arn", acceleratorARN) + d.Set(names.AttrARN, listener.ListenerArn) d.Set("client_affinity", listener.ClientAffinity) if err := d.Set("port_range", flattenPortRanges(listener.PortRanges)); err != nil { return sdkdiag.AppendErrorf(diags, "setting port_range: %s", err) diff --git a/internal/service/globalaccelerator/listener_test.go b/internal/service/globalaccelerator/listener_test.go index 7628e803b7c..8cbebc2cd68 100644 --- a/internal/service/globalaccelerator/listener_test.go +++ b/internal/service/globalaccelerator/listener_test.go @@ -8,6 +8,7 @@ import ( "fmt" "testing" + "github.com/YakDriver/regexache" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -15,6 +16,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" tfglobalaccelerator "github.com/hashicorp/terraform-provider-aws/internal/service/globalaccelerator" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" + "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -33,7 +35,9 @@ func TestAccGlobalAcceleratorListener_basic(t *testing.T) { Config: testAccListenerConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckListenerExists(ctx, resourceName), + acctest.MatchResourceAttrGlobalARN(ctx, resourceName, names.AttrARN, "globalaccelerator", regexache.MustCompile(`accelerator/`+verify.UUIDRegexPattern+`/listener/[a-z0-9]{8}$`)), resource.TestCheckResourceAttr(resourceName, "client_affinity", "NONE"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrID, resourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrProtocol, "TCP"), resource.TestCheckResourceAttr(resourceName, "port_range.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "port_range.*", map[string]string{ @@ -159,7 +163,7 @@ resource "aws_globalaccelerator_accelerator" "example" { } resource "aws_globalaccelerator_listener" "example" { - accelerator_arn = aws_globalaccelerator_accelerator.example.id + accelerator_arn = aws_globalaccelerator_accelerator.example.arn protocol = "TCP" port_range { @@ -179,7 +183,7 @@ resource "aws_globalaccelerator_accelerator" "example" { } resource "aws_globalaccelerator_listener" "example" { - accelerator_arn = aws_globalaccelerator_accelerator.example.id + accelerator_arn = aws_globalaccelerator_accelerator.example.arn client_affinity = "SOURCE_IP" protocol = "UDP" diff --git a/internal/service/shield/protection_data_source_test.go b/internal/service/shield/protection_data_source_test.go index c324f80fd04..3b645c9aced 100644 --- a/internal/service/shield/protection_data_source_test.go +++ b/internal/service/shield/protection_data_source_test.go @@ -63,7 +63,7 @@ resource "aws_globalaccelerator_accelerator" "test" { resource "aws_shield_protection" "test" { name = %[1]q - resource_arn = aws_globalaccelerator_accelerator.test.id + resource_arn = aws_globalaccelerator_accelerator.test.arn } `, rName) } diff --git a/internal/service/shield/protection_test.go b/internal/service/shield/protection_test.go index 0deb65b8eda..4ce5fc5e4e6 100644 --- a/internal/service/shield/protection_test.go +++ b/internal/service/shield/protection_test.go @@ -786,7 +786,7 @@ func testAccProtectionConfig_globalAccelerator(rName string) string { return fmt.Sprintf(` resource "aws_shield_protection" "test" { name = %[1]q - resource_arn = aws_globalaccelerator_accelerator.test.id + resource_arn = aws_globalaccelerator_accelerator.test.arn } resource "aws_globalaccelerator_accelerator" "test" { diff --git a/website/docs/r/globalaccelerator_accelerator.html.markdown b/website/docs/r/globalaccelerator_accelerator.html.markdown index 5ed4ba467fd..2c07d01ed28 100644 --- a/website/docs/r/globalaccelerator_accelerator.html.markdown +++ b/website/docs/r/globalaccelerator_accelerator.html.markdown @@ -49,6 +49,7 @@ This resource supports the following arguments: This resource exports the following attributes in addition to the arguments above: * `id` - The Amazon Resource Name (ARN) of the accelerator. +* `arn` - The Amazon Resource Name (ARN) of the accelerator. * `dns_name` - The DNS name of the accelerator. For example, `a5d53ff5ee6bca4ce.awsglobalaccelerator.com`. * `dual_stack_dns_name` - The Domain Name System (DNS) name that Global Accelerator creates that points to a dual-stack accelerator's four static IP addresses: two IPv4 addresses and two IPv6 addresses. For example, `a1234567890abcdef.dualstack.awsglobalaccelerator.com`. * `hosted_zone_id` -- The Global Accelerator Route 53 zone ID that can be used to diff --git a/website/docs/r/globalaccelerator_custom_routing_accelerator.html.markdown b/website/docs/r/globalaccelerator_custom_routing_accelerator.html.markdown index f2e10c19bf3..5ab917567c6 100644 --- a/website/docs/r/globalaccelerator_custom_routing_accelerator.html.markdown +++ b/website/docs/r/globalaccelerator_custom_routing_accelerator.html.markdown @@ -49,6 +49,7 @@ This resource supports the following arguments: This resource exports the following attributes in addition to the arguments above: * `id` - The Amazon Resource Name (ARN) of the custom accelerator. +* `arn` - The Amazon Resource Name (ARN) of the custom accelerator. * `dns_name` - The DNS name of the accelerator. For example, `a5d53ff5ee6bca4ce.awsglobalaccelerator.com`. * `hosted_zone_id` -- The Global Accelerator Route 53 zone ID that can be used to route an [Alias Resource Record Set][1] to the Global Accelerator. This attribute diff --git a/website/docs/r/globalaccelerator_custom_routing_endpoint_group.html.markdown b/website/docs/r/globalaccelerator_custom_routing_endpoint_group.html.markdown index dfe4084fadf..6d7f90c6249 100644 --- a/website/docs/r/globalaccelerator_custom_routing_endpoint_group.html.markdown +++ b/website/docs/r/globalaccelerator_custom_routing_endpoint_group.html.markdown @@ -14,7 +14,7 @@ Provides a Global Accelerator custom routing endpoint group. ```terraform resource "aws_globalaccelerator_custom_routing_endpoint_group" "example" { - listener_arn = aws_globalaccelerator_custom_routing_listener.example.id + listener_arn = aws_globalaccelerator_custom_routing_listener.example.arn destination_configuration { from_port = 80 diff --git a/website/docs/r/globalaccelerator_custom_routing_listener.html.markdown b/website/docs/r/globalaccelerator_custom_routing_listener.html.markdown index 1604e43052c..25d23f5ed8d 100644 --- a/website/docs/r/globalaccelerator_custom_routing_listener.html.markdown +++ b/website/docs/r/globalaccelerator_custom_routing_listener.html.markdown @@ -26,7 +26,7 @@ resource "aws_globalaccelerator_custom_routing_accelerator" "example" { } resource "aws_globalaccelerator_custom_routing_listener" "example" { - accelerator_arn = aws_globalaccelerator_custom_routing_accelerator.example.id + accelerator_arn = aws_globalaccelerator_custom_routing_accelerator.example.arn port_range { from_port = 80 diff --git a/website/docs/r/globalaccelerator_endpoint_group.html.markdown b/website/docs/r/globalaccelerator_endpoint_group.html.markdown index 65531419843..ff1a7a0a5a3 100644 --- a/website/docs/r/globalaccelerator_endpoint_group.html.markdown +++ b/website/docs/r/globalaccelerator_endpoint_group.html.markdown @@ -14,7 +14,7 @@ Provides a Global Accelerator endpoint group. ```terraform resource "aws_globalaccelerator_endpoint_group" "example" { - listener_arn = aws_globalaccelerator_listener.example.id + listener_arn = aws_globalaccelerator_listener.example.arn endpoint_configuration { endpoint_id = aws_lb.example.arn diff --git a/website/docs/r/globalaccelerator_listener.html.markdown b/website/docs/r/globalaccelerator_listener.html.markdown index 2f352f08be5..3ff57eb34d0 100644 --- a/website/docs/r/globalaccelerator_listener.html.markdown +++ b/website/docs/r/globalaccelerator_listener.html.markdown @@ -26,7 +26,7 @@ resource "aws_globalaccelerator_accelerator" "example" { } resource "aws_globalaccelerator_listener" "example" { - accelerator_arn = aws_globalaccelerator_accelerator.example.id + accelerator_arn = aws_globalaccelerator_accelerator.example.arn client_affinity = "SOURCE_IP" protocol = "TCP" @@ -56,6 +56,7 @@ This resource supports the following arguments: This resource exports the following attributes in addition to the arguments above: * `id` - The Amazon Resource Name (ARN) of the listener. +* `arn` - The Amazon Resource Name (ARN) of the listener. ## Timeouts From 9fa883c8b19367f92aa713d7844676b8ea861fdc Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Tue, 14 Jan 2025 16:30:37 -0800 Subject: [PATCH 5/6] `iot` --- .ci/semgrep/acctest/checks/arn.yml | 1 - internal/service/iot/ca_certificate_test.go | 4 ++-- internal/service/iot/certificate_test.go | 6 +++--- internal/service/iot/domain_configuration_test.go | 8 +++++--- internal/service/iot/provisioning_template_test.go | 9 +++++---- internal/service/iot/thing_test.go | 9 +++++---- internal/service/iot/thing_type_test.go | 3 ++- 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/.ci/semgrep/acctest/checks/arn.yml b/.ci/semgrep/acctest/checks/arn.yml index b3b1bc0025c..6d7cd796051 100644 --- a/.ci/semgrep/acctest/checks/arn.yml +++ b/.ci/semgrep/acctest/checks/arn.yml @@ -5,7 +5,6 @@ rules: paths: exclude: - "internal/service/controltower" - - "internal/service/iot" - "internal/service/kafka" - "internal/service/kafkaconnect" - "internal/service/kendra" diff --git a/internal/service/iot/ca_certificate_test.go b/internal/service/iot/ca_certificate_test.go index 6ed0141b8aa..754cf300f58 100644 --- a/internal/service/iot/ca_certificate_test.go +++ b/internal/service/iot/ca_certificate_test.go @@ -35,7 +35,7 @@ func TestAccIoTCACertificate_basic(t *testing.T) { testAccCheckCACertificateExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "active", acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, "allow_auto_registration", acctest.CtTrue), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "cacert/{id}"), resource.TestCheckResourceAttrSet(resourceName, "ca_certificate_pem"), resource.TestCheckResourceAttr(resourceName, "certificate_mode", "SNI_ONLY"), resource.TestCheckResourceAttrSet(resourceName, "customer_version"), @@ -139,7 +139,7 @@ func TestAccIoTCACertificate_defaultMode(t *testing.T) { testAccCheckCACertificateExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "active", acctest.CtFalse), resource.TestCheckResourceAttr(resourceName, "allow_auto_registration", acctest.CtFalse), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "cacert/{id}"), resource.TestCheckResourceAttrSet(resourceName, "ca_certificate_pem"), resource.TestCheckResourceAttr(resourceName, "certificate_mode", "DEFAULT"), resource.TestCheckResourceAttrSet(resourceName, "customer_version"), diff --git a/internal/service/iot/certificate_test.go b/internal/service/iot/certificate_test.go index b58383bb8d9..b33dd91a343 100644 --- a/internal/service/iot/certificate_test.go +++ b/internal/service/iot/certificate_test.go @@ -32,7 +32,7 @@ func TestAccIoTCertificate_csr(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckCertificateExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "active", acctest.CtTrue), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "cert/{id}"), resource.TestCheckResourceAttrSet(resourceName, acctest.CtCertificatePEM), resource.TestCheckResourceAttrSet(resourceName, "csr"), resource.TestCheckNoResourceAttr(resourceName, names.AttrPrivateKey), @@ -58,7 +58,7 @@ func TestAccIoTCertificate_Keys_certificate(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckCertificateExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "active", acctest.CtTrue), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "cert/{id}"), resource.TestCheckResourceAttrSet(resourceName, acctest.CtCertificatePEM), resource.TestCheckNoResourceAttr(resourceName, "csr"), resource.TestCheckResourceAttrSet(resourceName, names.AttrPrivateKey), @@ -86,7 +86,7 @@ func TestAccIoTCertificate_Keys_existingCertificate(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckCertificateExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "active", acctest.CtFalse), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "cert/{id}"), resource.TestCheckResourceAttrSet(resourceName, acctest.CtCertificatePEM), resource.TestCheckNoResourceAttr(resourceName, "csr"), resource.TestCheckNoResourceAttr(resourceName, names.AttrPrivateKey), diff --git a/internal/service/iot/domain_configuration_test.go b/internal/service/iot/domain_configuration_test.go index e9ce472744d..45a2dc0533e 100644 --- a/internal/service/iot/domain_configuration_test.go +++ b/internal/service/iot/domain_configuration_test.go @@ -8,6 +8,7 @@ import ( "fmt" "testing" + "github.com/YakDriver/regexache" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -35,10 +36,11 @@ func TestAccIoTDomainConfiguration_basic(t *testing.T) { Config: testAccDomainConfigurationConfig_basic(rName, rootDomain, domain), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckDomainConfigurationExists(ctx, resourceName), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.MatchResourceAttrRegionalARN(ctx, resourceName, names.AttrARN, "iot", regexache.MustCompile(`domainconfiguration/`+rName+`/[a-z0-9]+$`)), resource.TestCheckResourceAttr(resourceName, "authorizer_config.#", "0"), resource.TestCheckResourceAttr(resourceName, names.AttrDomainName, domain), resource.TestCheckResourceAttr(resourceName, "domain_type", "CUSTOMER_MANAGED"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrID, resourceName, names.AttrName), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "server_certificate_arns.#", "1"), resource.TestCheckResourceAttr(resourceName, "service_type", "DATA"), @@ -75,7 +77,7 @@ func TestAccIoTDomainConfiguration_disappears(t *testing.T) { Config: testAccDomainConfigurationConfig_basic(rName, rootDomain, domain), Check: resource.ComposeTestCheckFunc( testAccCheckDomainConfigurationExists(ctx, resourceName), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.MatchResourceAttrRegionalARN(ctx, resourceName, names.AttrARN, "iot", regexache.MustCompile(`domainconfiguration/`+rName+`/[a-z0-9]+$`)), acctest.CheckResourceDisappears(ctx, acctest.Provider, tfiot.ResourceDomainConfiguration(), resourceName), ), ExpectNonEmptyPlan: true, @@ -190,7 +192,7 @@ func TestAccIoTDomainConfiguration_awsManaged(t *testing.T) { // nosemgrep:ci.aw Config: testAccDomainConfigurationConfig_awsManaged(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckDomainConfigurationExists(ctx, resourceName), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.MatchResourceAttrRegionalARN(ctx, resourceName, names.AttrARN, "iot", regexache.MustCompile(`domainconfiguration/`+rName+`/[a-z0-9]+$`)), resource.TestCheckResourceAttr(resourceName, "authorizer_config.#", "0"), resource.TestCheckResourceAttrSet(resourceName, names.AttrDomainName), resource.TestCheckResourceAttr(resourceName, "domain_type", "AWS_MANAGED"), diff --git a/internal/service/iot/provisioning_template_test.go b/internal/service/iot/provisioning_template_test.go index 04bec714b47..cf1d26e0cf4 100644 --- a/internal/service/iot/provisioning_template_test.go +++ b/internal/service/iot/provisioning_template_test.go @@ -36,9 +36,10 @@ func TestAccIoTProvisioningTemplate_basic(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckProvisioningTemplateExists(ctx, resourceName), testAccCheckProvisioningTemplateNumVersions(ctx, rName, 1), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "provisioningtemplate/{name}"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, acctest.CtFalse), + resource.TestCheckResourceAttrPair(resourceName, names.AttrID, resourceName, names.AttrName), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "pre_provisioning_hook.#", "0"), resource.TestCheckResourceAttrSet(resourceName, "provisioning_role_arn"), @@ -143,7 +144,7 @@ func TestAccIoTProvisioningTemplate_update(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckProvisioningTemplateExists(ctx, resourceName), testAccCheckProvisioningTemplateNumVersions(ctx, rName, 1), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "provisioningtemplate/{name}"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, acctest.CtFalse), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), @@ -163,7 +164,7 @@ func TestAccIoTProvisioningTemplate_update(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckProvisioningTemplateExists(ctx, resourceName), testAccCheckProvisioningTemplateNumVersions(ctx, rName, 2), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "provisioningtemplate/{name}"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "For testing"), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, acctest.CtTrue), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), @@ -194,7 +195,7 @@ func TestAccIoTProvisioningTemplate_jitp(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckProvisioningTemplateExists(ctx, resourceName), testAccCheckProvisioningTemplateNumVersions(ctx, rName, 1), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "provisioningtemplate/{name}"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, acctest.CtFalse), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), diff --git a/internal/service/iot/thing_test.go b/internal/service/iot/thing_test.go index 584a2b48bbc..532d73769ef 100644 --- a/internal/service/iot/thing_test.go +++ b/internal/service/iot/thing_test.go @@ -39,9 +39,10 @@ func TestAccIoTThing_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrName, thingName), resource.TestCheckResourceAttr(resourceName, "attributes.%", "0"), resource.TestCheckResourceAttr(resourceName, "thing_type_name", ""), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "thing/{name}"), resource.TestCheckResourceAttrSet(resourceName, "default_client_id"), resource.TestCheckResourceAttrSet(resourceName, names.AttrVersion), + resource.TestCheckResourceAttrPair(resourceName, names.AttrID, resourceName, names.AttrName), ), }, { @@ -77,7 +78,7 @@ func TestAccIoTThing_full(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "attributes.One", "11111"), resource.TestCheckResourceAttr(resourceName, "attributes.Two", "TwoTwo"), resource.TestCheckResourceAttr(resourceName, "attributes.Answer", "42"), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "thing/{name}"), resource.TestCheckResourceAttrSet(resourceName, "default_client_id"), resource.TestCheckResourceAttrSet(resourceName, names.AttrVersion), ), @@ -97,7 +98,7 @@ func TestAccIoTThing_full(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "attributes.One", "11111"), resource.TestCheckResourceAttr(resourceName, "attributes.Two", "TwoTwo"), resource.TestCheckResourceAttr(resourceName, "attributes.Answer", "differentOne"), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "thing/{name}"), resource.TestCheckResourceAttrSet(resourceName, "default_client_id"), resource.TestCheckResourceAttrSet(resourceName, names.AttrVersion), ), @@ -109,7 +110,7 @@ func TestAccIoTThing_full(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrName, thingName), resource.TestCheckResourceAttr(resourceName, "attributes.%", "0"), resource.TestCheckResourceAttr(resourceName, "thing_type_name", ""), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "thing/{name}"), resource.TestCheckResourceAttrSet(resourceName, "default_client_id"), resource.TestCheckResourceAttrSet(resourceName, names.AttrVersion), ), diff --git a/internal/service/iot/thing_type_test.go b/internal/service/iot/thing_type_test.go index caa84ff0a1e..913a2b1d7dd 100644 --- a/internal/service/iot/thing_type_test.go +++ b/internal/service/iot/thing_type_test.go @@ -33,8 +33,9 @@ func TestAccIoTThingType_basic(t *testing.T) { Config: testAccThingTypeConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckThingTypeExists(ctx, resourceName), - resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), + acctest.CheckResourceAttrRegionalARNFormat(ctx, resourceName, names.AttrARN, "iot", "thingtype/{name}"), resource.TestCheckResourceAttr(resourceName, "deprecated", acctest.CtFalse), + resource.TestCheckResourceAttrPair(resourceName, names.AttrID, resourceName, names.AttrName), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, "0"), ), From 7a34bb96e445954b4560f345edd7b52d81ad8e8a Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Tue, 14 Jan 2025 16:42:44 -0800 Subject: [PATCH 6/6] Updates CHANGELOG placeholder --- .changelog/{placeholder.txt => 40930.txt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .changelog/{placeholder.txt => 40930.txt} (100%) diff --git a/.changelog/placeholder.txt b/.changelog/40930.txt similarity index 100% rename from .changelog/placeholder.txt rename to .changelog/40930.txt