diff --git a/internal/acctest/acctest.go b/internal/acctest/acctest.go index a5559b583ec..fa0e5f3f824 100644 --- a/internal/acctest/acctest.go +++ b/internal/acctest/acctest.go @@ -890,7 +890,7 @@ func ThirdRegion() string { } func Partition() string { - return names.PartitionForRegion(Region()) + return names.PartitionForRegion(Region()).ID() } func PartitionRegions() []string { @@ -898,7 +898,7 @@ func PartitionRegions() []string { } func PartitionDNSSuffix() string { - return names.DNSSuffixForPartition(Partition()) + return names.PartitionForRegion(Region()).DNSSuffix() } func PartitionReverseDNSPrefix() string { @@ -906,11 +906,11 @@ func PartitionReverseDNSPrefix() string { } func alternateRegionPartition() string { - return names.PartitionForRegion(AlternateRegion()) + return names.PartitionForRegion(AlternateRegion()).ID() } func thirdRegionPartition() string { - return names.PartitionForRegion(ThirdRegion()) + return names.PartitionForRegion(ThirdRegion()).ID() } func PreCheckAlternateAccount(t *testing.T) { @@ -959,7 +959,7 @@ func PreCheckMultipleRegion(t *testing.T, regions int) { } if regions >= 3 { - if thirdRegionPartition() == names.USGovCloudPartitionID || Partition() == names.USGovCloudPartitionID { + if thirdRegionPartition() == endpoints.AwsUsGovPartitionID || Partition() == endpoints.AwsUsGovPartitionID { t.Skipf("wanted %d regions, partition (%s) only has 2 regions", regions, Partition()) } @@ -1340,9 +1340,9 @@ func PreCheckWAFV2CloudFrontScope(ctx context.Context, t *testing.T) { t.Helper() switch Partition() { - case names.StandardPartitionID: + case endpoints.AwsPartitionID: PreCheckRegion(t, names.USEast1RegionID) - case names.ChinaPartitionID: + case endpoints.AwsCnPartitionID: PreCheckRegion(t, names.CNNorthwest1RegionID) } @@ -2202,7 +2202,7 @@ func CheckACMPCACertificateAuthorityExists(ctx context.Context, n string, certif func PreCheckAPIGatewayTypeEDGE(t *testing.T) { t.Helper() - if Partition() != names.StandardPartitionID { + if Partition() != endpoints.AwsPartitionID { t.Skipf("skipping test; Endpoint Configuration type EDGE is not supported in this partition (%s)", Partition()) } } diff --git a/internal/acctest/partition.go b/internal/acctest/partition.go index e3c06456a40..886226d4183 100644 --- a/internal/acctest/partition.go +++ b/internal/acctest/partition.go @@ -12,7 +12,7 @@ import ( func IsIsolatedRegion(region string) bool { partition := names.PartitionForRegion(region) - return IsIsolatedPartition(partition) + return IsIsolatedPartition(partition.ID()) } func IsIsolatedPartition(partition string) bool { @@ -26,11 +26,11 @@ func IsIsolatedPartition(partition string) bool { func IsStandardRegion(region string) bool { partition := names.PartitionForRegion(region) - return IsStandardPartition(partition) + return IsStandardPartition(partition.ID()) } -func IsStandardPartition(partitionId string) bool { - return partitionId == names.StandardPartitionID +func IsStandardPartition(partitionID string) bool { + return partitionID == endpoints.AwsPartitionID } func RegionsInPartition(partitionName string) []string { diff --git a/internal/acctest/partition_test.go b/internal/acctest/partition_test.go index aeaf71f4f0b..e9eb57ee1e1 100644 --- a/internal/acctest/partition_test.go +++ b/internal/acctest/partition_test.go @@ -6,6 +6,7 @@ package acctest_test import ( "testing" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -18,31 +19,31 @@ func TestIsIsolatedPartition(t *testing.T) { expected bool }{ { - input: names.StandardPartitionID, + input: endpoints.AwsPartitionID, expected: false, }, { - input: names.ChinaPartitionID, + input: endpoints.AwsCnPartitionID, expected: false, }, { - input: names.USGovCloudPartitionID, + input: endpoints.AwsUsGovPartitionID, expected: false, }, { - input: names.ISOPartitionID, + input: endpoints.AwsIsoPartitionID, expected: true, }, { - input: names.ISOBPartitionID, + input: endpoints.AwsIsoBPartitionID, expected: true, }, { - input: names.ISOEPartitionID, + input: endpoints.AwsIsoEPartitionID, expected: true, }, { - input: names.ISOFPartitionID, + input: endpoints.AwsIsoFPartitionID, expected: true, }, } @@ -110,31 +111,31 @@ func TestIsStandardPartition(t *testing.T) { expected bool }{ { - input: names.StandardPartitionID, + input: endpoints.AwsPartitionID, expected: true, }, { - input: names.ChinaPartitionID, + input: endpoints.AwsCnPartitionID, expected: false, }, { - input: names.USGovCloudPartitionID, + input: endpoints.AwsUsGovPartitionID, expected: false, }, { - input: names.ISOPartitionID, + input: endpoints.AwsIsoPartitionID, expected: false, }, { - input: names.ISOBPartitionID, + input: endpoints.AwsIsoBPartitionID, expected: false, }, { - input: names.ISOEPartitionID, + input: endpoints.AwsIsoEPartitionID, expected: false, }, { - input: names.ISOFPartitionID, + input: endpoints.AwsIsoFPartitionID, expected: false, }, } diff --git a/internal/conns/awsclient.go b/internal/conns/awsclient.go index 9425b4a16de..8f0be787649 100644 --- a/internal/conns/awsclient.go +++ b/internal/conns/awsclient.go @@ -13,6 +13,7 @@ import ( "sync" "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/arn" apigatewayv2_types "github.com/aws/aws-sdk-go-v2/service/apigatewayv2/types" "github.com/aws/aws-sdk-go-v2/service/s3" session_sdkv1 "github.com/aws/aws-sdk-go/aws/session" @@ -28,18 +29,17 @@ type AWSClient struct { AccountID string defaultTagsConfig *tftags.DefaultConfig ignoreTagsConfig *tftags.IgnoreConfig - Partition string Region string ServicePackages map[string]ServicePackage awsConfig *aws.Config clients map[string]any conns map[string]any - dnsSuffix string endpoints map[string]string // From provider configuration. httpClient *http.Client lock sync.Mutex logger baselogging.Logger + partition endpoints.Partition session *session_sdkv1.Session s3ExpressClient *s3.Client s3UsePathStyle bool // From provider configuration. @@ -76,6 +76,11 @@ func (c *AWSClient) Endpoints(context.Context) map[string]string { return maps.Clone(c.endpoints) } +// Partition returns the ID of the configured AWS partition. +func (c *AWSClient) Partition(context.Context) string { + return c.partition.ID() +} + // PartitionHostname returns a hostname with the provider domain suffix for the partition // e.g. PREFIX.amazonaws.com // The prefix should not contain a trailing period. @@ -83,6 +88,27 @@ func (c *AWSClient) PartitionHostname(ctx context.Context, prefix string) string return fmt.Sprintf("%s.%s", prefix, c.DNSSuffix(ctx)) } +// RegionalARN returns a regional ARN for the specified service namespace and resource. +func (c *AWSClient) RegionalARN(ctx context.Context, service, resource string) string { + return arn.ARN{ + Partition: c.Partition(ctx), + Service: service, + Region: c.Region, + AccountID: c.AccountID, + Resource: resource, + }.String() +} + +// RegionalARNNoAccount returns a regional ARN for the specified service namespace and resource without AWS account ID. +func (c *AWSClient) RegionalARNNoAccount(ctx context.Context, service, resource string) string { + return arn.ARN{ + Partition: c.Partition(ctx), + Service: service, + Region: c.Region, + Resource: resource, + }.String() +} + // RegionalHostname returns a hostname with the provider domain suffix for the region and partition // e.g. PREFIX.us-west-2.amazonaws.com // The prefix should not contain a trailing period. @@ -158,15 +184,15 @@ func (c *AWSClient) APIGatewayV2InvokeURL(ctx context.Context, protocolType apig // CloudFrontDistributionHostedZoneID returns the Route 53 hosted zone ID // for Amazon CloudFront distributions in the configured AWS partition. -func (c *AWSClient) CloudFrontDistributionHostedZoneID(context.Context) string { - if c.Partition == endpoints.AwsCnPartitionID { +func (c *AWSClient) CloudFrontDistributionHostedZoneID(ctx context.Context) string { + if c.Partition(ctx) == endpoints.AwsCnPartitionID { return "Z3RFFRIM2A3IF5" // See https://docs.amazonaws.cn/en_us/aws/latest/userguide/route53.html } return "Z2FDTNDATAQYW2" // See https://docs.aws.amazon.com/Route53/latest/APIReference/API_AliasTarget.html#Route53-Type-AliasTarget-HostedZoneId } // DefaultKMSKeyPolicy returns the default policy for KMS keys in the configured AWS partition. -func (c *AWSClient) DefaultKMSKeyPolicy(context.Context) string { +func (c *AWSClient) DefaultKMSKeyPolicy(ctx context.Context) string { return fmt.Sprintf(` { "Id": "default", @@ -183,7 +209,7 @@ func (c *AWSClient) DefaultKMSKeyPolicy(context.Context) string { } ] } -`, c.Partition, c.AccountID) +`, c.Partition(ctx), c.AccountID) } // GlobalAcceleratorHostedZoneID returns the Route 53 hosted zone ID @@ -194,7 +220,12 @@ func (c *AWSClient) GlobalAcceleratorHostedZoneID(context.Context) string { // DNSSuffix returns the domain suffix for the configured AWS partition. func (c *AWSClient) DNSSuffix(context.Context) string { - return c.dnsSuffix + dnsSuffix := c.partition.DNSSuffix() + if dnsSuffix == "" { + dnsSuffix = "amazonaws.com" + } + + return dnsSuffix } // ReverseDNSPrefix returns the reverse DNS prefix for the configured AWS partition. @@ -248,11 +279,11 @@ func convertIPToDashIP(ip string) string { } // apiClientConfig returns the AWS API client configuration parameters for the specified service. -func (c *AWSClient) apiClientConfig(_ context.Context, servicePackageName string) map[string]any { +func (c *AWSClient) apiClientConfig(ctx context.Context, servicePackageName string) map[string]any { m := map[string]any{ "aws_sdkv2_config": c.awsConfig, "endpoint": c.endpoints[servicePackageName], - "partition": c.Partition, + "partition": c.Partition(ctx), } switch servicePackageName { case names.S3: diff --git a/internal/conns/awsclient_test.go b/internal/conns/awsclient_test.go index eaa2d52cce8..ed6bfe7a968 100644 --- a/internal/conns/awsclient_test.go +++ b/internal/conns/awsclient_test.go @@ -6,6 +6,13 @@ package conns import ( "context" "testing" + + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" +) + +var ( + standardPartition, _ = endpoints.PartitionForRegion(endpoints.DefaultPartitions(), endpoints.UsEast1RegionID) + chinaPartition, _ = endpoints.PartitionForRegion(endpoints.DefaultPartitions(), endpoints.CnNorth1RegionID) ) func TestAWSClientPartitionHostname(t *testing.T) { // nosemgrep:ci.aws-in-func-name @@ -21,7 +28,7 @@ func TestAWSClientPartitionHostname(t *testing.T) { // nosemgrep:ci.aws-in-func- { Name: "AWS Commercial", AWSClient: &AWSClient{ - dnsSuffix: "amazonaws.com", + partition: standardPartition, }, Prefix: "test", Expected: "test.amazonaws.com", @@ -29,7 +36,7 @@ func TestAWSClientPartitionHostname(t *testing.T) { // nosemgrep:ci.aws-in-func- { Name: "AWS China", AWSClient: &AWSClient{ - dnsSuffix: "amazonaws.com.cn", + partition: chinaPartition, }, Prefix: "test", Expected: "test.amazonaws.com.cn", @@ -62,7 +69,7 @@ func TestAWSClientRegionalHostname(t *testing.T) { // nosemgrep:ci.aws-in-func-n { Name: "AWS Commercial", AWSClient: &AWSClient{ - dnsSuffix: "amazonaws.com", + partition: standardPartition, Region: "us-west-2", //lintignore:AWSAT003 }, Prefix: "test", @@ -71,7 +78,7 @@ func TestAWSClientRegionalHostname(t *testing.T) { // nosemgrep:ci.aws-in-func-n { Name: "AWS China", AWSClient: &AWSClient{ - dnsSuffix: "amazonaws.com.cn", + partition: chinaPartition, Region: "cn-northwest-1", //lintignore:AWSAT003 }, Prefix: "test", @@ -105,7 +112,7 @@ func TestAWSClientEC2PrivateDNSNameForIP(t *testing.T) { // nosemgrep:ci.aws-in- { Name: "us-west-2", AWSClient: &AWSClient{ - dnsSuffix: "amazonaws.com", + partition: standardPartition, Region: "us-west-2", //lintignore:AWSAT003 }, IP: "10.20.30.40", @@ -114,7 +121,7 @@ func TestAWSClientEC2PrivateDNSNameForIP(t *testing.T) { // nosemgrep:ci.aws-in- { Name: "us-east-1", AWSClient: &AWSClient{ - dnsSuffix: "amazonaws.com", + partition: standardPartition, Region: "us-east-1", //lintignore:AWSAT003 }, IP: "10.20.30.40", @@ -148,7 +155,7 @@ func TestAWSClientEC2PublicDNSNameForIP(t *testing.T) { // nosemgrep:ci.aws-in-f { Name: "us-west-2", AWSClient: &AWSClient{ - dnsSuffix: "amazonaws.com", + partition: standardPartition, Region: "us-west-2", //lintignore:AWSAT003 }, IP: "10.20.30.40", @@ -157,7 +164,7 @@ func TestAWSClientEC2PublicDNSNameForIP(t *testing.T) { // nosemgrep:ci.aws-in-f { Name: "us-east-1", AWSClient: &AWSClient{ - dnsSuffix: "amazonaws.com", + partition: standardPartition, Region: "us-east-1", //lintignore:AWSAT003 }, IP: "10.20.30.40", diff --git a/internal/conns/config.go b/internal/conns/config.go index 3c1521b6f42..7f7a5afc0ef 100644 --- a/internal/conns/config.go +++ b/internal/conns/config.go @@ -181,7 +181,7 @@ func (c *Config) ConfigureProvider(ctx context.Context, client *AWSClient) (*AWS } tflog.Debug(ctx, "Retrieving AWS account details") - accountID, partition, awsDiags := awsbase.GetAwsAccountIDAndPartition(ctx, cfg, &awsbaseConfig) + accountID, partitionID, awsDiags := awsbase.GetAwsAccountIDAndPartition(ctx, cfg, &awsbaseConfig) for _, d := range awsDiags { diags = append(diags, diag.Diagnostic{ Severity: baseSeverityToSDKSeverity(d.Severity()), @@ -201,16 +201,15 @@ func (c *Config) ConfigureProvider(ctx context.Context, client *AWSClient) (*AWS return nil, sdkdiag.AppendErrorf(diags, "%s", err.Error()) } - dnsSuffix := "amazonaws.com" - if p, ok := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), c.Region); ok { - dnsSuffix = p.DNSSuffix() + for _, partition := range endpoints.DefaultPartitions() { + if partition.ID() == partitionID { + client.partition = partition + } } client.AccountID = accountID client.defaultTagsConfig = c.DefaultTagsConfig - client.dnsSuffix = dnsSuffix client.ignoreTagsConfig = c.IgnoreTagsConfig - client.Partition = partition client.Region = c.Region client.SetHTTPClient(ctx, session.Config.HTTPClient) // Must be called while client.Session is nil. client.session = session diff --git a/internal/errs/unsupported.go b/internal/errs/unsupported.go index 3c745eee658..e4a456c43a1 100644 --- a/internal/errs/unsupported.go +++ b/internal/errs/unsupported.go @@ -4,8 +4,8 @@ package errs import ( + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" - "github.com/hashicorp/terraform-provider-aws/names" ) const ( @@ -33,7 +33,7 @@ const ( // Be careful with a return value of `false`, which means either there is NO error // or there is an error but not one that suggests an unsupported feature in ISO. func IsUnsupportedOperationInPartitionError(partition string, err error) bool { - if partition == names.StandardPartitionID { + if partition == endpoints.AwsPartitionID { return false } diff --git a/internal/framework/with_meta.go b/internal/framework/with_meta.go index 95ae2dcbc6b..5c1a435b41b 100644 --- a/internal/framework/with_meta.go +++ b/internal/framework/with_meta.go @@ -4,7 +4,6 @@ package framework import ( - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/hashicorp/terraform-provider-aws/internal/conns" ) @@ -24,14 +23,3 @@ type withMeta struct { func (w *withMeta) Meta() *conns.AWSClient { return w.meta } - -// RegionalARN returns a regional ARN for the specified service namespace and resource. -func (w *withMeta) RegionalARN(service, resource string) string { - return arn.ARN{ - Partition: w.meta.Partition, - Service: service, - Region: w.meta.Region, - AccountID: w.meta.AccountID, - Resource: resource, - }.String() -} diff --git a/internal/provider/fwprovider/intercept.go b/internal/provider/fwprovider/intercept.go index 76c9b2d1c80..b032b1620dd 100644 --- a/internal/provider/fwprovider/intercept.go +++ b/internal/provider/fwprovider/intercept.go @@ -323,7 +323,7 @@ func (r tagsDataSourceInterceptor) read(ctx context.Context, request datasource. } // ISO partitions may not support tagging, giving error. - if errs.IsUnsupportedOperationInPartitionError(meta.Partition, err) { + if errs.IsUnsupportedOperationInPartitionError(meta.Partition(ctx), err) { return ctx, diags } @@ -609,7 +609,7 @@ func (r tagsResourceInterceptor) read(ctx context.Context, request resource.Read } // ISO partitions may not support tagging, giving error. - if errs.IsUnsupportedOperationInPartitionError(meta.Partition, err) { + if errs.IsUnsupportedOperationInPartitionError(meta.Partition(ctx), err) { return ctx, diags } @@ -738,7 +738,7 @@ func (r tagsResourceInterceptor) update(ctx context.Context, request resource.Up } // ISO partitions may not support tagging, giving error. - if errs.IsUnsupportedOperationInPartitionError(meta.Partition, err) { + if errs.IsUnsupportedOperationInPartitionError(meta.Partition(ctx), err) { return ctx, diags } diff --git a/internal/provider/intercept.go b/internal/provider/intercept.go index 83a424fcb75..6afcb82053e 100644 --- a/internal/provider/intercept.go +++ b/internal/provider/intercept.go @@ -279,7 +279,7 @@ func (r tagsResourceInterceptor) run(ctx context.Context, d schemaResourceData, } // ISO partitions may not support tagging, giving error. - if errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return ctx, diags } @@ -338,7 +338,7 @@ func (r tagsResourceInterceptor) run(ctx context.Context, d schemaResourceData, } // ISO partitions may not support tagging, giving error. - if errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return ctx, diags } @@ -467,7 +467,7 @@ func (r tagsDataSourceInterceptor) run(ctx context.Context, d schemaResourceData } // ISO partitions may not support tagging, giving error. - if errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return ctx, diags } diff --git a/internal/provider/provider_acc_test.go b/internal/provider/provider_acc_test.go index 333b8519ae4..6648afe21f2 100644 --- a/internal/provider/provider_acc_test.go +++ b/internal/provider/provider_acc_test.go @@ -15,6 +15,7 @@ import ( awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" "github.com/aws/aws-sdk-go-v2/service/sts" "github.com/aws/smithy-go/middleware" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-go/tfprotov5" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" @@ -520,7 +521,7 @@ func TestAccProvider_Region_c2s(t *testing.T) { Config: testAccProviderConfig_region(names.USISOEast1RegionID), Check: resource.ComposeTestCheckFunc( testAccCheckDNSSuffix(ctx, t, &provider, "c2s.ic.gov"), - testAccCheckPartition(ctx, t, &provider, names.ISOPartitionID), + testAccCheckPartition(ctx, t, &provider, endpoints.AwsIsoPartitionID), testAccCheckReverseDNSPrefix(ctx, t, &provider, "gov.ic.c2s"), ), PlanOnly: true, @@ -543,7 +544,7 @@ func TestAccProvider_Region_china(t *testing.T) { Config: testAccProviderConfig_region(names.CNNorthwest1RegionID), Check: resource.ComposeTestCheckFunc( testAccCheckDNSSuffix(ctx, t, &provider, "amazonaws.com.cn"), - testAccCheckPartition(ctx, t, &provider, names.ChinaPartitionID), + testAccCheckPartition(ctx, t, &provider, endpoints.AwsCnPartitionID), testAccCheckReverseDNSPrefix(ctx, t, &provider, "cn.com.amazonaws"), ), PlanOnly: true, @@ -566,7 +567,7 @@ func TestAccProvider_Region_commercial(t *testing.T) { Config: testAccProviderConfig_region(names.USWest2RegionID), Check: resource.ComposeTestCheckFunc( testAccCheckDNSSuffix(ctx, t, &provider, "amazonaws.com"), - testAccCheckPartition(ctx, t, &provider, names.StandardPartitionID), + testAccCheckPartition(ctx, t, &provider, endpoints.AwsPartitionID), testAccCheckReverseDNSPrefix(ctx, t, &provider, "com.amazonaws"), ), PlanOnly: true, @@ -589,7 +590,7 @@ func TestAccProvider_Region_govCloud(t *testing.T) { Config: testAccProviderConfig_region(names.USGovWest1RegionID), Check: resource.ComposeTestCheckFunc( testAccCheckDNSSuffix(ctx, t, &provider, "amazonaws.com"), - testAccCheckPartition(ctx, t, &provider, names.USGovCloudPartitionID), + testAccCheckPartition(ctx, t, &provider, endpoints.AwsUsGovPartitionID), testAccCheckReverseDNSPrefix(ctx, t, &provider, "com.amazonaws"), ), PlanOnly: true, @@ -612,7 +613,7 @@ func TestAccProvider_Region_sc2s(t *testing.T) { Config: testAccProviderConfig_region(names.USISOBEast1RegionID), Check: resource.ComposeTestCheckFunc( testAccCheckDNSSuffix(ctx, t, &provider, "sc2s.sgov.gov"), - testAccCheckPartition(ctx, t, &provider, names.ISOBPartitionID), + testAccCheckPartition(ctx, t, &provider, endpoints.AwsIsoBPartitionID), testAccCheckReverseDNSPrefix(ctx, t, &provider, "gov.sgov.sc2s"), ), PlanOnly: true, @@ -685,7 +686,7 @@ func testAccCheckPartition(ctx context.Context, t *testing.T, p **schema.Provide return fmt.Errorf("provider not initialized") } - providerPartition := (*p).Meta().(*conns.AWSClient).Partition + providerPartition := (*p).Meta().(*conns.AWSClient).Partition(ctx) if providerPartition != expectedPartition { return fmt.Errorf("expected DNS Suffix (%s), got: %s", expectedPartition, providerPartition) diff --git a/internal/provider/tags_interceptor.go b/internal/provider/tags_interceptor.go index d8f55af0485..9ca76495855 100644 --- a/internal/provider/tags_interceptor.go +++ b/internal/provider/tags_interceptor.go @@ -88,7 +88,7 @@ func tagsUpdateFunc(ctx context.Context, d schemaResourceData, sp conns.ServiceP } // ISO partitions may not support tagging, giving error. - if errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return ctx, diags } @@ -139,7 +139,7 @@ func tagsReadFunc(ctx context.Context, d schemaResourceData, sp conns.ServicePac } // ISO partitions may not support tagging, giving error. - if errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return ctx, diags } diff --git a/internal/service/amplify/app_test.go b/internal/service/amplify/app_test.go index 1a8605e4260..7b6b5600d8e 100644 --- a/internal/service/amplify/app_test.go +++ b/internal/service/amplify/app_test.go @@ -13,6 +13,7 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/amplify/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -640,7 +641,7 @@ func testAccCheckAppDestroy(ctx context.Context) resource.TestCheckFunc { } func testAccPreCheck(t *testing.T) { - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) } func testAccCheckAppNotRecreated(before, after *types.App) resource.TestCheckFunc { diff --git a/internal/service/apigateway/api_key.go b/internal/service/apigateway/api_key.go index d878a367ea7..1bc1374a310 100644 --- a/internal/service/apigateway/api_key.go +++ b/internal/service/apigateway/api_key.go @@ -10,7 +10,6 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/apigateway" "github.com/aws/aws-sdk-go-v2/service/apigateway/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -133,7 +132,7 @@ func resourceAPIKeyRead(ctx context.Context, d *schema.ResourceData, meta interf setTagsOut(ctx, apiKey.Tags) - d.Set(names.AttrARN, apiKeyARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, apiKeyARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set(names.AttrCreatedDate, apiKey.CreatedDate.Format(time.RFC3339)) d.Set("customer_id", apiKey.CustomerId) d.Set(names.AttrDescription, apiKey.Description) @@ -251,11 +250,6 @@ func findAPIKeyByID(ctx context.Context, conn *apigateway.Client, id string) (*a return output, nil } -func apiKeyARN(c *conns.AWSClient, id string) string { - return arn.ARN{ - Partition: c.Partition, - Service: "apigateway", - Region: c.Region, - Resource: fmt.Sprintf("/apikeys/%s", id), - }.String() +func apiKeyARN(ctx context.Context, c *conns.AWSClient, id string) string { + return c.RegionalARNNoAccount(ctx, "apigateway", fmt.Sprintf("/apikeys/%s", id)) } diff --git a/internal/service/apigateway/api_key_data_source.go b/internal/service/apigateway/api_key_data_source.go index f90c461cc23..bc1090b60c2 100644 --- a/internal/service/apigateway/api_key_data_source.go +++ b/internal/service/apigateway/api_key_data_source.go @@ -78,7 +78,7 @@ func dataSourceAPIKeyRead(ctx context.Context, d *schema.ResourceData, meta inte } d.SetId(aws.ToString(apiKey.Id)) - d.Set(names.AttrARN, apiKeyARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, apiKeyARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set(names.AttrCreatedDate, aws.ToTime(apiKey.CreatedDate).Format(time.RFC3339)) d.Set("customer_id", apiKey.CustomerId) d.Set(names.AttrDescription, apiKey.Description) diff --git a/internal/service/apigateway/authorizer.go b/internal/service/apigateway/authorizer.go index 1b00166524b..1341aa6670b 100644 --- a/internal/service/apigateway/authorizer.go +++ b/internal/service/apigateway/authorizer.go @@ -10,7 +10,6 @@ import ( "strings" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/apigateway" "github.com/aws/aws-sdk-go-v2/service/apigateway/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -193,7 +192,7 @@ func resourceAuthorizerRead(ctx context.Context, d *schema.ResourceData, meta in return sdkdiag.AppendErrorf(diags, "reading API Gateway Authorizer (%s): %s", d.Id(), err) } - d.Set(names.AttrARN, authorizerARN(meta.(*conns.AWSClient), apiID, d.Id())) + d.Set(names.AttrARN, authorizerARN(ctx, meta.(*conns.AWSClient), apiID, d.Id())) d.Set("authorizer_credentials", authorizer.AuthorizerCredentials) if authorizer.AuthorizerResultTtlInSeconds != nil { // nosemgrep:ci.helper-schema-ResourceData-Set-extraneous-nil-check d.Set("authorizer_result_ttl_in_seconds", authorizer.AuthorizerResultTtlInSeconds) @@ -379,11 +378,6 @@ func findAuthorizerByTwoPartKey(ctx context.Context, conn *apigateway.Client, au return output, nil } -func authorizerARN(c *conns.AWSClient, apiID, authorizerID string) string { - return arn.ARN{ - Partition: c.Partition, - Service: "apigateway", - Region: c.Region, - Resource: fmt.Sprintf("/restapis/%s/authorizers/%s", apiID, authorizerID), - }.String() +func authorizerARN(ctx context.Context, c *conns.AWSClient, apiID, authorizerID string) string { + return c.RegionalARNNoAccount(ctx, "apigateway", fmt.Sprintf("/restapis/%s/authorizers/%s", apiID, authorizerID)) } diff --git a/internal/service/apigateway/authorizer_data_source.go b/internal/service/apigateway/authorizer_data_source.go index 935ca0bedb8..8614075c6c7 100644 --- a/internal/service/apigateway/authorizer_data_source.go +++ b/internal/service/apigateway/authorizer_data_source.go @@ -81,7 +81,7 @@ func dataSourceAuthorizerRead(ctx context.Context, d *schema.ResourceData, meta } d.SetId(authorizerID) - d.Set(names.AttrARN, authorizerARN(meta.(*conns.AWSClient), apiID, d.Id())) + d.Set(names.AttrARN, authorizerARN(ctx, meta.(*conns.AWSClient), apiID, d.Id())) d.Set("authorizer_credentials", authorizer.AuthorizerCredentials) if authorizer.AuthorizerResultTtlInSeconds != nil { // nosemgrep:ci.helper-schema-ResourceData-Set-extraneous-nil-check d.Set("authorizer_result_ttl_in_seconds", authorizer.AuthorizerResultTtlInSeconds) diff --git a/internal/service/apigateway/client_certificate.go b/internal/service/apigateway/client_certificate.go index 21d63586c26..0fb8cd2b7c6 100644 --- a/internal/service/apigateway/client_certificate.go +++ b/internal/service/apigateway/client_certificate.go @@ -107,7 +107,7 @@ func resourceClientCertificateRead(ctx context.Context, d *schema.ResourceData, } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "apigateway", Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("/clientcertificates/%s", d.Id()), diff --git a/internal/service/apigateway/deployment.go b/internal/service/apigateway/deployment.go index f3cb71b9a0b..ea810b29bfb 100644 --- a/internal/service/apigateway/deployment.go +++ b/internal/service/apigateway/deployment.go @@ -155,7 +155,7 @@ func resourceDeploymentRead(ctx context.Context, d *schema.ResourceData, meta in d.Set(names.AttrCreatedDate, deployment.CreatedDate.Format(time.RFC3339)) d.Set(names.AttrDescription, deployment.Description) executionARN := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "execute-api", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/apigateway/domain_name.go b/internal/service/apigateway/domain_name.go index 04b07987aac..de5abb04b9f 100644 --- a/internal/service/apigateway/domain_name.go +++ b/internal/service/apigateway/domain_name.go @@ -11,7 +11,6 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/apigateway" "github.com/aws/aws-sdk-go-v2/service/apigateway/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -253,7 +252,7 @@ func resourceDomainNameRead(ctx context.Context, d *schema.ResourceData, meta in return sdkdiag.AppendErrorf(diags, "reading API Gateway Domain Name (%s): %s", d.Id(), err) } - d.Set(names.AttrARN, domainNameARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, domainNameARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set(names.AttrCertificateARN, domainName.CertificateArn) d.Set("certificate_name", domainName.CertificateName) if domainName.CertificateUploadDate != nil { @@ -519,11 +518,6 @@ func flattenMutualTLSAuthentication(apiObject *types.MutualTlsAuthentication) [] return []interface{}{tfMap} } -func domainNameARN(c *conns.AWSClient, domainName string) string { - return arn.ARN{ - Partition: c.Partition, - Service: "apigateway", - Region: c.Region, - Resource: fmt.Sprintf("/domainnames/%s", domainName), - }.String() +func domainNameARN(ctx context.Context, c *conns.AWSClient, domainName string) string { + return c.RegionalARNNoAccount(ctx, "apigateway", fmt.Sprintf("/domainnames/%s", domainName)) } diff --git a/internal/service/apigateway/domain_name_data_source.go b/internal/service/apigateway/domain_name_data_source.go index e890403eaca..2bcc319df01 100644 --- a/internal/service/apigateway/domain_name_data_source.go +++ b/internal/service/apigateway/domain_name_data_source.go @@ -104,7 +104,7 @@ func dataSourceDomainNameRead(ctx context.Context, d *schema.ResourceData, meta } d.SetId(aws.ToString(output.DomainName)) - d.Set(names.AttrARN, domainNameARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, domainNameARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set(names.AttrCertificateARN, output.CertificateArn) d.Set("certificate_name", output.CertificateName) if output.CertificateUploadDate != nil { diff --git a/internal/service/apigateway/rest_api.go b/internal/service/apigateway/rest_api.go index 02e08fccd1e..c9b6ed9e3cb 100644 --- a/internal/service/apigateway/rest_api.go +++ b/internal/service/apigateway/rest_api.go @@ -12,7 +12,6 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/apigateway" "github.com/aws/aws-sdk-go-v2/service/apigateway/types" awspolicy "github.com/hashicorp/awspolicyequivalence" @@ -296,7 +295,7 @@ func resourceRestAPIRead(ctx context.Context, d *schema.ResourceData, meta inter } d.Set("api_key_source", api.ApiKeySource) - d.Set(names.AttrARN, apiARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, apiARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set("binary_media_types", api.BinaryMediaTypes) d.Set(names.AttrCreatedDate, api.CreatedDate.Format(time.RFC3339)) d.Set(names.AttrDescription, api.Description) @@ -304,7 +303,7 @@ func resourceRestAPIRead(ctx context.Context, d *schema.ResourceData, meta inter if err := d.Set("endpoint_configuration", flattenEndpointConfiguration(api.EndpointConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting endpoint_configuration: %s", err) } - d.Set("execution_arn", apiInvokeARN(meta.(*conns.AWSClient), d.Id())) + d.Set("execution_arn", apiInvokeARN(ctx, meta.(*conns.AWSClient), d.Id())) if api.MinimumCompressionSize == nil { d.Set("minimum_compression_size", nil) } else { @@ -781,21 +780,10 @@ func flattenAPIPolicy(apiObject *string) (string, error) { return policy, nil } -func apiARN(c *conns.AWSClient, apiID string) string { - return arn.ARN{ - Partition: c.Partition, - Service: "apigateway", - Region: c.Region, - Resource: fmt.Sprintf("/restapis/%s", apiID), - }.String() +func apiARN(ctx context.Context, c *conns.AWSClient, apiID string) string { + return c.RegionalARNNoAccount(ctx, "apigateway", fmt.Sprintf("/restapis/%s", apiID)) } -func apiInvokeARN(c *conns.AWSClient, apiID string) string { - return arn.ARN{ - Partition: c.Partition, - Service: "execute-api", - Region: c.Region, - AccountID: c.AccountID, - Resource: apiID, - }.String() +func apiInvokeARN(ctx context.Context, c *conns.AWSClient, apiID string) string { + return c.RegionalARN(ctx, "execute-api", apiID) } diff --git a/internal/service/apigateway/rest_api_data_source.go b/internal/service/apigateway/rest_api_data_source.go index 107561a7f59..e2856005e6d 100644 --- a/internal/service/apigateway/rest_api_data_source.go +++ b/internal/service/apigateway/rest_api_data_source.go @@ -106,13 +106,13 @@ func dataSourceRestAPIRead(ctx context.Context, d *schema.ResourceData, meta int d.SetId(aws.ToString(match.Id)) d.Set("api_key_source", match.ApiKeySource) - d.Set(names.AttrARN, apiARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, apiARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set("binary_media_types", match.BinaryMediaTypes) d.Set(names.AttrDescription, match.Description) if err := d.Set("endpoint_configuration", flattenEndpointConfiguration(match.EndpointConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting endpoint_configuration: %s", err) } - d.Set("execution_arn", apiInvokeARN(meta.(*conns.AWSClient), d.Id())) + d.Set("execution_arn", apiInvokeARN(ctx, meta.(*conns.AWSClient), d.Id())) if match.MinimumCompressionSize == nil { d.Set("minimum_compression_size", nil) } else { diff --git a/internal/service/apigateway/stage.go b/internal/service/apigateway/stage.go index 4b56bba1242..07d1304a4df 100644 --- a/internal/service/apigateway/stage.go +++ b/internal/service/apigateway/stage.go @@ -11,7 +11,6 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/apigateway" "github.com/aws/aws-sdk-go-v2/service/apigateway/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -254,7 +253,7 @@ func resourceStageRead(ctx context.Context, d *schema.ResourceData, meta interfa if err := d.Set("access_log_settings", flattenAccessLogSettings(stage.AccessLogSettings)); err != nil { return sdkdiag.AppendErrorf(diags, "setting access_log_settings: %s", err) } - d.Set(names.AttrARN, stageARN(meta.(*conns.AWSClient), apiID, stageName)) + d.Set(names.AttrARN, stageARN(ctx, meta.(*conns.AWSClient), apiID, stageName)) if stage.CacheClusterStatus == types.CacheClusterStatusDeleteInProgress { d.Set("cache_cluster_enabled", false) d.Set("cache_cluster_size", d.Get("cache_cluster_size")) @@ -274,7 +273,7 @@ func resourceStageRead(ctx context.Context, d *schema.ResourceData, meta interfa d.Set("deployment_id", stage.DeploymentId) d.Set(names.AttrDescription, stage.Description) d.Set("documentation_version", stage.DocumentationVersion) - d.Set("execution_arn", stageInvokeARN(meta.(*conns.AWSClient), apiID, stageName)) + d.Set("execution_arn", stageInvokeARN(ctx, meta.(*conns.AWSClient), apiID, stageName)) d.Set("invoke_url", meta.(*conns.AWSClient).APIGatewayInvokeURL(ctx, apiID, stageName)) if err := d.Set("variables", stage.Variables); err != nil { return sdkdiag.AppendErrorf(diags, "setting variables: %s", err) @@ -652,21 +651,10 @@ func appendCanarySettingsPatchOperations(operations []types.PatchOperation, oldC return operations } -func stageARN(c *conns.AWSClient, apiID, stageName string) string { - return arn.ARN{ - Partition: c.Partition, - Region: c.Region, - Service: "apigateway", - Resource: fmt.Sprintf("/restapis/%s/stages/%s", apiID, stageName), - }.String() +func stageARN(ctx context.Context, c *conns.AWSClient, apiID, stageName string) string { + return c.RegionalARNNoAccount(ctx, "apigateway", fmt.Sprintf("/restapis/%s/stages/%s", apiID, stageName)) } -func stageInvokeARN(c *conns.AWSClient, apiID, stageName string) string { - return arn.ARN{ - Partition: c.Partition, - Service: "execute-api", - Region: c.Region, - AccountID: c.AccountID, - Resource: fmt.Sprintf("%s/%s", apiID, stageName), - }.String() +func stageInvokeARN(ctx context.Context, c *conns.AWSClient, apiID, stageName string) string { + return c.RegionalARN(ctx, "execute-api", fmt.Sprintf("%s/%s", apiID, stageName)) } diff --git a/internal/service/apigateway/usage_plan.go b/internal/service/apigateway/usage_plan.go index 40d88c1f3ad..0d3772bb44d 100644 --- a/internal/service/apigateway/usage_plan.go +++ b/internal/service/apigateway/usage_plan.go @@ -238,7 +238,7 @@ func resourceUsagePlanRead(ctx context.Context, d *schema.ResourceData, meta int } } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "apigateway", Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("/usageplans/%s", d.Id()), diff --git a/internal/service/apigateway/vpc_link.go b/internal/service/apigateway/vpc_link.go index e0fb7ea8c80..957b5b75977 100644 --- a/internal/service/apigateway/vpc_link.go +++ b/internal/service/apigateway/vpc_link.go @@ -11,7 +11,6 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/apigateway" "github.com/aws/aws-sdk-go-v2/service/apigateway/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -115,7 +114,7 @@ func resourceVPCLinkRead(ctx context.Context, d *schema.ResourceData, meta inter return sdkdiag.AppendErrorf(diags, "reading API Gateway VPC Link (%s): %s", d.Id(), err) } - d.Set(names.AttrARN, vpcLinkARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, vpcLinkARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set(names.AttrDescription, vpcLink.Description) d.Set(names.AttrName, vpcLink.Name) d.Set("target_arns", vpcLink.TargetArns) @@ -278,11 +277,6 @@ func waitVPCLinkDeleted(ctx context.Context, conn *apigateway.Client, id string) return nil, err } -func vpcLinkARN(c *conns.AWSClient, vpcLinkID string) string { - return arn.ARN{ - Partition: c.Partition, - Service: "apigateway", - Region: c.Region, - Resource: fmt.Sprintf("/vpclinks/%s", vpcLinkID), - }.String() +func vpcLinkARN(ctx context.Context, c *conns.AWSClient, vpcLinkID string) string { + return c.RegionalARNNoAccount(ctx, "apigateway", fmt.Sprintf("/vpclinks/%s", vpcLinkID)) } diff --git a/internal/service/apigateway/vpc_link_data_source.go b/internal/service/apigateway/vpc_link_data_source.go index ea151b0d32b..7043f198b55 100644 --- a/internal/service/apigateway/vpc_link_data_source.go +++ b/internal/service/apigateway/vpc_link_data_source.go @@ -77,7 +77,7 @@ func dataSourceVPCLinkRead(ctx context.Context, d *schema.ResourceData, meta int } d.SetId(aws.ToString(match.Id)) - d.Set(names.AttrARN, vpcLinkARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, vpcLinkARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set(names.AttrDescription, match.Description) d.Set(names.AttrName, match.Name) d.Set(names.AttrStatus, match.Status) diff --git a/internal/service/apigatewayv2/api.go b/internal/service/apigatewayv2/api.go index 6fd117b4bfe..6c9c613548b 100644 --- a/internal/service/apigatewayv2/api.go +++ b/internal/service/apigatewayv2/api.go @@ -10,7 +10,6 @@ import ( "reflect" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/apigatewayv2" awstypes "github.com/aws/aws-sdk-go-v2/service/apigatewayv2/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -252,13 +251,13 @@ func resourceAPIRead(ctx context.Context, d *schema.ResourceData, meta interface d.Set("api_endpoint", output.ApiEndpoint) d.Set("api_key_selection_expression", output.ApiKeySelectionExpression) - d.Set(names.AttrARN, apiARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, apiARN(ctx, meta.(*conns.AWSClient), d.Id())) if err := d.Set("cors_configuration", flattenCORSConfiguration(output.CorsConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting cors_configuration: %s", err) } d.Set(names.AttrDescription, output.Description) d.Set("disable_execute_api_endpoint", output.DisableExecuteApiEndpoint) - d.Set("execution_arn", apiInvokeARN(meta.(*conns.AWSClient), d.Id())) + d.Set("execution_arn", apiInvokeARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set(names.AttrName, output.Name) d.Set("protocol_type", output.ProtocolType) d.Set("route_selection_expression", output.RouteSelectionExpression) @@ -494,21 +493,10 @@ func flattenCORSConfiguration(configuration *awstypes.Cors) []interface{} { }} } -func apiARN(c *conns.AWSClient, apiID string) string { - return arn.ARN{ - Partition: c.Partition, - Service: "apigateway", - Region: c.Region, - Resource: "/apis/" + apiID, - }.String() +func apiARN(ctx context.Context, c *conns.AWSClient, apiID string) string { + return c.RegionalARNNoAccount(ctx, "apigateway", "/apis/"+apiID) } -func apiInvokeARN(c *conns.AWSClient, apiID string) string { - return arn.ARN{ - Partition: c.Partition, - Service: "execute-api", - Region: c.Region, - AccountID: c.AccountID, - Resource: apiID, - }.String() +func apiInvokeARN(ctx context.Context, c *conns.AWSClient, apiID string) string { + return c.RegionalARN(ctx, "execute-api", apiID) } diff --git a/internal/service/apigatewayv2/api_data_source.go b/internal/service/apigatewayv2/api_data_source.go index 8729067bea0..3797f87d817 100644 --- a/internal/service/apigatewayv2/api_data_source.go +++ b/internal/service/apigatewayv2/api_data_source.go @@ -126,13 +126,13 @@ func dataSourceAPIRead(ctx context.Context, d *schema.ResourceData, meta interfa d.SetId(apiID) d.Set("api_endpoint", api.ApiEndpoint) d.Set("api_key_selection_expression", api.ApiKeySelectionExpression) - d.Set(names.AttrARN, apiARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, apiARN(ctx, meta.(*conns.AWSClient), d.Id())) if err := d.Set("cors_configuration", flattenCORSConfiguration(api.CorsConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting cors_configuration: %s", err) } d.Set(names.AttrDescription, api.Description) d.Set("disable_execute_api_endpoint", api.DisableExecuteApiEndpoint) - d.Set("execution_arn", apiInvokeARN(meta.(*conns.AWSClient), d.Id())) + d.Set("execution_arn", apiInvokeARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set(names.AttrName, api.Name) d.Set("protocol_type", api.ProtocolType) d.Set("route_selection_expression", api.RouteSelectionExpression) diff --git a/internal/service/apigatewayv2/domain_name.go b/internal/service/apigatewayv2/domain_name.go index 1d178223c24..c4e1c2e70c3 100644 --- a/internal/service/apigatewayv2/domain_name.go +++ b/internal/service/apigatewayv2/domain_name.go @@ -173,7 +173,7 @@ func resourceDomainNameRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("api_mapping_selection_expression", output.ApiMappingSelectionExpression) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "apigateway", Region: meta.(*conns.AWSClient).Region, Resource: "/domainnames/" + d.Id(), diff --git a/internal/service/apigatewayv2/stage.go b/internal/service/apigatewayv2/stage.go index bb57a521d09..57fcdc32165 100644 --- a/internal/service/apigatewayv2/stage.go +++ b/internal/service/apigatewayv2/stage.go @@ -10,7 +10,6 @@ import ( "strings" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/apigatewayv2" awstypes "github.com/aws/aws-sdk-go-v2/service/apigatewayv2/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -270,7 +269,7 @@ func resourceStageRead(ctx context.Context, d *schema.ResourceData, meta interfa if err := d.Set("access_log_settings", flattenAccessLogSettings(outputGS.AccessLogSettings)); err != nil { return sdkdiag.AppendErrorf(diags, "setting access_log_settings: %s", err) } - d.Set(names.AttrARN, stageARN(meta.(*conns.AWSClient), apiID, stageName)) + d.Set(names.AttrARN, stageARN(ctx, meta.(*conns.AWSClient), apiID, stageName)) d.Set("auto_deploy", outputGS.AutoDeploy) d.Set("client_certificate_id", outputGS.ClientCertificateId) if err := d.Set("default_route_settings", flattenDefaultRouteSettings(outputGS.DefaultRouteSettings)); err != nil { @@ -278,7 +277,7 @@ func resourceStageRead(ctx context.Context, d *schema.ResourceData, meta interfa } d.Set("deployment_id", outputGS.DeploymentId) d.Set(names.AttrDescription, outputGS.Description) - d.Set("execution_arn", stageInvokeARN(meta.(*conns.AWSClient), apiID, stageName)) + d.Set("execution_arn", stageInvokeARN(ctx, meta.(*conns.AWSClient), apiID, stageName)) d.Set(names.AttrName, stageName) if err := d.Set("route_settings", flattenRouteSettings(outputGS.RouteSettings)); err != nil { return sdkdiag.AppendErrorf(diags, "setting route_settings: %s", err) @@ -588,21 +587,10 @@ func flattenRouteSettings(settings map[string]awstypes.RouteSettings) []interfac return vSettings } -func stageARN(c *conns.AWSClient, apiID, stageName string) string { - return arn.ARN{ - Partition: c.Partition, - Service: "apigateway", - Region: c.Region, - Resource: fmt.Sprintf("/apis/%s/stages/%s", apiID, stageName), - }.String() +func stageARN(ctx context.Context, c *conns.AWSClient, apiID, stageName string) string { + return c.RegionalARNNoAccount(ctx, "apigateway", fmt.Sprintf("/apis/%s/stages/%s", apiID, stageName)) } -func stageInvokeARN(c *conns.AWSClient, apiID, stageName string) string { - return arn.ARN{ - Partition: c.Partition, - Service: "execute-api", - Region: c.Region, - AccountID: c.AccountID, - Resource: fmt.Sprintf("%s/%s", apiID, stageName), - }.String() +func stageInvokeARN(ctx context.Context, c *conns.AWSClient, apiID, stageName string) string { + return c.RegionalARN(ctx, "execute-api", fmt.Sprintf("%s/%s", apiID, stageName)) } diff --git a/internal/service/apigatewayv2/vpc_link.go b/internal/service/apigatewayv2/vpc_link.go index c20151a4d84..ef086c5886c 100644 --- a/internal/service/apigatewayv2/vpc_link.go +++ b/internal/service/apigatewayv2/vpc_link.go @@ -10,7 +10,6 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/apigatewayv2" awstypes "github.com/aws/aws-sdk-go-v2/service/apigatewayv2/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -115,7 +114,7 @@ func resourceVPCLinkRead(ctx context.Context, d *schema.ResourceData, meta inter return sdkdiag.AppendErrorf(diags, "reading API Gateway v2 VPC Link (%s): %s", d.Id(), err) } - d.Set(names.AttrARN, vpcLinkARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, vpcLinkARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set(names.AttrName, output.Name) d.Set(names.AttrSecurityGroupIDs, output.SecurityGroupIds) d.Set(names.AttrSubnetIDs, output.SubnetIds) @@ -258,11 +257,6 @@ func waitVPCLinkDeleted(ctx context.Context, conn *apigatewayv2.Client, vpcLinkI return nil, err } -func vpcLinkARN(c *conns.AWSClient, vpcLinkID string) string { - return arn.ARN{ - Partition: c.Partition, - Service: "apigateway", - Region: c.Region, - Resource: "/vpclinks/" + vpcLinkID, - }.String() +func vpcLinkARN(ctx context.Context, c *conns.AWSClient, vpcLinkID string) string { + return c.RegionalARNNoAccount(ctx, "apigateway", "/vpclinks/"+vpcLinkID) } diff --git a/internal/service/apigatewayv2/vpc_link_data_source.go b/internal/service/apigatewayv2/vpc_link_data_source.go index 97ab23fd8f3..b020687a91a 100644 --- a/internal/service/apigatewayv2/vpc_link_data_source.go +++ b/internal/service/apigatewayv2/vpc_link_data_source.go @@ -61,7 +61,7 @@ func dataSourceVPCLinkRead(ctx context.Context, d *schema.ResourceData, meta int } d.SetId(vpcLinkID) - d.Set(names.AttrARN, vpcLinkARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, vpcLinkARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set(names.AttrName, output.Name) d.Set(names.AttrSecurityGroupIDs, output.SecurityGroupIds) d.Set(names.AttrSubnetIDs, output.SubnetIds) diff --git a/internal/service/appconfig/application.go b/internal/service/appconfig/application.go index 204784ce1f3..4243e2dd1d3 100644 --- a/internal/service/appconfig/application.go +++ b/internal/service/appconfig/application.go @@ -112,7 +112,7 @@ func resourceApplicationRead(ctx context.Context, d *schema.ResourceData, meta i arn := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("application/%s", aws.ToString(output.Id)), Service: "appconfig", diff --git a/internal/service/appconfig/configuration_profile.go b/internal/service/appconfig/configuration_profile.go index 7e51a158d97..0894f711f9f 100644 --- a/internal/service/appconfig/configuration_profile.go +++ b/internal/service/appconfig/configuration_profile.go @@ -213,7 +213,7 @@ func resourceConfigurationProfileRead(ctx context.Context, d *schema.ResourceDat arn := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("application/%s/configurationprofile/%s", appID, confProfID), Service: "appconfig", diff --git a/internal/service/appconfig/configuration_profile_data_source.go b/internal/service/appconfig/configuration_profile_data_source.go index 4b0eb98a809..b8317e74173 100644 --- a/internal/service/appconfig/configuration_profile_data_source.go +++ b/internal/service/appconfig/configuration_profile_data_source.go @@ -109,7 +109,7 @@ func dataSourceConfigurationProfileRead(ctx context.Context, d *schema.ResourceD arn := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("application/%s/configurationprofile/%s", appId, profileId), Service: "appconfig", diff --git a/internal/service/appconfig/deployment.go b/internal/service/appconfig/deployment.go index 217a62948d9..0420e247d54 100644 --- a/internal/service/appconfig/deployment.go +++ b/internal/service/appconfig/deployment.go @@ -182,7 +182,7 @@ func resourceDeploymentRead(ctx context.Context, d *schema.ResourceData, meta in arn := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("application/%s/environment/%s/deployment/%d", aws.ToString(output.ApplicationId), aws.ToString(output.EnvironmentId), output.DeploymentNumber), Service: "appconfig", diff --git a/internal/service/appconfig/deployment_strategy.go b/internal/service/appconfig/deployment_strategy.go index c4fa4c71558..dbfabb2ee9d 100644 --- a/internal/service/appconfig/deployment_strategy.go +++ b/internal/service/appconfig/deployment_strategy.go @@ -153,7 +153,7 @@ func resourceDeploymentStrategyRead(ctx context.Context, d *schema.ResourceData, arn := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("deploymentstrategy/%s", d.Id()), Service: "appconfig", diff --git a/internal/service/appconfig/environment.go b/internal/service/appconfig/environment.go index cb03ee76b78..78e0e9656d2 100644 --- a/internal/service/appconfig/environment.go +++ b/internal/service/appconfig/environment.go @@ -10,7 +10,6 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/appconfig" awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" "github.com/hashicorp/terraform-plugin-framework-validators/setvalidator" @@ -337,7 +336,7 @@ func (d *resourceEnvironmentData) refreshFromCreateOutput(ctx context.Context, m envID := aws.ToString(out.Id) d.ApplicationID = types.StringValue(appID) - d.ARN = types.StringValue(environmentARN(meta, aws.ToString(out.ApplicationId), aws.ToString(out.Id)).String()) + d.ARN = types.StringValue(environmentARN(ctx, meta, aws.ToString(out.ApplicationId), aws.ToString(out.Id))) d.Description = flex.StringToFrameworkLegacy(ctx, out.Description) d.EnvironmentID = types.StringValue(envID) d.ID = types.StringValue(fmt.Sprintf("%s:%s", envID, appID)) @@ -359,7 +358,7 @@ func (d *resourceEnvironmentData) refreshFromGetOutput(ctx context.Context, meta envID := aws.ToString(out.Id) d.ApplicationID = types.StringValue(appID) - d.ARN = types.StringValue(environmentARN(meta, aws.ToString(out.ApplicationId), aws.ToString(out.Id)).String()) + d.ARN = types.StringValue(environmentARN(ctx, meta, aws.ToString(out.ApplicationId), aws.ToString(out.Id))) d.Description = flex.StringToFrameworkLegacy(ctx, out.Description) d.EnvironmentID = types.StringValue(envID) d.ID = types.StringValue(fmt.Sprintf("%s:%s", envID, appID)) @@ -381,7 +380,7 @@ func (d *resourceEnvironmentData) refreshFromUpdateOutput(ctx context.Context, m envID := aws.ToString(out.Id) d.ApplicationID = types.StringValue(appID) - d.ARN = types.StringValue(environmentARN(meta, aws.ToString(out.ApplicationId), aws.ToString(out.Id)).String()) + d.ARN = types.StringValue(environmentARN(ctx, meta, aws.ToString(out.ApplicationId), aws.ToString(out.Id))) d.Description = flex.StringToFrameworkLegacy(ctx, out.Description) d.EnvironmentID = types.StringValue(envID) d.ID = types.StringValue(fmt.Sprintf("%s:%s", envID, appID)) @@ -413,14 +412,8 @@ func (d *resourceEnvironmentData) deleteEnvironmentInput() *appconfig.DeleteEnvi } } -func environmentARN(meta *conns.AWSClient, appID, envID string) arn.ARN { - return arn.ARN{ - AccountID: meta.AccountID, - Partition: meta.Partition, - Region: meta.Region, - Resource: fmt.Sprintf("application/%s/environment/%s", appID, envID), - Service: "appconfig", - } +func environmentARN(ctx context.Context, c *conns.AWSClient, appID, envID string) string { + return c.RegionalARN(ctx, "appconfig", fmt.Sprintf("application/%s/environment/%s", appID, envID)) } func expandMonitors(l []monitorData) []awstypes.Monitor { diff --git a/internal/service/appconfig/environment_data_source.go b/internal/service/appconfig/environment_data_source.go index 70696fd519c..e92c7cc36d2 100644 --- a/internal/service/appconfig/environment_data_source.go +++ b/internal/service/appconfig/environment_data_source.go @@ -92,10 +92,10 @@ func dataSourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta } d.SetId(ID) - d.Set(names.AttrApplicationID, appID) - d.Set("environment_id", envID) + d.Set(names.AttrARN, environmentARN(ctx, meta.(*conns.AWSClient), appID, envID)) d.Set(names.AttrDescription, out.Description) + d.Set("environment_id", envID) d.Set(names.AttrName, out.Name) d.Set(names.AttrState, out.State) @@ -103,10 +103,6 @@ func dataSourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta return create.AppendDiagError(diags, names.AppConfig, create.ErrActionReading, DSNameEnvironment, ID, err) } - arn := environmentARN(meta.(*conns.AWSClient), appID, envID).String() - - d.Set(names.AttrARN, arn) - return diags } diff --git a/internal/service/appconfig/hosted_configuration_version.go b/internal/service/appconfig/hosted_configuration_version.go index 129115c2950..769c70c3a0f 100644 --- a/internal/service/appconfig/hosted_configuration_version.go +++ b/internal/service/appconfig/hosted_configuration_version.go @@ -147,7 +147,7 @@ func resourceHostedConfigurationVersionRead(ctx context.Context, d *schema.Resou arn := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("application/%s/configurationprofile/%s/hostedconfigurationversion/%d", appID, confProfID, versionNumber), Service: "appconfig", diff --git a/internal/service/applicationinsights/application.go b/internal/service/applicationinsights/application.go index fe8df3ab184..6331f1f78d8 100644 --- a/internal/service/applicationinsights/application.go +++ b/internal/service/applicationinsights/application.go @@ -140,7 +140,7 @@ func resourceApplicationRead(ctx context.Context, d *schema.ResourceData, meta i rgName := aws.ToString(application.ResourceGroupName) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "applicationinsights", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/athena/data_catalog.go b/internal/service/athena/data_catalog.go index fdaadd3c1ab..ef38bb1be74 100644 --- a/internal/service/athena/data_catalog.go +++ b/internal/service/athena/data_catalog.go @@ -127,7 +127,7 @@ func resourceDataCatalogRead(ctx context.Context, d *schema.ResourceData, meta i } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "athena", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/athena/workgroup.go b/internal/service/athena/workgroup.go index 8e8efc9fe2b..5006c9edf06 100644 --- a/internal/service/athena/workgroup.go +++ b/internal/service/athena/workgroup.go @@ -240,7 +240,7 @@ func resourceWorkGroupRead(ctx context.Context, d *schema.ResourceData, meta int } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "athena", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/backup/vault_test.go b/internal/service/backup/vault_test.go index d6842309786..012a9b9ac65 100644 --- a/internal/service/backup/vault_test.go +++ b/internal/service/backup/vault_test.go @@ -231,13 +231,13 @@ func testAccCheckRunDynamoDBTableBackupJob(ctx context.Context, rName string) re conn := client.BackupClient(ctx) iamRoleARN := arn.ARN{ - Partition: client.Partition, + Partition: client.Partition(ctx), Service: "iam", AccountID: client.AccountID, Resource: "role/service-role/AWSBackupDefaultServiceRole", }.String() resourceARN := arn.ARN{ - Partition: client.Partition, + Partition: client.Partition(ctx), Service: "dynamodb", Region: client.Region, AccountID: client.AccountID, diff --git a/internal/service/batch/sweep.go b/internal/service/batch/sweep.go index cd5461d795e..fb008f05df9 100644 --- a/internal/service/batch/sweep.go +++ b/internal/service/batch/sweep.go @@ -105,11 +105,11 @@ func sweepComputeEnvironments(region string) error { continue } - servicePrincipal := fmt.Sprintf("%s.%s", names.BatchEndpointID, sweep.PartitionDNSSuffix(region)) + servicePrincipal := fmt.Sprintf("%s.%s", names.BatchEndpointID, client.DNSSuffix(ctx)) serviceRoleName := strings.TrimPrefix(serviceRoleARN.Resource, "role/") serviceRolePolicyARN := arn.ARN{ AccountID: "aws", - Partition: sweep.Partition(region), + Partition: client.Partition(ctx), Resource: "policy/service-role/AWSBatchServiceRole", Service: "iam", }.String() diff --git a/internal/service/bcmdataexports/export_test.go b/internal/service/bcmdataexports/export_test.go index 95e6326fe24..4f10ec8ca40 100644 --- a/internal/service/bcmdataexports/export_test.go +++ b/internal/service/bcmdataexports/export_test.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/bcmdataexports" "github.com/aws/aws-sdk-go-v2/service/bcmdataexports/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -36,7 +37,7 @@ func TestAccBCMDataExportsExport_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.BCMDataExportsServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -87,7 +88,7 @@ func TestAccBCMDataExportsExport_update(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.BCMDataExportsServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -275,7 +276,7 @@ func TestAccBCMDataExportsExport_curSubset(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.BCMDataExportsServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -314,7 +315,7 @@ func TestAccBCMDataExportsExport_disappears(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.BCMDataExportsServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -341,7 +342,7 @@ func TestAccBCMDataExportsExport_updateTable(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.BCMDataExportsServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/budgets/budget.go b/internal/service/budgets/budget.go index 6d2f9c7814d..26837cb9566 100644 --- a/internal/service/budgets/budget.go +++ b/internal/service/budgets/budget.go @@ -371,7 +371,7 @@ func resourceBudgetRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set(names.AttrAccountID, accountID) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "budgets", AccountID: accountID, Resource: "budget/" + budgetName, diff --git a/internal/service/budgets/budget_action.go b/internal/service/budgets/budget_action.go index 01bf16f169e..34e267e4b7e 100644 --- a/internal/service/budgets/budget_action.go +++ b/internal/service/budgets/budget_action.go @@ -301,7 +301,7 @@ func resourceBudgetActionRead(ctx context.Context, d *schema.ResourceData, meta d.Set("action_type", output.ActionType) d.Set("approval_model", output.ApprovalModel) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "budgets", AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("budget/%s/action/%s", budgetName, actionID), diff --git a/internal/service/budgets/budget_data_source.go b/internal/service/budgets/budget_data_source.go index b3ac0652554..f19676d378a 100644 --- a/internal/service/budgets/budget_data_source.go +++ b/internal/service/budgets/budget_data_source.go @@ -292,7 +292,7 @@ func dataSourceBudgetRead(ctx context.Context, d *schema.ResourceData, meta inte d.SetId(fmt.Sprintf("%s:%s", accountID, budgetName)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "budgets", AccountID: accountID, Resource: "budget/" + budgetName, diff --git a/internal/service/chatbot/service_package.go b/internal/service/chatbot/service_package.go index 3e2466dce00..19bec367747 100644 --- a/internal/service/chatbot/service_package.go +++ b/internal/service/chatbot/service_package.go @@ -9,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/chatbot" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -21,7 +22,7 @@ func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) ( chatbot.WithEndpointResolverV2(newEndpointResolverV2()), withBaseEndpoint(config[names.AttrEndpoint].(string)), func(o *chatbot.Options) { - if config["partition"].(string) == names.StandardPartitionID { + if config["partition"].(string) == endpoints.AwsPartitionID { // Chatbot endpoint is available only in the 4 regions us-east-2, us-west-2, eu-west-1, and ap-southeast-1. // If the region from the context is one of those four, then use that region. If not default to us-west-2 if slices.Contains([]string{names.USEast2RegionID, names.USWest2RegionID, names.EUWest1RegionID, names.APSoutheast1RegionID}, cfg.Region) { diff --git a/internal/service/cloudfront/distribution_test.go b/internal/service/cloudfront/distribution_test.go index 92d9fb0c1e3..2cb16be603d 100644 --- a/internal/service/cloudfront/distribution_test.go +++ b/internal/service/cloudfront/distribution_test.go @@ -12,6 +12,7 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" awstypes "github.com/aws/aws-sdk-go-v2/service/cloudfront/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -1557,9 +1558,9 @@ func testAccDistributionRetainConfig() string { // are necessary and overwrites the "aws" provider configuration. func testAccRegionProviderConfig() string { switch acctest.Partition() { - case names.StandardPartitionID: + case endpoints.AwsPartitionID: return acctest.ConfigRegionalProvider(names.USEast1RegionID) - case names.ChinaPartitionID: + case endpoints.AwsCnPartitionID: return acctest.ConfigRegionalProvider(names.CNNorthwest1RegionID) default: return acctest.ConfigRegionalProvider(acctest.Region()) diff --git a/internal/service/cloudfront/log_delivery_canonical_user_id_data_source.go b/internal/service/cloudfront/log_delivery_canonical_user_id_data_source.go index 7223a6c1df8..a4c00fe3c93 100644 --- a/internal/service/cloudfront/log_delivery_canonical_user_id_data_source.go +++ b/internal/service/cloudfront/log_delivery_canonical_user_id_data_source.go @@ -6,6 +6,7 @@ package cloudfront import ( "context" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -36,18 +37,18 @@ func dataSourceLogDeliveryCanonicalUserID() *schema.Resource { func dataSourceLogDeliveryCanonicalUserIDRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - canonicalId := defaultLogDeliveryCanonicalUserID + canonicalUserID := defaultLogDeliveryCanonicalUserID region := meta.(*conns.AWSClient).Region if v, ok := d.GetOk(names.AttrRegion); ok { region = v.(string) } - if v := names.PartitionForRegion(region); v == names.ChinaPartitionID { - canonicalId = cnLogDeliveryCanonicalUserID + if v := names.PartitionForRegion(region); v.ID() == endpoints.AwsCnPartitionID { + canonicalUserID = cnLogDeliveryCanonicalUserID } - d.SetId(canonicalId) + d.SetId(canonicalUserID) return diags } diff --git a/internal/service/cloudfront/origin_access_identities_data_source.go b/internal/service/cloudfront/origin_access_identities_data_source.go index e0b9b3ba749..7cc966aa043 100644 --- a/internal/service/cloudfront/origin_access_identities_data_source.go +++ b/internal/service/cloudfront/origin_access_identities_data_source.go @@ -82,7 +82,7 @@ func dataSourceOriginAccessIdentitiesRead(ctx context.Context, d *schema.Resourc for _, v := range output { id := aws.ToString(v.Id) - iamARNs = append(iamARNs, originAccessIdentityARN(meta.(*conns.AWSClient), id)) + iamARNs = append(iamARNs, originAccessIdentityARN(ctx, meta.(*conns.AWSClient), id)) ids = append(ids, id) s3CanonicalUserIDs = append(s3CanonicalUserIDs, aws.ToString(v.S3CanonicalUserId)) } diff --git a/internal/service/cloudfront/origin_access_identity.go b/internal/service/cloudfront/origin_access_identity.go index 03feef8c190..b4c86c23f24 100644 --- a/internal/service/cloudfront/origin_access_identity.go +++ b/internal/service/cloudfront/origin_access_identity.go @@ -104,7 +104,7 @@ func resourceOriginAccessIdentityRead(ctx context.Context, d *schema.ResourceDat d.Set("cloudfront_access_identity_path", "origin-access-identity/cloudfront/"+d.Id()) d.Set(names.AttrComment, apiObject.Comment) d.Set("etag", output.ETag) - d.Set("iam_arn", originAccessIdentityARN(meta.(*conns.AWSClient), d.Id())) + d.Set("iam_arn", originAccessIdentityARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set("s3_canonical_user_id", output.CloudFrontOriginAccessIdentity.S3CanonicalUserId) return diags @@ -189,9 +189,9 @@ func expandCloudFrontOriginAccessIdentityConfig(d *schema.ResourceData) *awstype return apiObject } -func originAccessIdentityARN(c *conns.AWSClient, originAccessControlID string) string { +func originAccessIdentityARN(ctx context.Context, c *conns.AWSClient, originAccessControlID string) string { return arn.ARN{ - Partition: c.Partition, + Partition: c.Partition(ctx), Service: "iam", AccountID: "cloudfront", Resource: "user/CloudFront Origin Access Identity " + originAccessControlID, diff --git a/internal/service/cloudfront/origin_access_identity_data_source.go b/internal/service/cloudfront/origin_access_identity_data_source.go index edd709ec6c8..bbdf9f9fd5d 100644 --- a/internal/service/cloudfront/origin_access_identity_data_source.go +++ b/internal/service/cloudfront/origin_access_identity_data_source.go @@ -69,7 +69,7 @@ func dataSourceOriginAccessIdentityRead(ctx context.Context, d *schema.ResourceD d.Set("cloudfront_access_identity_path", "origin-access-identity/cloudfront/"+d.Id()) d.Set(names.AttrComment, apiObject.Comment) d.Set("etag", output.ETag) - d.Set("iam_arn", originAccessIdentityARN(meta.(*conns.AWSClient), d.Id())) + d.Set("iam_arn", originAccessIdentityARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set("s3_canonical_user_id", output.CloudFrontOriginAccessIdentity.S3CanonicalUserId) return diags diff --git a/internal/service/cloudtrail/service_account_data_source.go b/internal/service/cloudtrail/service_account_data_source.go index 0c473bd749b..703aaeb99db 100644 --- a/internal/service/cloudtrail/service_account_data_source.go +++ b/internal/service/cloudtrail/service_account_data_source.go @@ -82,7 +82,7 @@ func dataSourceServiceAccountRead(ctx context.Context, d *schema.ResourceData, m if v, ok := serviceAccountPerRegionMap[region]; ok { d.SetId(v) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "iam", AccountID: v, Resource: "root", diff --git a/internal/service/cloudwatch/composite_alarm.go b/internal/service/cloudwatch/composite_alarm.go index 7b723472c62..49df78f7fbc 100644 --- a/internal/service/cloudwatch/composite_alarm.go +++ b/internal/service/cloudwatch/composite_alarm.go @@ -129,7 +129,7 @@ func resourceCompositeAlarmCreate(ctx context.Context, d *schema.ResourceData, m _, err := conn.PutCompositeAlarm(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { input.Tags = nil _, err = conn.PutCompositeAlarm(ctx, input) @@ -152,7 +152,7 @@ func resourceCompositeAlarmCreate(ctx context.Context, d *schema.ResourceData, m err = createTags(ctx, conn, aws.ToString(alarm.AlarmArn), tags) // If default tags only, continue. Otherwise, error. - if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return append(diags, resourceCompositeAlarmRead(ctx, d, meta)...) } diff --git a/internal/service/cloudwatch/metric_alarm.go b/internal/service/cloudwatch/metric_alarm.go index d377132a7e7..10e75bfdbe1 100644 --- a/internal/service/cloudwatch/metric_alarm.go +++ b/internal/service/cloudwatch/metric_alarm.go @@ -329,7 +329,7 @@ func resourceMetricAlarmCreate(ctx context.Context, d *schema.ResourceData, meta _, err := conn.PutMetricAlarm(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { input.Tags = nil _, err = conn.PutMetricAlarm(ctx, input) @@ -352,7 +352,7 @@ func resourceMetricAlarmCreate(ctx context.Context, d *schema.ResourceData, meta err = createTags(ctx, conn, aws.ToString(alarm.AlarmArn), tags) // If default tags only, continue. Otherwise, error. - if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return append(diags, resourceMetricAlarmRead(ctx, d, meta)...) } diff --git a/internal/service/cloudwatch/metric_stream.go b/internal/service/cloudwatch/metric_stream.go index 4a68f1056d5..2401f055cca 100644 --- a/internal/service/cloudwatch/metric_stream.go +++ b/internal/service/cloudwatch/metric_stream.go @@ -229,7 +229,7 @@ func resourceMetricStreamCreate(ctx context.Context, d *schema.ResourceData, met output, err := conn.PutMetricStream(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { input.Tags = nil output, err = conn.PutMetricStream(ctx, input) @@ -250,7 +250,7 @@ func resourceMetricStreamCreate(ctx context.Context, d *schema.ResourceData, met err := createTags(ctx, conn, aws.ToString(output.Arn), tags) // If default tags only, continue. Otherwise, error. - if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return append(diags, resourceMetricStreamRead(ctx, d, meta)...) } diff --git a/internal/service/codebuild/project_test.go b/internal/service/codebuild/project_test.go index b69bac367df..79f67f654a0 100644 --- a/internal/service/codebuild/project_test.go +++ b/internal/service/codebuild/project_test.go @@ -12,6 +12,7 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/codebuild/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -235,7 +236,7 @@ func TestAccCodeBuildProject_publicVisibility(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) testAccPreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheckSourceCredentialsForServerType(ctx, t, types.ServerTypeGithub) }, ErrorCheck: acctest.ErrorCheck(t, names.CodeBuildServiceID), @@ -1017,7 +1018,7 @@ func TestAccCodeBuildProject_buildBatchConfigDelete(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) testAccPreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheckSourceCredentialsForServerType(ctx, t, types.ServerTypeGithub) }, ErrorCheck: acctest.ErrorCheck(t, names.CodeBuildServiceID), @@ -1458,7 +1459,7 @@ func TestAccCodeBuildProject_SourceBuildStatus_gitHubEnterprise(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) testAccPreCheckSourceCredentialsForServerType(ctx, t, types.ServerTypeGithubEnterprise) }, @@ -1875,7 +1876,7 @@ func TestAccCodeBuildProject_windowsServer2019Container(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) testAccPreCheckSourceCredentialsForServerType(ctx, t, types.ServerTypeGithub) }, @@ -1914,7 +1915,7 @@ func TestAccCodeBuildProject_armContainer(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) testAccPreCheckSourceCredentialsForServerType(ctx, t, types.ServerTypeGithub) }, @@ -1946,7 +1947,7 @@ func TestAccCodeBuildProject_linuxLambdaContainer(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) testAccPreCheckSourceCredentialsForServerType(ctx, t, types.ServerTypeGithub) }, @@ -2360,7 +2361,7 @@ func TestAccCodeBuildProject_Artifacts_bucketOwnerAccess(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.CodeBuildServiceID), diff --git a/internal/service/codepipeline/custom_action_type.go b/internal/service/codepipeline/custom_action_type.go index 8057ba9080d..707b6bf8358 100644 --- a/internal/service/codepipeline/custom_action_type.go +++ b/internal/service/codepipeline/custom_action_type.go @@ -247,7 +247,7 @@ func resourceCustomActionTypeRead(ctx context.Context, d *schema.ResourceData, m } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "codepipeline", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/cognitoidentity/pool.go b/internal/service/cognitoidentity/pool.go index 62b040b9fb8..7759c21affe 100644 --- a/internal/service/cognitoidentity/pool.go +++ b/internal/service/cognitoidentity/pool.go @@ -186,7 +186,7 @@ func resourcePoolRead(ctx context.Context, d *schema.ResourceData, meta interfac } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "cognito-identity", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/cognitoidentity/pool_data_source.go b/internal/service/cognitoidentity/pool_data_source.go index ff7d13cb0d1..64df8d1cf7a 100644 --- a/internal/service/cognitoidentity/pool_data_source.go +++ b/internal/service/cognitoidentity/pool_data_source.go @@ -112,7 +112,7 @@ func dataSourcePoolRead(ctx context.Context, d *schema.ResourceData, meta interf d.SetId(aws.ToString(ip.IdentityPoolId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "cognito-identity", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/cognitoidp/user_pools_data_source.go b/internal/service/cognitoidp/user_pools_data_source.go index 7a5476d9e0f..5251cbf9e06 100644 --- a/internal/service/cognitoidp/user_pools_data_source.go +++ b/internal/service/cognitoidp/user_pools_data_source.go @@ -57,7 +57,7 @@ func dataSourceUserPoolsRead(ctx context.Context, d *schema.ResourceData, meta i for _, v := range output { userPoolID := aws.ToString(v.Id) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "cognito-idp", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/costoptimizationhub/service_package.go b/internal/service/costoptimizationhub/service_package.go index 84b08fb0178..3b8eaf3b396 100644 --- a/internal/service/costoptimizationhub/service_package.go +++ b/internal/service/costoptimizationhub/service_package.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/costoptimizationhub" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -20,7 +21,7 @@ func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) ( costoptimizationhub.WithEndpointResolverV2(newEndpointResolverV2()), withBaseEndpoint(config[names.AttrEndpoint].(string)), func(o *costoptimizationhub.Options) { - if config["partition"].(string) == names.StandardPartitionID { + if config["partition"].(string) == endpoints.AwsPartitionID { // Cost Optimization Hub endpoint is available only in us-east-1 Region. if cfg.Region != names.USEast1RegionID { tflog.Info(ctx, "overriding region", map[string]any{ diff --git a/internal/service/cur/report_definition.go b/internal/service/cur/report_definition.go index 32c670384e3..250f6ff6338 100644 --- a/internal/service/cur/report_definition.go +++ b/internal/service/cur/report_definition.go @@ -192,7 +192,7 @@ func resourceReportDefinitionRead(ctx context.Context, d *schema.ResourceData, m d.Set("additional_artifacts", reportDefinition.AdditionalArtifacts) d.Set("additional_schema_elements", reportDefinition.AdditionalSchemaElements) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.CUR, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/cur/service_package.go b/internal/service/cur/service_package.go index 085157f67ab..9bf53fd0f4f 100644 --- a/internal/service/cur/service_package.go +++ b/internal/service/cur/service_package.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/costandusagereportservice" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -20,7 +21,7 @@ func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) ( costandusagereportservice.WithEndpointResolverV2(newEndpointResolverV2()), withBaseEndpoint(config[names.AttrEndpoint].(string)), func(o *costandusagereportservice.Options) { - if config["partition"].(string) == names.StandardPartitionID { + if config["partition"].(string) == endpoints.AwsPartitionID { // AWS Cost and Usage Reports is only available in AWS Commercial us-east-1 Region. // https://docs.aws.amazon.com/general/latest/gr/billing.html. if cfg.Region != names.USEast1RegionID { diff --git a/internal/service/customerprofiles/domain.go b/internal/service/customerprofiles/domain.go index 9ff77515ffc..fa9a4028a74 100644 --- a/internal/service/customerprofiles/domain.go +++ b/internal/service/customerprofiles/domain.go @@ -5,7 +5,6 @@ package customerprofiles import ( "context" - "fmt" "log" "github.com/aws/aws-sdk-go-v2/aws" @@ -313,7 +312,7 @@ func resourceDomainRead(ctx context.Context, d *schema.ResourceData, meta interf return sdkdiag.AppendErrorf(diags, "reading Customer Profiles Domain: (%s) %s", d.Id(), err) } - d.Set(names.AttrARN, buildDomainARN(meta.(*conns.AWSClient), d.Id())) + d.Set(names.AttrARN, domainARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set(names.AttrDomainName, output.DomainName) d.Set("dead_letter_queue_url", output.DeadLetterQueueUrl) d.Set("default_encryption_key", output.DefaultEncryptionKey) @@ -910,6 +909,6 @@ func flattenMatchingRules(apiObject []types.MatchingRule) []interface{} { // CreateDomainOutput does not have an ARN attribute which is needed for Tagging, therefore we construct it. // https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonconnectcustomerprofiles.html#amazonconnectcustomerprofiles-resources-for-iam-policies -func buildDomainARN(conn *conns.AWSClient, domainName string) string { - return fmt.Sprintf("arn:%s:profile:%s:%s:domains/%s", conn.Partition, conn.Region, conn.AccountID, domainName) +func domainARN(ctx context.Context, c *conns.AWSClient, domainName string) string { + return c.RegionalARN(ctx, "profile", "domains/"+domainName) // nosemgrep:ci.literal-profile-string-constant } diff --git a/internal/service/deploy/app.go b/internal/service/deploy/app.go index c78f5258f14..cc4fae3905b 100644 --- a/internal/service/deploy/app.go +++ b/internal/service/deploy/app.go @@ -154,7 +154,7 @@ func resourceAppRead(ctx context.Context, d *schema.ResourceData, meta interface d.Set(names.AttrApplicationID, app.ApplicationId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "codedeploy", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/deploy/deployment_config.go b/internal/service/deploy/deployment_config.go index 14000d17464..6b9c8c8f39f 100644 --- a/internal/service/deploy/deployment_config.go +++ b/internal/service/deploy/deployment_config.go @@ -221,7 +221,7 @@ func resourceDeploymentConfigRead(ctx context.Context, d *schema.ResourceData, m deploymentConfigName := aws.ToString(deploymentConfig.DeploymentConfigName) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "codedeploy", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/deploy/deployment_group.go b/internal/service/deploy/deployment_group.go index ecfd9e3c669..b0f9763991d 100644 --- a/internal/service/deploy/deployment_group.go +++ b/internal/service/deploy/deployment_group.go @@ -575,7 +575,7 @@ func resourceDeploymentGroupRead(ctx context.Context, d *schema.ResourceData, me groupName := aws.ToString(group.DeploymentGroupName) d.Set("app_name", appName) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "codedeploy", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/devicefarm/device_pool.go b/internal/service/devicefarm/device_pool.go index 9534ba787c9..732cfa3f3e4 100644 --- a/internal/service/devicefarm/device_pool.go +++ b/internal/service/devicefarm/device_pool.go @@ -153,7 +153,7 @@ func resourceDevicePoolRead(ctx context.Context, d *schema.ResourceData, meta in d.Set(names.AttrDescription, devicePool.Description) d.Set("max_devices", devicePool.MaxDevices) - projectArn, err := decodeProjectARN(arn, "devicepool", meta) + projectArn, err := decodeProjectARN(ctx, meta.(*conns.AWSClient), arn, "devicepool") if err != nil { return sdkdiag.AppendErrorf(diags, "decoding project_arn (%s): %s", arn, err) } @@ -295,26 +295,20 @@ func flattenDevicePoolRules(list []awstypes.Rule) []map[string]interface{} { return result } -func decodeProjectARN(id, typ string, meta interface{}) (string, error) { - poolArn, err := arn.Parse(id) +func decodeProjectARN(ctx context.Context, c *conns.AWSClient, id, typ string) (string, error) { + poolARN, err := arn.Parse(id) if err != nil { return "", fmt.Errorf("parsing '%s': %w", id, err) } - poolArnResouce := poolArn.Resource - parts := strings.Split(strings.TrimPrefix(poolArnResouce, typ+":"), "/") + poolARNResource := poolARN.Resource + parts := strings.Split(strings.TrimPrefix(poolARNResource, typ+":"), "/") if len(parts) != 2 { - return "", fmt.Errorf("Unexpected format of ID (%q), expected project-id/%q-id", poolArnResouce, typ) + return "", fmt.Errorf("Unexpected format of ID (%q), expected project-id/%q-id", poolARNResource, typ) } - projectId := parts[0] - projectArn := arn.ARN{ - AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, - Region: meta.(*conns.AWSClient).Region, - Resource: "project:" + projectId, - Service: names.DeviceFarmEndpointID, - }.String() + projectID := parts[0] + projectARN := c.RegionalARN(ctx, "devicefarm", "project:"+projectID) - return projectArn, nil + return projectARN, nil } diff --git a/internal/service/devicefarm/network_profile.go b/internal/service/devicefarm/network_profile.go index fd6e44b4bb2..f01f959af9b 100644 --- a/internal/service/devicefarm/network_profile.go +++ b/internal/service/devicefarm/network_profile.go @@ -207,7 +207,7 @@ func resourceNetworkProfileRead(ctx context.Context, d *schema.ResourceData, met d.Set("uplink_loss_percent", project.UplinkLossPercent) d.Set(names.AttrType, project.Type) - projectArn, err := decodeProjectARN(arn, "networkprofile", meta) + projectArn, err := decodeProjectARN(ctx, meta.(*conns.AWSClient), arn, "networkprofile") if err != nil { return sdkdiag.AppendErrorf(diags, "decoding project_arn (%s): %s", arn, err) } diff --git a/internal/service/devicefarm/upload.go b/internal/service/devicefarm/upload.go index bdd448610a8..67afa7bc385 100644 --- a/internal/service/devicefarm/upload.go +++ b/internal/service/devicefarm/upload.go @@ -128,7 +128,7 @@ func resourceUploadRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set("metadata", upload.Metadata) d.Set(names.AttrARN, arn) - projectArn, err := decodeProjectARN(arn, "upload", meta) + projectArn, err := decodeProjectARN(ctx, meta.(*conns.AWSClient), arn, "upload") if err != nil { return sdkdiag.AppendErrorf(diags, "decoding project_arn (%s): %s", arn, err) } diff --git a/internal/service/directconnect/connection.go b/internal/service/directconnect/connection.go index 9d039ec3d4b..069d819480c 100644 --- a/internal/service/directconnect/connection.go +++ b/internal/service/directconnect/connection.go @@ -281,7 +281,7 @@ func resourceConnectionRead(ctx context.Context, d *schema.ResourceData, meta in } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: aws.ToString(connection.Region), Service: "directconnect", AccountID: aws.ToString(connection.OwnerAccount), diff --git a/internal/service/directconnect/connection_data_source.go b/internal/service/directconnect/connection_data_source.go index 21fe032ab55..f0ad7c309e2 100644 --- a/internal/service/directconnect/connection_data_source.go +++ b/internal/service/directconnect/connection_data_source.go @@ -85,7 +85,7 @@ func dataSourceConnectionRead(ctx context.Context, d *schema.ResourceData, meta d.SetId(aws.ToString(connection.ConnectionId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: aws.ToString(connection.Region), Service: "directconnect", AccountID: aws.ToString(connection.OwnerAccount), diff --git a/internal/service/directconnect/hosted_private_virtual_interface.go b/internal/service/directconnect/hosted_private_virtual_interface.go index 68ff4098555..cbd0c6a31c9 100644 --- a/internal/service/directconnect/hosted_private_virtual_interface.go +++ b/internal/service/directconnect/hosted_private_virtual_interface.go @@ -187,7 +187,7 @@ func resourceHostedPrivateVirtualInterfaceRead(ctx context.Context, d *schema.Re d.Set("amazon_address", vif.AmazonAddress) d.Set("amazon_side_asn", flex.Int64ToStringValue(vif.AmazonSideAsn)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "directconnect", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/directconnect/hosted_private_virtual_interface_accepter.go b/internal/service/directconnect/hosted_private_virtual_interface_accepter.go index 824d512899e..31c191ded2d 100644 --- a/internal/service/directconnect/hosted_private_virtual_interface_accepter.go +++ b/internal/service/directconnect/hosted_private_virtual_interface_accepter.go @@ -97,7 +97,7 @@ func resourceHostedPrivateVirtualInterfaceAccepterCreate(ctx context.Context, d d.SetId(vifID) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "directconnect", AccountID: meta.(*conns.AWSClient).AccountID, @@ -170,7 +170,7 @@ func resourceHostedPrivateVirtualInterfaceAccepterImport(ctx context.Context, d } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "directconnect", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/directconnect/hosted_public_virtual_interface.go b/internal/service/directconnect/hosted_public_virtual_interface.go index be7c1b4f817..769931e386f 100644 --- a/internal/service/directconnect/hosted_public_virtual_interface.go +++ b/internal/service/directconnect/hosted_public_virtual_interface.go @@ -184,7 +184,7 @@ func resourceHostedPublicVirtualInterfaceRead(ctx context.Context, d *schema.Res d.Set("amazon_address", vif.AmazonAddress) d.Set("amazon_side_asn", strconv.FormatInt(aws.ToInt64(vif.AmazonSideAsn), 10)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "directconnect", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/directconnect/hosted_public_virtual_interface_accepter.go b/internal/service/directconnect/hosted_public_virtual_interface_accepter.go index e4ac14b07d9..40955116f10 100644 --- a/internal/service/directconnect/hosted_public_virtual_interface_accepter.go +++ b/internal/service/directconnect/hosted_public_virtual_interface_accepter.go @@ -77,7 +77,7 @@ func resourceHostedPublicVirtualInterfaceAccepterCreate(ctx context.Context, d * d.SetId(vifID) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "directconnect", AccountID: meta.(*conns.AWSClient).AccountID, @@ -148,7 +148,7 @@ func resourceHostedPublicVirtualInterfaceAccepterImport(ctx context.Context, d * } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "directconnect", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/directconnect/hosted_transit_virtual_interface.go b/internal/service/directconnect/hosted_transit_virtual_interface.go index 4899b4fd640..2929b0d0bbe 100644 --- a/internal/service/directconnect/hosted_transit_virtual_interface.go +++ b/internal/service/directconnect/hosted_transit_virtual_interface.go @@ -183,7 +183,7 @@ func resourceHostedTransitVirtualInterfaceRead(ctx context.Context, d *schema.Re d.Set("amazon_address", vif.AmazonAddress) d.Set("amazon_side_asn", flex.Int64ToStringValue(vif.AmazonSideAsn)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "directconnect", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/directconnect/hosted_transit_virtual_interface_accepter.go b/internal/service/directconnect/hosted_transit_virtual_interface_accepter.go index c4d92244196..ab660b5f8f2 100644 --- a/internal/service/directconnect/hosted_transit_virtual_interface_accepter.go +++ b/internal/service/directconnect/hosted_transit_virtual_interface_accepter.go @@ -83,7 +83,7 @@ func resourceHostedTransitVirtualInterfaceAccepterCreate(ctx context.Context, d d.SetId(vifID) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "directconnect", AccountID: meta.(*conns.AWSClient).AccountID, @@ -155,7 +155,7 @@ func resourceHostedTransitVirtualInterfaceAccepterImport(ctx context.Context, d } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "directconnect", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/directconnect/lag.go b/internal/service/directconnect/lag.go index 36265c03a3f..01571680c4f 100644 --- a/internal/service/directconnect/lag.go +++ b/internal/service/directconnect/lag.go @@ -156,7 +156,7 @@ func resourceLagRead(ctx context.Context, d *schema.ResourceData, meta interface } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: aws.ToString(lag.Region), Service: "directconnect", AccountID: aws.ToString(lag.OwnerAccount), diff --git a/internal/service/directconnect/private_virtual_interface.go b/internal/service/directconnect/private_virtual_interface.go index a5089cbca03..ef1ea10656d 100644 --- a/internal/service/directconnect/private_virtual_interface.go +++ b/internal/service/directconnect/private_virtual_interface.go @@ -209,7 +209,7 @@ func resourcePrivateVirtualInterfaceRead(ctx context.Context, d *schema.Resource d.Set("amazon_address", vif.AmazonAddress) d.Set("amazon_side_asn", strconv.FormatInt(aws.ToInt64(vif.AmazonSideAsn), 10)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "directconnect", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/directconnect/public_virtual_interface.go b/internal/service/directconnect/public_virtual_interface.go index 13614817840..99ec2d81894 100644 --- a/internal/service/directconnect/public_virtual_interface.go +++ b/internal/service/directconnect/public_virtual_interface.go @@ -187,7 +187,7 @@ func resourcePublicVirtualInterfaceRead(ctx context.Context, d *schema.ResourceD d.Set("amazon_address", vif.AmazonAddress) d.Set("amazon_side_asn", strconv.FormatInt(aws.ToInt64(vif.AmazonSideAsn), 10)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "directconnect", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/directconnect/transit_virtual_interface.go b/internal/service/directconnect/transit_virtual_interface.go index f5c04c03443..1a8030cb737 100644 --- a/internal/service/directconnect/transit_virtual_interface.go +++ b/internal/service/directconnect/transit_virtual_interface.go @@ -195,7 +195,7 @@ func resourceTransitVirtualInterfaceRead(ctx context.Context, d *schema.Resource d.Set("amazon_address", vif.AmazonAddress) d.Set("amazon_side_asn", strconv.FormatInt(aws.ToInt64(vif.AmazonSideAsn), 10)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "directconnect", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/dms/event_subscription.go b/internal/service/dms/event_subscription.go index 48e100e6498..5d97aa47f69 100644 --- a/internal/service/dms/event_subscription.go +++ b/internal/service/dms/event_subscription.go @@ -146,7 +146,7 @@ func resourceEventSubscriptionRead(ctx context.Context, d *schema.ResourceData, } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "dms", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/dms/replication_subnet_group.go b/internal/service/dms/replication_subnet_group.go index 6094f6376e9..43d28747a0d 100644 --- a/internal/service/dms/replication_subnet_group.go +++ b/internal/service/dms/replication_subnet_group.go @@ -115,7 +115,7 @@ func resourceReplicationSubnetGroupRead(ctx context.Context, d *schema.ResourceD // The AWS API for DMS subnet groups does not return the ARN which is required to // retrieve tags. This ARN can be built. arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "dms", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/dms/replication_subnet_group_data_source.go b/internal/service/dms/replication_subnet_group_data_source.go index aed5e9d8059..1eb9b010092 100644 --- a/internal/service/dms/replication_subnet_group_data_source.go +++ b/internal/service/dms/replication_subnet_group_data_source.go @@ -69,7 +69,7 @@ func dataSourceReplicationSubnetGroupRead(ctx context.Context, d *schema.Resourc d.SetId(aws.ToString(group.ReplicationSubnetGroupIdentifier)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "dms", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/dynamodb/table_replica.go b/internal/service/dynamodb/table_replica.go index c2e40437589..1dfae612d14 100644 --- a/internal/service/dynamodb/table_replica.go +++ b/internal/service/dynamodb/table_replica.go @@ -207,7 +207,7 @@ func resourceTableReplicaRead(ctx context.Context, d *schema.ResourceData, meta globalTableARN := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: mainRegion, Resource: fmt.Sprintf("table/%s", tableName), Service: "dynamodb", diff --git a/internal/service/ec2/ebs_snapshot.go b/internal/service/ec2/ebs_snapshot.go index 4d320a56cf9..e12e5e6a7e8 100644 --- a/internal/service/ec2/ebs_snapshot.go +++ b/internal/service/ec2/ebs_snapshot.go @@ -190,7 +190,7 @@ func resourceEBSSnapshotRead(ctx context.Context, d *schema.ResourceData, meta i } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("snapshot/%s", d.Id()), diff --git a/internal/service/ec2/ebs_snapshot_data_source.go b/internal/service/ec2/ebs_snapshot_data_source.go index 6c2fe40d352..0e337fb5478 100644 --- a/internal/service/ec2/ebs_snapshot_data_source.go +++ b/internal/service/ec2/ebs_snapshot_data_source.go @@ -165,7 +165,7 @@ func dataSourceEBSSnapshotRead(ctx context.Context, d *schema.ResourceData, meta d.SetId(aws.ToString(snapshot.SnapshotId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("snapshot/%s", d.Id()), diff --git a/internal/service/ec2/ebs_snapshot_import.go b/internal/service/ec2/ebs_snapshot_import.go index 3efc43a25fa..5cbc327490d 100644 --- a/internal/service/ec2/ebs_snapshot_import.go +++ b/internal/service/ec2/ebs_snapshot_import.go @@ -287,7 +287,7 @@ func resourceEBSSnapshotImportRead(ctx context.Context, d *schema.ResourceData, } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("snapshot/%s", d.Id()), diff --git a/internal/service/ec2/ebs_volume.go b/internal/service/ec2/ebs_volume.go index dc0c78c0e95..693d6adb36b 100644 --- a/internal/service/ec2/ebs_volume.go +++ b/internal/service/ec2/ebs_volume.go @@ -204,7 +204,7 @@ func resourceEBSVolumeRead(ctx context.Context, d *schema.ResourceData, meta int } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/ebs_volume_data_source.go b/internal/service/ec2/ebs_volume_data_source.go index cf25ee99bc4..31a120d8575 100644 --- a/internal/service/ec2/ebs_volume_data_source.go +++ b/internal/service/ec2/ebs_volume_data_source.go @@ -135,7 +135,7 @@ func dataSourceEBSVolumeRead(ctx context.Context, d *schema.ResourceData, meta i d.SetId(aws.ToString(volume.VolumeId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/ec2_ami.go b/internal/service/ec2/ec2_ami.go index d5f53ff85dd..b91a38c73a5 100644 --- a/internal/service/ec2/ec2_ami.go +++ b/internal/service/ec2/ec2_ami.go @@ -422,7 +422,7 @@ func resourceAMIRead(ctx context.Context, d *schema.ResourceData, meta interface d.Set("architecture", image.Architecture) imageArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("image/%s", d.Id()), Service: names.EC2, diff --git a/internal/service/ec2/ec2_ami_data_source.go b/internal/service/ec2/ec2_ami_data_source.go index 06040243f19..faa18e56137 100644 --- a/internal/service/ec2/ec2_ami_data_source.go +++ b/internal/service/ec2/ec2_ami_data_source.go @@ -294,7 +294,7 @@ func dataSourceAMIRead(ctx context.Context, d *schema.ResourceData, meta interfa d.SetId(aws.ToString(image.ImageId)) d.Set("architecture", image.Architecture) imageArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: names.EC2, Resource: fmt.Sprintf("image/%s", d.Id()), diff --git a/internal/service/ec2/ec2_eip.go b/internal/service/ec2/ec2_eip.go index e950b537a00..69df5eeec91 100644 --- a/internal/service/ec2/ec2_eip.go +++ b/internal/service/ec2/ec2_eip.go @@ -12,7 +12,6 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/aws/aws-sdk-go-v2/service/ec2/types" "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" @@ -246,7 +245,7 @@ func resourceEIPRead(ctx context.Context, d *schema.ResourceData, meta interface address := outputRaw.(*types.Address) allocationID := aws.ToString(address.AllocationId) d.Set("allocation_id", allocationID) - d.Set(names.AttrARN, eipARN(meta.(*conns.AWSClient), allocationID)) + d.Set(names.AttrARN, eipARN(ctx, meta.(*conns.AWSClient), allocationID)) d.Set(names.AttrAssociationID, address.AssociationId) d.Set("carrier_ip", address.CarrierIp) d.Set("customer_owned_ip", address.CustomerOwnedIp) @@ -444,14 +443,8 @@ func disassociateEIP(ctx context.Context, conn *ec2.Client, associationID string return nil } -func eipARN(c *conns.AWSClient, allocationID string) string { - return arn.ARN{ - Partition: c.Partition, - Service: names.EC2, - Region: c.Region, - AccountID: c.AccountID, - Resource: "elastic-ip/" + allocationID, - }.String() +func eipARN(ctx context.Context, c *conns.AWSClient, allocationID string) string { + return c.RegionalARN(ctx, names.EC2, "elastic-ip/"+allocationID) } func findIPAMPoolAllocationsForEIP(ctx context.Context, conn *ec2.Client, ipamPoolID, eipAllocationID string) ([]types.IpamPoolAllocation, error) { diff --git a/internal/service/ec2/ec2_eip_data_source.go b/internal/service/ec2/ec2_eip_data_source.go index f4ac551c628..b2a6cb99b4a 100644 --- a/internal/service/ec2/ec2_eip_data_source.go +++ b/internal/service/ec2/ec2_eip_data_source.go @@ -144,7 +144,7 @@ func dataSourceEIPRead(ctx context.Context, d *schema.ResourceData, meta interfa if eip.Domain == types.DomainTypeVpc { allocationID := aws.ToString(eip.AllocationId) d.SetId(allocationID) - d.Set(names.AttrARN, eipARN(meta.(*conns.AWSClient), allocationID)) + d.Set(names.AttrARN, eipARN(ctx, meta.(*conns.AWSClient), allocationID)) addressAttr, err := findEIPDomainNameAttributeByAllocationID(ctx, conn, d.Id()) diff --git a/internal/service/ec2/ec2_fleet.go b/internal/service/ec2/ec2_fleet.go index 28091f1d53e..425faedc1c8 100644 --- a/internal/service/ec2/ec2_fleet.go +++ b/internal/service/ec2/ec2_fleet.go @@ -807,7 +807,7 @@ func resourceFleetRead(ctx context.Context, d *schema.ResourceData, meta interfa } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/ec2_host.go b/internal/service/ec2/ec2_host.go index adbbf92dbca..400101e1f95 100644 --- a/internal/service/ec2/ec2_host.go +++ b/internal/service/ec2/ec2_host.go @@ -163,7 +163,7 @@ func resourceHostRead(ctx context.Context, d *schema.ResourceData, meta interfac } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: aws.ToString(host.OwnerId), diff --git a/internal/service/ec2/ec2_host_data_source.go b/internal/service/ec2/ec2_host_data_source.go index 9965c33814b..67a677a5c37 100644 --- a/internal/service/ec2/ec2_host_data_source.go +++ b/internal/service/ec2/ec2_host_data_source.go @@ -116,7 +116,7 @@ func dataSourceHostRead(ctx context.Context, d *schema.ResourceData, meta interf d.SetId(aws.ToString(host.HostId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: aws.ToString(host.OwnerId), diff --git a/internal/service/ec2/ec2_instance.go b/internal/service/ec2/ec2_instance.go index 064beb032c9..fb57c559e20 100644 --- a/internal/service/ec2/ec2_instance.go +++ b/internal/service/ec2/ec2_instance.go @@ -1361,7 +1361,7 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte // ARN arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: names.EC2, AccountID: meta.(*conns.AWSClient).AccountID, @@ -1375,10 +1375,10 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte Attribute: awstypes.InstanceAttributeNameDisableApiStop, InstanceId: aws.String(d.Id()), }) - if err != nil && !errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if err != nil && !errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return sdkdiag.AppendErrorf(diags, "getting attribute (%s): %s", awstypes.InstanceAttributeNameDisableApiStop, err) } - if !errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if !errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { d.Set("disable_api_stop", attr.DisableApiStop.Value) } } diff --git a/internal/service/ec2/ec2_instance_data_source.go b/internal/service/ec2/ec2_instance_data_source.go index b369075d829..0c427dc2116 100644 --- a/internal/service/ec2/ec2_instance_data_source.go +++ b/internal/service/ec2/ec2_instance_data_source.go @@ -452,7 +452,7 @@ func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta in // ARN arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: names.EC2, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/ec2_key_pair.go b/internal/service/ec2/ec2_key_pair.go index 160640fdd29..41518a92533 100644 --- a/internal/service/ec2/ec2_key_pair.go +++ b/internal/service/ec2/ec2_key_pair.go @@ -138,7 +138,7 @@ func resourceKeyPairRead(ctx context.Context, d *schema.ResourceData, meta inter } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/ec2_key_pair_data_source.go b/internal/service/ec2/ec2_key_pair_data_source.go index df6735b1316..aab5de4aa2e 100644 --- a/internal/service/ec2/ec2_key_pair_data_source.go +++ b/internal/service/ec2/ec2_key_pair_data_source.go @@ -101,7 +101,7 @@ func dataSourceKeyPairRead(ctx context.Context, d *schema.ResourceData, meta int d.SetId(aws.ToString(keyPair.KeyPairId)) keyName := aws.ToString(keyPair.KeyName) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ec2", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/ec2_launch_template.go b/internal/service/ec2/ec2_launch_template.go index 7fe7c5b0d1d..2f666722305 100644 --- a/internal/service/ec2/ec2_launch_template.go +++ b/internal/service/ec2/ec2_launch_template.go @@ -1047,7 +1047,7 @@ func resourceLaunchTemplateRead(ctx context.Context, d *schema.ResourceData, met } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/ec2_launch_template_data_source.go b/internal/service/ec2/ec2_launch_template_data_source.go index 796513dc163..0c1f17747c5 100644 --- a/internal/service/ec2/ec2_launch_template_data_source.go +++ b/internal/service/ec2/ec2_launch_template_data_source.go @@ -831,7 +831,7 @@ func dataSourceLaunchTemplateRead(ctx context.Context, d *schema.ResourceData, m } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/ec2_placement_group.go b/internal/service/ec2/ec2_placement_group.go index 004d74e7ee7..2685ba15ed6 100644 --- a/internal/service/ec2/ec2_placement_group.go +++ b/internal/service/ec2/ec2_placement_group.go @@ -139,7 +139,7 @@ func resourcePlacementGroupRead(ctx context.Context, d *schema.ResourceData, met } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/transitgateway_attachment_data_source.go b/internal/service/ec2/transitgateway_attachment_data_source.go index 558de145622..b506172a259 100644 --- a/internal/service/ec2/transitgateway_attachment_data_source.go +++ b/internal/service/ec2/transitgateway_attachment_data_source.go @@ -104,7 +104,7 @@ func dataSourceTransitGatewayAttachmentRead(ctx context.Context, d *schema.Resou resourceOwnerID := aws.ToString(transitGatewayAttachment.ResourceOwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: resourceOwnerID, diff --git a/internal/service/ec2/transitgateway_connect_peer.go b/internal/service/ec2/transitgateway_connect_peer.go index 5cf4900cfd8..bda6d95da0e 100644 --- a/internal/service/ec2/transitgateway_connect_peer.go +++ b/internal/service/ec2/transitgateway_connect_peer.go @@ -178,7 +178,7 @@ func resourceTransitGatewayConnectPeerRead(ctx context.Context, d *schema.Resour } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/transitgateway_connect_peer_data_source.go b/internal/service/ec2/transitgateway_connect_peer_data_source.go index 30dd2017014..dbeaecedb1f 100644 --- a/internal/service/ec2/transitgateway_connect_peer_data_source.go +++ b/internal/service/ec2/transitgateway_connect_peer_data_source.go @@ -103,7 +103,7 @@ func dataSourceTransitGatewayConnectPeerRead(ctx context.Context, d *schema.Reso d.SetId(aws.ToString(transitGatewayConnectPeer.TransitGatewayConnectPeerId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/transitgateway_policy_table.go b/internal/service/ec2/transitgateway_policy_table.go index e994d22b8ed..b549fff7c28 100644 --- a/internal/service/ec2/transitgateway_policy_table.go +++ b/internal/service/ec2/transitgateway_policy_table.go @@ -104,7 +104,7 @@ func resourceTransitGatewayPolicyTableRead(ctx context.Context, d *schema.Resour } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/transitgateway_route_table.go b/internal/service/ec2/transitgateway_route_table.go index 703b4373e85..fc6d6fcf60d 100644 --- a/internal/service/ec2/transitgateway_route_table.go +++ b/internal/service/ec2/transitgateway_route_table.go @@ -107,7 +107,7 @@ func resourceTransitGatewayRouteTableRead(ctx context.Context, d *schema.Resourc } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/transitgateway_route_table_data_source.go b/internal/service/ec2/transitgateway_route_table_data_source.go index 54a6b1b517a..7699212ca41 100644 --- a/internal/service/ec2/transitgateway_route_table_data_source.go +++ b/internal/service/ec2/transitgateway_route_table_data_source.go @@ -86,7 +86,7 @@ func dataSourceTransitGatewayRouteTableRead(ctx context.Context, d *schema.Resou d.SetId(aws.ToString(transitGatewayRouteTable.TransitGatewayRouteTableId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/vpc_.go b/internal/service/ec2/vpc_.go index 198112d79d1..f1779d7bd21 100644 --- a/internal/service/ec2/vpc_.go +++ b/internal/service/ec2/vpc_.go @@ -288,7 +288,7 @@ func resourceVPCRead(ctx context.Context, d *schema.ResourceData, meta interface ownerID := aws.ToString(vpc.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpc_data_source.go b/internal/service/ec2/vpc_data_source.go index 02ebca880d7..929586bf454 100644 --- a/internal/service/ec2/vpc_data_source.go +++ b/internal/service/ec2/vpc_data_source.go @@ -167,7 +167,7 @@ func dataSourceVPCRead(ctx context.Context, d *schema.ResourceData, meta interfa ownerID := aws.String(aws.ToString(vpc.OwnerId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: aws.ToString(ownerID), diff --git a/internal/service/ec2/vpc_dhcp_options.go b/internal/service/ec2/vpc_dhcp_options.go index 3e6e16fa02b..ffe2642be97 100644 --- a/internal/service/ec2/vpc_dhcp_options.go +++ b/internal/service/ec2/vpc_dhcp_options.go @@ -154,7 +154,7 @@ func resourceVPCDHCPOptionsRead(ctx context.Context, d *schema.ResourceData, met ownerID := aws.ToString(opts.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpc_dhcp_options_data_source.go b/internal/service/ec2/vpc_dhcp_options_data_source.go index f1b9a82f7c2..8f174c6a2eb 100644 --- a/internal/service/ec2/vpc_dhcp_options_data_source.go +++ b/internal/service/ec2/vpc_dhcp_options_data_source.go @@ -105,7 +105,7 @@ func dataSourceVPCDHCPOptionsRead(ctx context.Context, d *schema.ResourceData, m ownerID := aws.ToString(opts.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpc_endpoint.go b/internal/service/ec2/vpc_endpoint.go index c33adc75ea8..59ff63618c5 100644 --- a/internal/service/ec2/vpc_endpoint.go +++ b/internal/service/ec2/vpc_endpoint.go @@ -220,7 +220,7 @@ func resourceVPCEndpoint() *schema.Resource { func resourceVPCEndpointCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).EC2Client(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) serviceName := d.Get(names.AttrServiceName).(string) input := &ec2.CreateVpcEndpointInput{ @@ -331,7 +331,7 @@ func resourceVPCEndpointRead(ctx context.Context, d *schema.ResourceData, meta i } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: aws.ToString(vpce.OwnerId), diff --git a/internal/service/ec2/vpc_endpoint_data_source.go b/internal/service/ec2/vpc_endpoint_data_source.go index bf4acd5c73f..673dabb0579 100644 --- a/internal/service/ec2/vpc_endpoint_data_source.go +++ b/internal/service/ec2/vpc_endpoint_data_source.go @@ -186,7 +186,7 @@ func dataSourceVPCEndpointRead(ctx context.Context, d *schema.ResourceData, meta d.SetId(aws.ToString(vpce.VpcEndpointId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: aws.ToString(vpce.OwnerId), diff --git a/internal/service/ec2/vpc_endpoint_service.go b/internal/service/ec2/vpc_endpoint_service.go index cf34c22d6ab..84857044f31 100644 --- a/internal/service/ec2/vpc_endpoint_service.go +++ b/internal/service/ec2/vpc_endpoint_service.go @@ -223,7 +223,7 @@ func resourceVPCEndpointServiceRead(ctx context.Context, d *schema.ResourceData, d.Set("acceptance_required", svcCfg.AcceptanceRequired) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/vpc_endpoint_service_data_source.go b/internal/service/ec2/vpc_endpoint_service_data_source.go index e8b0de8592b..34a46a402e3 100644 --- a/internal/service/ec2/vpc_endpoint_service_data_source.go +++ b/internal/service/ec2/vpc_endpoint_service_data_source.go @@ -179,7 +179,7 @@ func dataSourceVPCEndpointServiceRead(ctx context.Context, d *schema.ResourceDat d.Set("acceptance_required", sd.AcceptanceRequired) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/vpc_flow_log.go b/internal/service/ec2/vpc_flow_log.go index 2adec49a6ae..bc810a3afcb 100644 --- a/internal/service/ec2/vpc_flow_log.go +++ b/internal/service/ec2/vpc_flow_log.go @@ -282,7 +282,7 @@ func resourceLogFlowRead(ctx context.Context, d *schema.ResourceData, meta inter } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/vpc_internet_gateway.go b/internal/service/ec2/vpc_internet_gateway.go index 997b504c8f9..9530b8c1af3 100644 --- a/internal/service/ec2/vpc_internet_gateway.go +++ b/internal/service/ec2/vpc_internet_gateway.go @@ -114,7 +114,7 @@ func resourceInternetGatewayRead(ctx context.Context, d *schema.ResourceData, me ownerID := aws.ToString(ig.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpc_internet_gateway_data_source.go b/internal/service/ec2/vpc_internet_gateway_data_source.go index 5936b42db21..23ffe75d169 100644 --- a/internal/service/ec2/vpc_internet_gateway_data_source.go +++ b/internal/service/ec2/vpc_internet_gateway_data_source.go @@ -100,7 +100,7 @@ func dataSourceInternetGatewayRead(ctx context.Context, d *schema.ResourceData, ownerID := aws.ToString(igw.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpc_network_acl.go b/internal/service/ec2/vpc_network_acl.go index 9fa62b3a92f..699160142b7 100644 --- a/internal/service/ec2/vpc_network_acl.go +++ b/internal/service/ec2/vpc_network_acl.go @@ -214,7 +214,7 @@ func resourceNetworkACLRead(ctx context.Context, d *schema.ResourceData, meta in ownerID := aws.ToString(nacl.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpc_network_interface.go b/internal/service/ec2/vpc_network_interface.go index 317e39a4b5e..1a832a3c7be 100644 --- a/internal/service/ec2/vpc_network_interface.go +++ b/internal/service/ec2/vpc_network_interface.go @@ -511,7 +511,7 @@ func resourceNetworkInterfaceRead(ctx context.Context, d *schema.ResourceData, m ownerID := aws.ToString(eni.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ec2", Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpc_network_interface_data_source.go b/internal/service/ec2/vpc_network_interface_data_source.go index fdd0a5a76cb..c8d1fdcaee1 100644 --- a/internal/service/ec2/vpc_network_interface_data_source.go +++ b/internal/service/ec2/vpc_network_interface_data_source.go @@ -189,7 +189,7 @@ func dataSourceNetworkInterfaceRead(ctx context.Context, d *schema.ResourceData, d.SetId(aws.ToString(eni.NetworkInterfaceId)) ownerID := aws.ToString(eni.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ec2", Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpc_route_table.go b/internal/service/ec2/vpc_route_table.go index 75db8524787..891535c7572 100644 --- a/internal/service/ec2/vpc_route_table.go +++ b/internal/service/ec2/vpc_route_table.go @@ -234,7 +234,7 @@ func resourceRouteTableRead(ctx context.Context, d *schema.ResourceData, meta in routeTable := outputRaw.(*awstypes.RouteTable) ownerID := aws.ToString(routeTable.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpc_route_table_data_source.go b/internal/service/ec2/vpc_route_table_data_source.go index 70cbf4964f0..532a8cdbd0a 100644 --- a/internal/service/ec2/vpc_route_table_data_source.go +++ b/internal/service/ec2/vpc_route_table_data_source.go @@ -234,7 +234,7 @@ func dataSourceRouteTableRead(ctx context.Context, d *schema.ResourceData, meta ownerID := aws.ToString(rt.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpc_security_group.go b/internal/service/ec2/vpc_security_group.go index 044afe933a2..3d736a5ccc0 100644 --- a/internal/service/ec2/vpc_security_group.go +++ b/internal/service/ec2/vpc_security_group.go @@ -297,7 +297,7 @@ func resourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, meta ownerID := aws.ToString(sg.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpc_security_group_data_source.go b/internal/service/ec2/vpc_security_group_data_source.go index eb4aa42c7fd..ff68375475c 100644 --- a/internal/service/ec2/vpc_security_group_data_source.go +++ b/internal/service/ec2/vpc_security_group_data_source.go @@ -101,7 +101,7 @@ func dataSourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, me d.SetId(aws.ToString(sg.GroupId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: *sg.OwnerId, diff --git a/internal/service/ec2/vpc_security_group_ingress_rule.go b/internal/service/ec2/vpc_security_group_ingress_rule.go index 1d3452cb181..ffecce97926 100644 --- a/internal/service/ec2/vpc_security_group_ingress_rule.go +++ b/internal/service/ec2/vpc_security_group_ingress_rule.go @@ -413,8 +413,8 @@ func (r *securityGroupRuleResource) ConfigValidators(context.Context) []resource } } -func (r *securityGroupRuleResource) securityGroupRuleARN(_ context.Context, id string) types.String { - return types.StringValue(r.RegionalARN(names.EC2, fmt.Sprintf("security-group-rule/%s", id))) +func (r *securityGroupRuleResource) securityGroupRuleARN(ctx context.Context, id string) types.String { + return types.StringValue(r.Meta().RegionalARN(ctx, names.EC2, fmt.Sprintf("security-group-rule/%s", id))) } func flattenReferencedSecurityGroup(ctx context.Context, apiObject *awstypes.ReferencedSecurityGroup, accountID string) types.String { diff --git a/internal/service/ec2/vpc_security_group_rule_data_source.go b/internal/service/ec2/vpc_security_group_rule_data_source.go index 175bbf5e0bd..260b6f4b678 100644 --- a/internal/service/ec2/vpc_security_group_rule_data_source.go +++ b/internal/service/ec2/vpc_security_group_rule_data_source.go @@ -131,8 +131,8 @@ func (d *securityGroupRuleDataSource) Read(ctx context.Context, request datasour response.Diagnostics.Append(response.State.Set(ctx, &data)...) } -func (d *securityGroupRuleDataSource) securityGroupRuleARN(_ context.Context, id string) types.String { - return types.StringValue(d.RegionalARN(names.EC2, fmt.Sprintf("security-group-rule/%s", id))) +func (d *securityGroupRuleDataSource) securityGroupRuleARN(ctx context.Context, id string) types.String { + return types.StringValue(d.Meta().RegionalARN(ctx, names.EC2, fmt.Sprintf("security-group-rule/%s", id))) } type securityGroupRuleDataSourceModel struct { diff --git a/internal/service/ec2/vpc_security_groups_data_source.go b/internal/service/ec2/vpc_security_groups_data_source.go index 73c71346b8f..630d8e1486f 100644 --- a/internal/service/ec2/vpc_security_groups_data_source.go +++ b/internal/service/ec2/vpc_security_groups_data_source.go @@ -79,7 +79,7 @@ func dataSourceSecurityGroupsRead(ctx context.Context, d *schema.ResourceData, m for _, v := range output { arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: aws.ToString(v.OwnerId), diff --git a/internal/service/ec2/vpc_test.go b/internal/service/ec2/vpc_test.go index 4cc15ae8752..2a14439c450 100644 --- a/internal/service/ec2/vpc_test.go +++ b/internal/service/ec2/vpc_test.go @@ -12,6 +12,7 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" awstypes "github.com/aws/aws-sdk-go-v2/service/ec2/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -407,7 +408,7 @@ func TestAccVPC_enableNetworkAddressUsageMetrics(t *testing.T) { rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.EC2), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckVPCDestroy(ctx), diff --git a/internal/service/ec2/vpc_traffic_mirror_filter.go b/internal/service/ec2/vpc_traffic_mirror_filter.go index 545f89cb773..ccb2f9b1bc8 100644 --- a/internal/service/ec2/vpc_traffic_mirror_filter.go +++ b/internal/service/ec2/vpc_traffic_mirror_filter.go @@ -123,7 +123,7 @@ func resourceTrafficMirrorFilterRead(ctx context.Context, d *schema.ResourceData } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ec2", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/vpc_traffic_mirror_filter_rule.go b/internal/service/ec2/vpc_traffic_mirror_filter_rule.go index 3e37a96421e..62ac5c27649 100644 --- a/internal/service/ec2/vpc_traffic_mirror_filter_rule.go +++ b/internal/service/ec2/vpc_traffic_mirror_filter_rule.go @@ -180,7 +180,7 @@ func resourceTrafficMirrorFilterRuleRead(ctx context.Context, d *schema.Resource } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ec2", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/vpc_traffic_mirror_session.go b/internal/service/ec2/vpc_traffic_mirror_session.go index 61cafc04b22..f995419645e 100644 --- a/internal/service/ec2/vpc_traffic_mirror_session.go +++ b/internal/service/ec2/vpc_traffic_mirror_session.go @@ -145,7 +145,7 @@ func resourceTrafficMirrorSessionRead(ctx context.Context, d *schema.ResourceDat ownerID := aws.ToString(session.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ec2", Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpc_traffic_mirror_target.go b/internal/service/ec2/vpc_traffic_mirror_target.go index 402b7b6daeb..2989dffa531 100644 --- a/internal/service/ec2/vpc_traffic_mirror_target.go +++ b/internal/service/ec2/vpc_traffic_mirror_target.go @@ -145,7 +145,7 @@ func resourceTrafficMirrorTargetRead(ctx context.Context, d *schema.ResourceData ownerID := aws.ToString(target.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ec2/vpnclient_endpoint.go b/internal/service/ec2/vpnclient_endpoint.go index 52a49d01535..3b6ba76279c 100644 --- a/internal/service/ec2/vpnclient_endpoint.go +++ b/internal/service/ec2/vpnclient_endpoint.go @@ -313,7 +313,7 @@ func resourceClientVPNEndpointRead(ctx context.Context, d *schema.ResourceData, } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/vpnclient_endpoint_data_source.go b/internal/service/ec2/vpnclient_endpoint_data_source.go index 9ca982684ec..8e88dad91a5 100644 --- a/internal/service/ec2/vpnclient_endpoint_data_source.go +++ b/internal/service/ec2/vpnclient_endpoint_data_source.go @@ -212,7 +212,7 @@ func dataSourceClientVPNEndpointRead(ctx context.Context, d *schema.ResourceData d.SetId(aws.ToString(ep.ClientVpnEndpointId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/vpnsite_connection.go b/internal/service/ec2/vpnsite_connection.go index 88b19dd6a3c..5e5936d6e2a 100644 --- a/internal/service/ec2/vpnsite_connection.go +++ b/internal/service/ec2/vpnsite_connection.go @@ -729,7 +729,7 @@ func resourceVPNConnectionRead(ctx context.Context, d *schema.ResourceData, meta } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/vpnsite_customer_gateway.go b/internal/service/ec2/vpnsite_customer_gateway.go index fa1e7262d42..5e96bf56527 100644 --- a/internal/service/ec2/vpnsite_customer_gateway.go +++ b/internal/service/ec2/vpnsite_customer_gateway.go @@ -164,7 +164,7 @@ func resourceCustomerGatewayRead(ctx context.Context, d *schema.ResourceData, me } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/vpnsite_customer_gateway_data_source.go b/internal/service/ec2/vpnsite_customer_gateway_data_source.go index 8039df3803b..b1eeee18d11 100644 --- a/internal/service/ec2/vpnsite_customer_gateway_data_source.go +++ b/internal/service/ec2/vpnsite_customer_gateway_data_source.go @@ -95,7 +95,7 @@ func dataSourceCustomerGatewayRead(ctx context.Context, d *schema.ResourceData, d.SetId(aws.ToString(cgw.CustomerGatewayId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/vpnsite_gateway.go b/internal/service/ec2/vpnsite_gateway.go index fc115d4a0e2..b72acdb4b32 100644 --- a/internal/service/ec2/vpnsite_gateway.go +++ b/internal/service/ec2/vpnsite_gateway.go @@ -126,7 +126,7 @@ func resourceVPNGatewayRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("amazon_side_asn", flex.Int64ToStringValue(vpnGateway.AmazonSideAsn)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/vpnsite_gateway_data_source.go b/internal/service/ec2/vpnsite_gateway_data_source.go index 7967a37cf33..4535fd23e2c 100644 --- a/internal/service/ec2/vpnsite_gateway_data_source.go +++ b/internal/service/ec2/vpnsite_gateway_data_source.go @@ -121,7 +121,7 @@ func dataSourceVPNGatewayRead(ctx context.Context, d *schema.ResourceData, meta d.Set("amazon_side_asn", strconv.FormatInt(aws.ToInt64(vgw.AmazonSideAsn), 10)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ec2/wavelength_carrier_gateway.go b/internal/service/ec2/wavelength_carrier_gateway.go index aa08a339d2f..86c32185725 100644 --- a/internal/service/ec2/wavelength_carrier_gateway.go +++ b/internal/service/ec2/wavelength_carrier_gateway.go @@ -103,7 +103,7 @@ func resourceCarrierGatewayRead(ctx context.Context, d *schema.ResourceData, met ownerID := aws.ToString(carrierGateway.OwnerId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.EC2, Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/ecr/repository.go b/internal/service/ecr/repository.go index 6a32373808e..9f22b2c97da 100644 --- a/internal/service/ecr/repository.go +++ b/internal/service/ecr/repository.go @@ -136,7 +136,7 @@ func resourceRepositoryCreate(ctx context.Context, d *schema.ResourceData, meta output, err := conn.CreateRepository(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { input.Tags = nil output, err = conn.CreateRepository(ctx, input) @@ -153,7 +153,7 @@ func resourceRepositoryCreate(ctx context.Context, d *schema.ResourceData, meta err := createTags(ctx, conn, aws.ToString(output.Repository.RepositoryArn), tags) // If default tags only, continue. Otherwise, error. - if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return append(diags, resourceRepositoryRead(ctx, d, meta)...) } diff --git a/internal/service/ecs/account_setting_default.go b/internal/service/ecs/account_setting_default.go index 113bc1cf67e..8fdabc2cddc 100644 --- a/internal/service/ecs/account_setting_default.go +++ b/internal/service/ecs/account_setting_default.go @@ -139,7 +139,7 @@ func resourceAccountSettingDefaultDelete(ctx context.Context, d *schema.Resource func resourceAccountSettingDefaultImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { d.Set(names.AttrName, d.Id()) d.SetId(arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, Service: names.ECSEndpointID, diff --git a/internal/service/ecs/capacity_provider.go b/internal/service/ecs/capacity_provider.go index 9affea997d6..daf72621f7f 100644 --- a/internal/service/ecs/capacity_provider.go +++ b/internal/service/ecs/capacity_provider.go @@ -128,7 +128,7 @@ func resourceCapacityProvider() *schema.Resource { func resourceCapacityProviderCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ECSClient(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) name := d.Get(names.AttrName).(string) input := ecs.CreateCapacityProviderInput{ @@ -256,7 +256,7 @@ func resourceCapacityProviderDelete(ctx context.Context, d *schema.ResourceData, func resourceCapacityProviderImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { d.Set(names.AttrName, d.Id()) d.SetId(arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, Service: "ecs", @@ -267,7 +267,7 @@ func resourceCapacityProviderImport(ctx context.Context, d *schema.ResourceData, } func partitionFromConn(conn *ecs.Client) string { - return names.PartitionForRegion(conn.Options().Region) + return names.PartitionForRegion(conn.Options().Region).ID() } func findCapacityProvider(ctx context.Context, conn *ecs.Client, input *ecs.DescribeCapacityProvidersInput) (*awstypes.CapacityProvider, error) { diff --git a/internal/service/ecs/cluster.go b/internal/service/ecs/cluster.go index 28a1f6040a2..db25c78e3e3 100644 --- a/internal/service/ecs/cluster.go +++ b/internal/service/ecs/cluster.go @@ -166,7 +166,7 @@ func resourceCluster() *schema.Resource { func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ECSClient(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) clusterName := d.Get(names.AttrName).(string) input := &ecs.CreateClusterInput{ @@ -332,7 +332,7 @@ func resourceClusterDelete(ctx context.Context, d *schema.ResourceData, meta int func resourceClusterImport(ctx context.Context, d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) { d.Set(names.AttrName, d.Id()) d.SetId(arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, Service: "ecs", diff --git a/internal/service/ecs/service.go b/internal/service/ecs/service.go index 43a817364fe..67cbdf69861 100644 --- a/internal/service/ecs/service.go +++ b/internal/service/ecs/service.go @@ -1126,7 +1126,7 @@ func resourceService() *schema.Resource { func resourceServiceCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ECSClient(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) deploymentController := expandDeploymentController(d.Get("deployment_controller").([]interface{})) deploymentMinimumHealthyPercent := d.Get("deployment_minimum_healthy_percent").(int) @@ -1632,7 +1632,7 @@ func resourceServiceImport(ctx context.Context, d *schema.ResourceData, meta int d.SetId(name) clusterArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "ecs", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ecs/task_definition.go b/internal/service/ecs/task_definition.go index 606b94202fd..78ee4154a16 100644 --- a/internal/service/ecs/task_definition.go +++ b/internal/service/ecs/task_definition.go @@ -463,7 +463,7 @@ func resourceTaskDefinition() *schema.Resource { func resourceTaskDefinitionCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ECSClient(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) definitions, err := expandContainerDefinitions(d.Get("container_definitions").(string)) if err != nil { diff --git a/internal/service/ecs/task_definition_test.go b/internal/service/ecs/task_definition_test.go index 536f726714b..23b4803ff0f 100644 --- a/internal/service/ecs/task_definition_test.go +++ b/internal/service/ecs/task_definition_test.go @@ -11,6 +11,7 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" awstypes "github.com/aws/aws-sdk-go-v2/service/ecs/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -307,7 +308,7 @@ func TestAccECSTaskDefinition_runtimePlatform(t *testing.T) { resourceName := "aws_ecs_task_definition.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartition(t, names.StandardPartitionID) }, // runtime platform not support on GovCloud + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartition(t, endpoints.AwsPartitionID) }, // runtime platform not support on GovCloud ErrorCheck: acctest.ErrorCheck(t, names.ECSServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckTaskDefinitionDestroy(ctx), @@ -341,7 +342,7 @@ func TestAccECSTaskDefinition_Fargate_runtimePlatform(t *testing.T) { resourceName := "aws_ecs_task_definition.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartition(t, names.StandardPartitionID) }, // runtime platform not support on GovCloud + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartition(t, endpoints.AwsPartitionID) }, // runtime platform not support on GovCloud ErrorCheck: acctest.ErrorCheck(t, names.ECSServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckTaskDefinitionDestroy(ctx), @@ -375,7 +376,7 @@ func TestAccECSTaskDefinition_Fargate_runtimePlatformWithoutArch(t *testing.T) { resourceName := "aws_ecs_task_definition.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartition(t, names.StandardPartitionID) }, // runtime platform not support on GovCloud + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartition(t, endpoints.AwsPartitionID) }, // runtime platform not support on GovCloud ErrorCheck: acctest.ErrorCheck(t, names.ECSServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckTaskDefinitionDestroy(ctx), @@ -637,7 +638,7 @@ func TestAccECSTaskDefinition_fsxWinFileSystem(t *testing.T) { t.Skip("skipping long-running test in short mode") } - if acctest.Partition() == names.USGovCloudPartitionID { + if acctest.Partition() == endpoints.AwsUsGovPartitionID { t.Skip("Amazon FSx for Windows File Server volumes for ECS tasks are not supported in GovCloud partition") } diff --git a/internal/service/ecs/task_set.go b/internal/service/ecs/task_set.go index e2cf76a34f2..8665629257f 100644 --- a/internal/service/ecs/task_set.go +++ b/internal/service/ecs/task_set.go @@ -276,7 +276,7 @@ func resourceTaskSet() *schema.Resource { func resourceTaskSetCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ECSClient(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) cluster := d.Get("cluster").(string) service := d.Get("service").(string) diff --git a/internal/service/efs/access_point.go b/internal/service/efs/access_point.go index 990d718f7ac..92c02e0451b 100644 --- a/internal/service/efs/access_point.go +++ b/internal/service/efs/access_point.go @@ -188,7 +188,7 @@ func resourceAccessPointRead(ctx context.Context, d *schema.ResourceData, meta i fsID := aws.ToString(ap.FileSystemId) fsARN := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: "file-system/" + fsID, Service: "elasticfilesystem", diff --git a/internal/service/efs/access_point_data_source.go b/internal/service/efs/access_point_data_source.go index 31c5ad2bd82..7a7d68691c1 100644 --- a/internal/service/efs/access_point_data_source.go +++ b/internal/service/efs/access_point_data_source.go @@ -118,7 +118,7 @@ func dataSourceAccessPointRead(ctx context.Context, d *schema.ResourceData, meta fsID := aws.ToString(ap.FileSystemId) fsARN := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: "file-system/" + fsID, Service: "elasticfilesystem", diff --git a/internal/service/efs/mount_target.go b/internal/service/efs/mount_target.go index d6f27c5a712..fe73c5b5bbf 100644 --- a/internal/service/efs/mount_target.go +++ b/internal/service/efs/mount_target.go @@ -169,7 +169,7 @@ func resourceMountTargetRead(ctx context.Context, d *schema.ResourceData, meta i fsID := aws.ToString(mt.FileSystemId) fsARN := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: "file-system/" + fsID, Service: "elasticfilesystem", diff --git a/internal/service/efs/mount_target_data_source.go b/internal/service/efs/mount_target_data_source.go index bedea3271da..2d7cd9a313d 100644 --- a/internal/service/efs/mount_target_data_source.go +++ b/internal/service/efs/mount_target_data_source.go @@ -112,7 +112,7 @@ func dataSourceMountTargetRead(ctx context.Context, d *schema.ResourceData, meta fsID := aws.ToString(mt.FileSystemId) fsARN := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: "file-system/" + fsID, Service: "elasticfilesystem", diff --git a/internal/service/eks/arn.go b/internal/service/eks/arn.go index 0144829fbfe..41034976c6d 100644 --- a/internal/service/eks/arn.go +++ b/internal/service/eks/arn.go @@ -17,7 +17,7 @@ import ( "strings" awsarn "github.com/aws/aws-sdk-go-v2/aws/arn" - "github.com/hashicorp/terraform-provider-aws/names" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" ) // Canonicalize validates IAM resources are appropriate for the authenticator @@ -71,9 +71,9 @@ func Canonicalize(arn string) (string, error) { func checkPartition(partition string) error { switch partition { - case names.StandardPartitionID: - case names.ChinaPartitionID: - case names.USGovCloudPartitionID: + case endpoints.AwsPartitionID: + case endpoints.AwsCnPartitionID: + case endpoints.AwsUsGovPartitionID: default: return fmt.Errorf("partion %q is not recognized", partition) } diff --git a/internal/service/eks/fargate_profile_test.go b/internal/service/eks/fargate_profile_test.go index b118d9c3919..a4bc88602ce 100644 --- a/internal/service/eks/fargate_profile_test.go +++ b/internal/service/eks/fargate_profile_test.go @@ -10,6 +10,7 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/service/eks/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -31,7 +32,7 @@ func TestAccEKSFargateProfile_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartition(t, names.StandardPartitionID) + acctest.PreCheckPartition(t, endpoints.AwsPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.EKSServiceID), @@ -70,7 +71,7 @@ func TestAccEKSFargateProfile_disappears(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartition(t, names.StandardPartitionID) + acctest.PreCheckPartition(t, endpoints.AwsPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.EKSServiceID), @@ -99,7 +100,7 @@ func TestAccEKSFargateProfile_Multi_profile(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartition(t, names.StandardPartitionID) + acctest.PreCheckPartition(t, endpoints.AwsPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.EKSServiceID), @@ -126,7 +127,7 @@ func TestAccEKSFargateProfile_Selector_labels(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartition(t, names.StandardPartitionID) + acctest.PreCheckPartition(t, endpoints.AwsPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.EKSServiceID), @@ -157,7 +158,7 @@ func TestAccEKSFargateProfile_tags(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartition(t, names.StandardPartitionID) + acctest.PreCheckPartition(t, endpoints.AwsPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.EKSServiceID), diff --git a/internal/service/elasticache/cluster.go b/internal/service/elasticache/cluster.go index 690b40d7831..f697c94627e 100644 --- a/internal/service/elasticache/cluster.go +++ b/internal/service/elasticache/cluster.go @@ -349,7 +349,7 @@ func resourceCluster() *schema.Resource { func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ElastiCacheClient(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) clusterID := d.Get("cluster_id").(string) input := &elasticache.CreateCacheClusterInput{ diff --git a/internal/service/elasticache/cluster_data_source.go b/internal/service/elasticache/cluster_data_source.go index 14e666a0760..af103f4a821 100644 --- a/internal/service/elasticache/cluster_data_source.go +++ b/internal/service/elasticache/cluster_data_source.go @@ -176,7 +176,7 @@ func dataSourceClusterRead(ctx context.Context, d *schema.ResourceData, meta int var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ElastiCacheClient(ctx) ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) clusterID := d.Get("cluster_id").(string) cluster, err := findCacheClusterWithNodeInfoByID(ctx, conn, clusterID) diff --git a/internal/service/elasticache/parameter_group.go b/internal/service/elasticache/parameter_group.go index c4ae8478271..5a265a26d89 100644 --- a/internal/service/elasticache/parameter_group.go +++ b/internal/service/elasticache/parameter_group.go @@ -92,7 +92,7 @@ func resourceParameterGroup() *schema.Resource { func resourceParameterGroupCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ElastiCacheClient(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) name := d.Get(names.AttrName).(string) input := &elasticache.CreateCacheParameterGroupInput{ diff --git a/internal/service/elasticache/replication_group.go b/internal/service/elasticache/replication_group.go index 7c8fd300009..67fa1dd92a4 100644 --- a/internal/service/elasticache/replication_group.go +++ b/internal/service/elasticache/replication_group.go @@ -426,7 +426,7 @@ func resourceReplicationGroup() *schema.Resource { func resourceReplicationGroupCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ElastiCacheClient(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) replicationGroupID := d.Get("replication_group_id").(string) input := &elasticache.CreateReplicationGroupInput{ diff --git a/internal/service/elasticache/subnet_group.go b/internal/service/elasticache/subnet_group.go index b261327be5a..89920a47e3f 100644 --- a/internal/service/elasticache/subnet_group.go +++ b/internal/service/elasticache/subnet_group.go @@ -84,7 +84,7 @@ func resourceSubnetGroup() *schema.Resource { func resourceSubnetGroupCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ElastiCacheClient(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) name := d.Get(names.AttrName).(string) input := &elasticache.CreateCacheSubnetGroupInput{ diff --git a/internal/service/elasticache/subnet_group_data_source_test.go b/internal/service/elasticache/subnet_group_data_source_test.go index c80951b0a3e..e1c436dec00 100644 --- a/internal/service/elasticache/subnet_group_data_source_test.go +++ b/internal/service/elasticache/subnet_group_data_source_test.go @@ -7,6 +7,7 @@ import ( "fmt" "testing" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" @@ -14,7 +15,7 @@ import ( ) func testAccPreCheck(t *testing.T) { - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) } func TestAccElastiCacheSubnetGroupDataSource_basic(t *testing.T) { diff --git a/internal/service/elasticache/user.go b/internal/service/elasticache/user.go index 45b3053a971..315999095d2 100644 --- a/internal/service/elasticache/user.go +++ b/internal/service/elasticache/user.go @@ -130,7 +130,7 @@ func resourceUser() *schema.Resource { func resourceUserCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ElastiCacheClient(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) userID := d.Get("user_id").(string) input := &elasticache.CreateUserInput{ diff --git a/internal/service/elasticache/user_group.go b/internal/service/elasticache/user_group.go index 6ad3cc53379..49d1b72c4f9 100644 --- a/internal/service/elasticache/user_group.go +++ b/internal/service/elasticache/user_group.go @@ -75,7 +75,7 @@ func resourceUserGroup() *schema.Resource { func resourceUserGroupCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ElastiCacheClient(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) userGroupID := d.Get("user_group_id").(string) input := &elasticache.CreateUserGroupInput{ diff --git a/internal/service/elasticsearch/domain_policy_test.go b/internal/service/elasticsearch/domain_policy_test.go index a4f0b8579ae..a6e4cb5d9e1 100644 --- a/internal/service/elasticsearch/domain_policy_test.go +++ b/internal/service/elasticsearch/domain_policy_test.go @@ -63,7 +63,7 @@ func TestAccElasticsearchDomainPolicy_basic(t *testing.T) { resource.TestCheckResourceAttr("aws_elasticsearch_domain.example", "elasticsearch_version", "2.3"), func(s *terraform.State) error { awsClient := acctest.Provider.Meta().(*conns.AWSClient) - expectedArn, err := buildDomainARN(name, awsClient.Partition, awsClient.AccountID, awsClient.Region) + expectedArn, err := buildDomainARN(name, awsClient.Partition(ctx), awsClient.AccountID, awsClient.Region) if err != nil { return err } diff --git a/internal/service/elb/load_balancer.go b/internal/service/elb/load_balancer.go index 24bc3a45088..ae656c9df66 100644 --- a/internal/service/elb/load_balancer.go +++ b/internal/service/elb/load_balancer.go @@ -341,7 +341,7 @@ func resourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, meta } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "elasticloadbalancing", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/elb/load_balancer_data_source.go b/internal/service/elb/load_balancer_data_source.go index 21431e5b11e..c4cd2fe1243 100644 --- a/internal/service/elb/load_balancer_data_source.go +++ b/internal/service/elb/load_balancer_data_source.go @@ -229,7 +229,7 @@ func dataSourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, met lbAttrs := output.LoadBalancerAttributes arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "elasticloadbalancing", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/elb/service_account_data_source.go b/internal/service/elb/service_account_data_source.go index 5a82eac5192..950095235ed 100644 --- a/internal/service/elb/service_account_data_source.go +++ b/internal/service/elb/service_account_data_source.go @@ -75,7 +75,7 @@ func dataSourceServiceAccountRead(ctx context.Context, d *schema.ResourceData, m if v, ok := accountIDPerRegionMap[region]; ok { d.SetId(v) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "iam", AccountID: v, Resource: "root", diff --git a/internal/service/elbv2/listener.go b/internal/service/elbv2/listener.go index 228dbcf97a3..3f42df19768 100644 --- a/internal/service/elbv2/listener.go +++ b/internal/service/elbv2/listener.go @@ -486,7 +486,7 @@ func resourceListenerCreate(ctx context.Context, d *schema.ResourceData, meta in output, err := retryListenerCreate(ctx, conn, input, d.Timeout(schema.TimeoutCreate)) // Some partitions (e.g. ISO) may not support tag-on-create. - if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { input.Tags = nil output, err = retryListenerCreate(ctx, conn, input, d.Timeout(schema.TimeoutCreate)) @@ -519,7 +519,7 @@ func resourceListenerCreate(ctx context.Context, d *schema.ResourceData, meta in err := createTags(ctx, conn, d.Id(), tags) // If default tags only, continue. Otherwise, error. - if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return append(diags, resourceListenerRead(ctx, d, meta)...) } diff --git a/internal/service/elbv2/listener_rule.go b/internal/service/elbv2/listener_rule.go index 7d059296ff9..44d8a703a3b 100644 --- a/internal/service/elbv2/listener_rule.go +++ b/internal/service/elbv2/listener_rule.go @@ -512,7 +512,7 @@ func resourceListenerRuleCreate(ctx context.Context, d *schema.ResourceData, met output, err := retryListenerRuleCreate(ctx, conn, d, input, listenerARN) // Some partitions (e.g. ISO) may not support tag-on-create. - if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { input.Tags = nil output, err = retryListenerRuleCreate(ctx, conn, d, input, listenerARN) @@ -529,7 +529,7 @@ func resourceListenerRuleCreate(ctx context.Context, d *schema.ResourceData, met err := createTags(ctx, conn, d.Id(), tags) // If default tags only, continue. Otherwise, error. - if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return append(diags, resourceListenerRuleRead(ctx, d, meta)...) } diff --git a/internal/service/elbv2/load_balancer.go b/internal/service/elbv2/load_balancer.go index 51f0199af57..71c9159dc74 100644 --- a/internal/service/elbv2/load_balancer.go +++ b/internal/service/elbv2/load_balancer.go @@ -342,7 +342,7 @@ func suppressIfLBTypeNot(types ...awstypes.LoadBalancerTypeEnum) schema.SchemaDi func resourceLoadBalancerCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ELBV2Client(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) name := create.NewNameGenerator( create.WithConfiguredName(d.Get(names.AttrName).(string)), diff --git a/internal/service/elbv2/load_balancer_test.go b/internal/service/elbv2/load_balancer_test.go index 825555a06cc..8b58c6b83e5 100644 --- a/internal/service/elbv2/load_balancer_test.go +++ b/internal/service/elbv2/load_balancer_test.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2" awstypes "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -346,7 +347,7 @@ func TestAccELBV2LoadBalancer_ipv6SubnetMapping(t *testing.T) { "idle_timeout", } // GovCloud doesn't support dns_record_client_routing_policy. - if acctest.Partition() == names.USGovCloudPartitionID { + if acctest.Partition() == endpoints.AwsUsGovPartitionID { importStateVerifyIgnore = append(importStateVerifyIgnore, "dns_record_client_routing_policy") } @@ -499,7 +500,7 @@ func TestAccELBV2LoadBalancer_NLB_privateIPv4Address(t *testing.T) { var importStateVerifyIgnore []string // GovCloud doesn't support dns_record_client_routing_policy. - if acctest.Partition() == names.USGovCloudPartitionID { + if acctest.Partition() == endpoints.AwsUsGovPartitionID { importStateVerifyIgnore = append(importStateVerifyIgnore, "dns_record_client_routing_policy") } @@ -949,7 +950,7 @@ func TestAccELBV2LoadBalancer_ApplicationLoadBalancer_updatedSecurityGroups(t *t PreCheck: func() { acctest.PreCheck(ctx, t) // GovCloud Regions don't always have 3 AZs. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.ELBV2ServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -986,7 +987,7 @@ func TestAccELBV2LoadBalancer_ApplicationLoadBalancer_addSubnet(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) // GovCloud Regions don't always have 3 AZs. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.ELBV2ServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -1023,7 +1024,7 @@ func TestAccELBV2LoadBalancer_ApplicationLoadBalancer_deleteSubnet(t *testing.T) PreCheck: func() { acctest.PreCheck(ctx, t) // GovCloud Regions don't always have 3 AZs. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.ELBV2ServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -1060,7 +1061,7 @@ func TestAccELBV2LoadBalancer_ApplicationLoadBalancer_addSubnetMapping(t *testin PreCheck: func() { acctest.PreCheck(ctx, t) // GovCloud Regions don't always have 3 AZs. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.ELBV2ServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -1097,7 +1098,7 @@ func TestAccELBV2LoadBalancer_ApplicationLoadBalancer_deleteSubnetMapping(t *tes PreCheck: func() { acctest.PreCheck(ctx, t) // GovCloud Regions don't always have 3 AZs. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.ELBV2ServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -1432,7 +1433,7 @@ func TestAccELBV2LoadBalancer_NetworkLoadBalancer_accessLogs(t *testing.T) { var importStateVerifyIgnore []string // GovCloud doesn't support dns_record_client_routing_policy. - if acctest.Partition() == names.USGovCloudPartitionID { + if acctest.Partition() == endpoints.AwsUsGovPartitionID { importStateVerifyIgnore = append(importStateVerifyIgnore, "dns_record_client_routing_policy") } @@ -1512,7 +1513,7 @@ func TestAccELBV2LoadBalancer_NetworkLoadBalancer_accessLogsPrefix(t *testing.T) var importStateVerifyIgnore []string // GovCloud doesn't support dns_record_client_routing_policy. - if acctest.Partition() == names.USGovCloudPartitionID { + if acctest.Partition() == endpoints.AwsUsGovPartitionID { importStateVerifyIgnore = append(importStateVerifyIgnore, "dns_record_client_routing_policy") } @@ -1581,7 +1582,7 @@ func TestAccELBV2LoadBalancer_NetworkLoadBalancer_updateDNSRecordClientRoutingPo PreCheck: func() { acctest.PreCheck(ctx, t) // GovCloud doesn't support dns_record_client_routing_policy. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.ELBV2ServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -1676,7 +1677,7 @@ func TestAccELBV2LoadBalancer_NetworkLoadBalancer_enforcePrivateLink(t *testing. var importStateVerifyIgnore []string // GovCloud doesn't support dns_record_client_routing_policy. - if acctest.Partition() == names.USGovCloudPartitionID { + if acctest.Partition() == endpoints.AwsUsGovPartitionID { importStateVerifyIgnore = append(importStateVerifyIgnore, "dns_record_client_routing_policy") } @@ -1745,7 +1746,7 @@ func TestAccELBV2LoadBalancer_NetworkLoadBalancer_addSubnet(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) // GovCloud Regions don't always have 3 AZs. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.ELBV2ServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -1780,7 +1781,7 @@ func TestAccELBV2LoadBalancer_NetworkLoadBalancer_deleteSubnet(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) // GovCloud Regions don't always have 3 AZs. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.ELBV2ServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -1815,7 +1816,7 @@ func TestAccELBV2LoadBalancer_NetworkLoadBalancer_addSubnetMapping(t *testing.T) PreCheck: func() { acctest.PreCheck(ctx, t) // GovCloud Regions don't always have 3 AZs. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.ELBV2ServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -1852,7 +1853,7 @@ func TestAccELBV2LoadBalancer_NetworkLoadBalancer_deleteSubnetMapping(t *testing PreCheck: func() { acctest.PreCheck(ctx, t) // GovCloud Regions don't always have 3 AZs. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.ELBV2ServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/elbv2/target_group.go b/internal/service/elbv2/target_group.go index e0f83077a4d..4ebb52c2eb6 100644 --- a/internal/service/elbv2/target_group.go +++ b/internal/service/elbv2/target_group.go @@ -500,7 +500,7 @@ func resourceTargetGroupCreate(ctx context.Context, d *schema.ResourceData, meta output, err := conn.CreateTargetGroup(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(partition, err) { input.Tags = nil diff --git a/internal/service/elbv2/trust_store.go b/internal/service/elbv2/trust_store.go index fa038a0ca9d..6125e4d6e99 100644 --- a/internal/service/elbv2/trust_store.go +++ b/internal/service/elbv2/trust_store.go @@ -101,7 +101,7 @@ func resourceTrustStore() *schema.Resource { func resourceTrustStoreCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).ELBV2Client(ctx) - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) name := create.NewNameGenerator( create.WithConfiguredName(d.Get(names.AttrName).(string)), diff --git a/internal/service/emr/cluster_test.go b/internal/service/emr/cluster_test.go index 7b664688ea1..75a94fa366f 100644 --- a/internal/service/emr/cluster_test.go +++ b/internal/service/emr/cluster_test.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/ec2" ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types" awstypes "github.com/aws/aws-sdk-go-v2/service/emr/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -87,7 +88,7 @@ func TestAccEMRCluster_autoTerminationPolicy(t *testing.T) { resourceName := "aws_emr_cluster.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.EMRServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckClusterDestroy(ctx), diff --git a/internal/service/events/bus.go b/internal/service/events/bus.go index 29a75c29b57..be6e57c1d2a 100644 --- a/internal/service/events/bus.go +++ b/internal/service/events/bus.go @@ -87,7 +87,7 @@ func resourceBusCreate(ctx context.Context, d *schema.ResourceData, meta interfa output, err := conn.CreateEventBus(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { input.Tags = nil output, err = conn.CreateEventBus(ctx, input) @@ -104,7 +104,7 @@ func resourceBusCreate(ctx context.Context, d *schema.ResourceData, meta interfa err := createTags(ctx, conn, aws.ToString(output.EventBusArn), tags) // If default tags only, continue. Otherwise, error. - if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return append(diags, resourceBusRead(ctx, d, meta)...) } diff --git a/internal/service/events/rule.go b/internal/service/events/rule.go index 0fe22b8cf1b..9af11c1a911 100644 --- a/internal/service/events/rule.go +++ b/internal/service/events/rule.go @@ -158,7 +158,7 @@ func resourceRuleCreate(ctx context.Context, d *schema.ResourceData, meta interf arn, err := retryPutRule(ctx, conn, input) // Some partitions (e.g. ISO) may not support tag-on-create. - if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { input.Tags = nil arn, err = retryPutRule(ctx, conn, input) @@ -187,7 +187,7 @@ func resourceRuleCreate(ctx context.Context, d *schema.ResourceData, meta interf err := createTags(ctx, conn, arn, tags) // If default tags only, continue. Otherwise, error. - if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return append(diags, resourceRuleRead(ctx, d, meta)...) } @@ -263,7 +263,7 @@ func resourceRuleUpdate(ctx context.Context, d *schema.ResourceData, meta interf _, err = retryPutRule(ctx, conn, input) // Some partitions (e.g. ISO) may not support tag-on-update. - if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { input.Tags = nil _, err = retryPutRule(ctx, conn, input) diff --git a/internal/service/events/target_test.go b/internal/service/events/target_test.go index d688534be81..f74ad80cda0 100644 --- a/internal/service/events/target_test.go +++ b/internal/service/events/target_test.go @@ -13,6 +13,7 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/service/eventbridge/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -316,7 +317,7 @@ func TestAccEventsTarget_eventBusARN(t *testing.T) { resourceName := "aws_cloudwatch_event_target.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.EventsServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckTargetDestroy(ctx), diff --git a/internal/service/finspace/kx_dataview.go b/internal/service/finspace/kx_dataview.go index c5de0d95c91..1e048f3190e 100644 --- a/internal/service/finspace/kx_dataview.go +++ b/internal/service/finspace/kx_dataview.go @@ -249,7 +249,7 @@ func resourceKxDataviewRead(ctx context.Context, d *schema.ResourceData, meta in // // Ref: https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonfinspace.html#amazonfinspace-resources-for-iam-policies dataviewARN := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: names.FinSpace, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/firehose/sweep.go b/internal/service/firehose/sweep.go index 58f54a51393..fdae1adab0f 100644 --- a/internal/service/firehose/sweep.go +++ b/internal/service/firehose/sweep.go @@ -7,7 +7,6 @@ import ( "fmt" "log" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/firehose" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/sweep" @@ -40,14 +39,7 @@ func sweepDeliveryStreams(region string) error { for _, name := range page.DeliveryStreamNames { r := resourceDeliveryStream() d := r.Data(nil) - arn := arn.ARN{ - Partition: client.Partition, - Service: "firehose", - Region: client.Region, - AccountID: client.AccountID, - Resource: fmt.Sprintf("deliverystream/%s", name), - }.String() - d.SetId(arn) + d.SetId(client.RegionalARN(ctx, "firehose", fmt.Sprintf("deliverystream/%s", name))) d.Set(names.AttrName, name) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) diff --git a/internal/service/fsx/data_repository_association_test.go b/internal/service/fsx/data_repository_association_test.go index 0f12bd71973..9374fefc65a 100644 --- a/internal/service/fsx/data_repository_association_test.go +++ b/internal/service/fsx/data_repository_association_test.go @@ -12,6 +12,7 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" awstypes "github.com/aws/aws-sdk-go-v2/service/fsx/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" 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,7 +36,7 @@ func TestAccFSxDataRepositoryAssociation_basic(t *testing.T) { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -75,7 +76,7 @@ func TestAccFSxDataRepositoryAssociation_disappears(t *testing.T) { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -106,7 +107,7 @@ func TestAccFSxDataRepositoryAssociation_disappears_ParentFileSystem(t *testing. acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -137,7 +138,7 @@ func TestAccFSxDataRepositoryAssociation_fileSystemPathUpdated(t *testing.T) { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -184,7 +185,7 @@ func TestAccFSxDataRepositoryAssociation_dataRepositoryPathUpdated(t *testing.T) acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -228,7 +229,7 @@ func TestAccFSxDataRepositoryAssociation_importedFileChunkSize(t *testing.T) { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -264,7 +265,7 @@ func TestAccFSxDataRepositoryAssociation_importedFileChunkSizeUpdated(t *testing acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -307,7 +308,7 @@ func TestAccFSxDataRepositoryAssociation_deleteDataInFilesystem(t *testing.T) { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -343,7 +344,7 @@ func TestAccFSxDataRepositoryAssociation_s3AutoExportPolicy(t *testing.T) { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -382,7 +383,7 @@ func TestAccFSxDataRepositoryAssociation_s3AutoExportPolicyUpdate(t *testing.T) acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -428,7 +429,7 @@ func TestAccFSxDataRepositoryAssociation_s3AutoImportPolicy(t *testing.T) { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -467,7 +468,7 @@ func TestAccFSxDataRepositoryAssociation_s3AutoImportPolicyUpdate(t *testing.T) acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -512,7 +513,7 @@ func TestAccFSxDataRepositoryAssociation_s3FullPolicy(t *testing.T) { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.FSxEndpointID) // PERSISTENT_2 deployment_type is not supported in GovCloud partition. - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.FSxServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/fsx/lustre_file_system_test.go b/internal/service/fsx/lustre_file_system_test.go index 9e1e5e40e05..94d295281ee 100644 --- a/internal/service/fsx/lustre_file_system_test.go +++ b/internal/service/fsx/lustre_file_system_test.go @@ -11,6 +11,7 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" awstypes "github.com/aws/aws-sdk-go-v2/service/fsx/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -27,7 +28,7 @@ func TestAccFSxLustreFileSystem_basic(t *testing.T) { resourceName := "aws_fsx_lustre_file_system.test" rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) deploymentType := awstypes.LustreDeploymentTypeScratch1 - if acctest.Partition() == names.USGovCloudPartitionID { + if acctest.Partition() == endpoints.AwsUsGovPartitionID { deploymentType = awstypes.LustreDeploymentTypeScratch2 // SCRATCH_1 not supported in GovCloud } diff --git a/internal/service/globalaccelerator/service_package.go b/internal/service/globalaccelerator/service_package.go index 2284e7781df..3a1fa076461 100644 --- a/internal/service/globalaccelerator/service_package.go +++ b/internal/service/globalaccelerator/service_package.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/globalaccelerator" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -20,7 +21,7 @@ func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) ( globalaccelerator.WithEndpointResolverV2(newEndpointResolverV2()), withBaseEndpoint(config[names.AttrEndpoint].(string)), func(o *globalaccelerator.Options) { - if config["partition"].(string) == names.StandardPartitionID { + if config["partition"].(string) == endpoints.AwsPartitionID { // Global Accelerator endpoint is only available in AWS Commercial us-west-2 Region. if cfg.Region != names.USWest2RegionID { tflog.Info(ctx, "overriding region", map[string]any{ diff --git a/internal/service/glue/catalog_database.go b/internal/service/glue/catalog_database.go index e09a78866fe..40af7a2b187 100644 --- a/internal/service/glue/catalog_database.go +++ b/internal/service/glue/catalog_database.go @@ -273,7 +273,7 @@ func resourceCatalogDatabaseRead(ctx context.Context, d *schema.ResourceData, me database := out.Database databaseArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/glue/catalog_table.go b/internal/service/glue/catalog_table.go index c38a470eebe..5f8cce445d1 100644 --- a/internal/service/glue/catalog_table.go +++ b/internal/service/glue/catalog_table.go @@ -451,7 +451,7 @@ func resourceCatalogTableRead(ctx context.Context, d *schema.ResourceData, meta } tableArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/glue/catalog_table_data_source.go b/internal/service/glue/catalog_table_data_source.go index e7dc0b6fc52..3fea41664b8 100644 --- a/internal/service/glue/catalog_table_data_source.go +++ b/internal/service/glue/catalog_table_data_source.go @@ -367,7 +367,7 @@ func dataSourceCatalogTableRead(ctx context.Context, d *schema.ResourceData, met table := out.Table tableArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/glue/connection.go b/internal/service/glue/connection.go index 03d8fcb1a93..23f0e216b2f 100644 --- a/internal/service/glue/connection.go +++ b/internal/service/glue/connection.go @@ -164,7 +164,7 @@ func resourceConnectionRead(ctx context.Context, d *schema.ResourceData, meta in } connectionArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/glue/connection_data_source.go b/internal/service/glue/connection_data_source.go index 740fcb82c3c..acfc199fde6 100644 --- a/internal/service/glue/connection_data_source.go +++ b/internal/service/glue/connection_data_source.go @@ -115,7 +115,7 @@ func dataSourceConnectionRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrDescription, connection.Description) connectionArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/glue/crawler.go b/internal/service/glue/crawler.go index b8c4490a89b..daa062f28fd 100644 --- a/internal/service/glue/crawler.go +++ b/internal/service/glue/crawler.go @@ -498,7 +498,7 @@ func resourceCrawlerRead(ctx context.Context, d *schema.ResourceData, meta inter } crawlerARN := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/glue/data_quality_ruleset.go b/internal/service/glue/data_quality_ruleset.go index 6d3da5278bc..05b19e9145e 100644 --- a/internal/service/glue/data_quality_ruleset.go +++ b/internal/service/glue/data_quality_ruleset.go @@ -153,7 +153,7 @@ func resourceDataQualityRulesetRead(ctx context.Context, d *schema.ResourceData, } dataQualityRulesetArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/glue/dev_endpoint.go b/internal/service/glue/dev_endpoint.go index b39cdea4720..68fe18adbce 100644 --- a/internal/service/glue/dev_endpoint.go +++ b/internal/service/glue/dev_endpoint.go @@ -290,7 +290,7 @@ func resourceDevEndpointRead(ctx context.Context, d *schema.ResourceData, meta i } endpointARN := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/glue/job.go b/internal/service/glue/job.go index 9d250dc0245..d57e628b6a0 100644 --- a/internal/service/glue/job.go +++ b/internal/service/glue/job.go @@ -301,7 +301,7 @@ func resourceJobRead(ctx context.Context, d *schema.ResourceData, meta interface } jobARN := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/glue/ml_transform.go b/internal/service/glue/ml_transform.go index bb173b34e2b..660acf3993d 100644 --- a/internal/service/glue/ml_transform.go +++ b/internal/service/glue/ml_transform.go @@ -269,7 +269,7 @@ func resourceMLTransformRead(ctx context.Context, d *schema.ResourceData, meta i log.Printf("[DEBUG] setting Glue ML Transform: %#v", output) mlTransformArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/glue/trigger.go b/internal/service/glue/trigger.go index abecd2b1bf1..8a3ab610298 100644 --- a/internal/service/glue/trigger.go +++ b/internal/service/glue/trigger.go @@ -337,7 +337,7 @@ func resourceTriggerRead(ctx context.Context, d *schema.ResourceData, meta inter } triggerARN := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/glue/user_defined_function.go b/internal/service/glue/user_defined_function.go index fef34b1096f..8c20d5dbb11 100644 --- a/internal/service/glue/user_defined_function.go +++ b/internal/service/glue/user_defined_function.go @@ -173,7 +173,7 @@ func resourceUserDefinedFunctionRead(ctx context.Context, d *schema.ResourceData udf := out.UserDefinedFunction udfArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/glue/workflow.go b/internal/service/glue/workflow.go index 6d7a30e04f4..82837cf081e 100644 --- a/internal/service/glue/workflow.go +++ b/internal/service/glue/workflow.go @@ -127,7 +127,7 @@ func resourceWorkflowRead(ctx context.Context, d *schema.ResourceData, meta inte } workFlowArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "glue", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/grafana/workspace.go b/internal/service/grafana/workspace.go index 08b86fadde5..3e887ab0c74 100644 --- a/internal/service/grafana/workspace.go +++ b/internal/service/grafana/workspace.go @@ -285,7 +285,7 @@ func resourceWorkspaceRead(ctx context.Context, d *schema.ResourceData, meta int d.Set("account_access_type", workspace.AccountAccessType) // https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonmanagedgrafana.html#amazonmanagedgrafana-resources-for-iam-policies. workspaceARN := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "grafana", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/grafana/workspace_data_source.go b/internal/service/grafana/workspace_data_source.go index a42e515f87b..d11e6fdc9b0 100644 --- a/internal/service/grafana/workspace_data_source.go +++ b/internal/service/grafana/workspace_data_source.go @@ -124,7 +124,7 @@ func dataSourceWorkspaceRead(ctx context.Context, d *schema.ResourceData, meta i d.Set("account_access_type", workspace.AccountAccessType) // https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonmanagedgrafana.html#amazonmanagedgrafana-resources-for-iam-policies. workspaceARN := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "grafana", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/guardduty/detector.go b/internal/service/guardduty/detector.go index df87cd5887a..d437b675b8e 100644 --- a/internal/service/guardduty/detector.go +++ b/internal/service/guardduty/detector.go @@ -191,7 +191,7 @@ func resourceDetectorRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set(names.AttrAccountID, meta.(*conns.AWSClient).AccountID) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "guardduty", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/guardduty/filter.go b/internal/service/guardduty/filter.go index f73005ed0f8..6ba9cf36e7e 100644 --- a/internal/service/guardduty/filter.go +++ b/internal/service/guardduty/filter.go @@ -203,7 +203,7 @@ func resourceFilterRead(ctx context.Context, d *schema.ResourceData, meta interf } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "guardduty", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/guardduty/ipset.go b/internal/service/guardduty/ipset.go index 11e89d476f4..8eae9e67568 100644 --- a/internal/service/guardduty/ipset.go +++ b/internal/service/guardduty/ipset.go @@ -136,7 +136,7 @@ func resourceIPSetRead(ctx context.Context, d *schema.ResourceData, meta interfa } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "guardduty", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/guardduty/threatintelset.go b/internal/service/guardduty/threatintelset.go index 3231f3db854..85a96f0dd4f 100644 --- a/internal/service/guardduty/threatintelset.go +++ b/internal/service/guardduty/threatintelset.go @@ -136,7 +136,7 @@ func resourceThreatIntelSetRead(ctx context.Context, d *schema.ResourceData, met } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "guardduty", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/iam/instance_profile.go b/internal/service/iam/instance_profile.go index 45c2f594fd3..164b554d154 100644 --- a/internal/service/iam/instance_profile.go +++ b/internal/service/iam/instance_profile.go @@ -106,7 +106,7 @@ func resourceInstanceProfileCreate(ctx context.Context, d *schema.ResourceData, output, err := conn.CreateInstanceProfile(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(partition, err) { input.Tags = nil diff --git a/internal/service/iam/openid_connect_provider.go b/internal/service/iam/openid_connect_provider.go index aa7a1813d70..0ba671fdb8c 100644 --- a/internal/service/iam/openid_connect_provider.go +++ b/internal/service/iam/openid_connect_provider.go @@ -88,7 +88,7 @@ func resourceOpenIDConnectProviderCreate(ctx context.Context, d *schema.Resource output, err := conn.CreateOpenIDConnectProvider(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(partition, err) { input.Tags = nil diff --git a/internal/service/iam/policy.go b/internal/service/iam/policy.go index 2d229d9eece..b2fb64be31b 100644 --- a/internal/service/iam/policy.go +++ b/internal/service/iam/policy.go @@ -128,7 +128,7 @@ func resourcePolicyCreate(ctx context.Context, d *schema.ResourceData, meta inte output, err := conn.CreatePolicy(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(partition, err) { input.Tags = nil diff --git a/internal/service/iam/policy_document_data_source_test.go b/internal/service/iam/policy_document_data_source_test.go index 4f7d1010c91..91297fe9a1e 100644 --- a/internal/service/iam/policy_document_data_source_test.go +++ b/internal/service/iam/policy_document_data_source_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/YakDriver/regexache" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/names" @@ -371,7 +372,7 @@ func TestAccIAMPolicyDocumentDataSource_StatementPrincipalIdentifiers_multiplePr dataSourceName := "data.aws_iam_policy_document.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartition(t, names.StandardPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartition(t, endpoints.AwsPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.IAMServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Steps: []resource.TestStep{ @@ -390,7 +391,7 @@ func TestAccIAMPolicyDocumentDataSource_StatementPrincipalIdentifiers_multiplePr dataSourceName := "data.aws_iam_policy_document.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartition(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartition(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.IAMServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Steps: []resource.TestStep{ diff --git a/internal/service/iam/role.go b/internal/service/iam/role.go index 3a3d22bb6e0..d3719df1a87 100644 --- a/internal/service/iam/role.go +++ b/internal/service/iam/role.go @@ -216,7 +216,7 @@ func resourceRoleCreate(ctx context.Context, d *schema.ResourceData, meta interf output, err := retryCreateRole(ctx, conn, input) // Some partitions (e.g. ISO) may not support tag-on-create. - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(partition, err) { input.Tags = nil diff --git a/internal/service/iam/saml_provider.go b/internal/service/iam/saml_provider.go index f71cfa3eb80..1e80bb964c1 100644 --- a/internal/service/iam/saml_provider.go +++ b/internal/service/iam/saml_provider.go @@ -84,7 +84,7 @@ func resourceSAMLProviderCreate(ctx context.Context, d *schema.ResourceData, met output, err := conn.CreateSAMLProvider(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(partition, err) { input.Tags = nil diff --git a/internal/service/iam/server_certificate.go b/internal/service/iam/server_certificate.go index a9859e406e6..b3d9999e037 100644 --- a/internal/service/iam/server_certificate.go +++ b/internal/service/iam/server_certificate.go @@ -135,7 +135,7 @@ func resourceServerCertificateCreate(ctx context.Context, d *schema.ResourceData output, err := conn.UploadServerCertificate(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(partition, err) { input.Tags = nil diff --git a/internal/service/iam/service_linked_role.go b/internal/service/iam/service_linked_role.go index d3a0e5cd118..85277130c47 100644 --- a/internal/service/iam/service_linked_role.go +++ b/internal/service/iam/service_linked_role.go @@ -127,7 +127,7 @@ func resourceServiceLinkedRoleCreate(ctx context.Context, d *schema.ResourceData err = roleUpdateTags(ctx, conn, roleName, nil, KeyValueTags(ctx, tags)) // If default tags only, continue. Otherwise, error. - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(partition, err) { return append(diags, resourceServiceLinkedRoleRead(ctx, d, meta)...) } diff --git a/internal/service/iam/service_linked_role_test.go b/internal/service/iam/service_linked_role_test.go index 73c8a674c88..17564eb5a44 100644 --- a/internal/service/iam/service_linked_role_test.go +++ b/internal/service/iam/service_linked_role_test.go @@ -8,7 +8,6 @@ import ( "fmt" "testing" - "github.com/aws/aws-sdk-go-v2/aws/arn" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -98,16 +97,9 @@ func TestAccIAMServiceLinkedRole_basic(t *testing.T) { PreConfig: func() { // Remove existing if possible client := acctest.Provider.Meta().(*conns.AWSClient) - arn := arn.ARN{ - Partition: client.Partition, - Service: "iam", - Region: client.Region, - AccountID: client.AccountID, - Resource: arnResource, - }.String() r := tfiam.ResourceServiceLinkedRole() d := r.Data(nil) - d.SetId(arn) + d.SetId(client.RegionalARN(ctx, "iam", arnResource)) err := acctest.DeleteResource(ctx, r, d, client) if err != nil { diff --git a/internal/service/iam/user.go b/internal/service/iam/user.go index e0ea3929d86..7bef399e90e 100644 --- a/internal/service/iam/user.go +++ b/internal/service/iam/user.go @@ -109,7 +109,7 @@ func resourceUserCreate(ctx context.Context, d *schema.ResourceData, meta interf output, err := conn.CreateUser(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(partition, err) { input.Tags = nil diff --git a/internal/service/iam/virtual_mfa_device.go b/internal/service/iam/virtual_mfa_device.go index 8f919bb9017..bf345622606 100644 --- a/internal/service/iam/virtual_mfa_device.go +++ b/internal/service/iam/virtual_mfa_device.go @@ -101,7 +101,7 @@ func resourceVirtualMFADeviceCreate(ctx context.Context, d *schema.ResourceData, output, err := conn.CreateVirtualMFADevice(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - partition := meta.(*conns.AWSClient).Partition + partition := meta.(*conns.AWSClient).Partition(ctx) if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(partition, err) { input.Tags = nil diff --git a/internal/service/kendra/data_source.go b/internal/service/kendra/data_source.go index ad5bcf49237..a7070d90bf2 100644 --- a/internal/service/kendra/data_source.go +++ b/internal/service/kendra/data_source.go @@ -689,7 +689,7 @@ func resourceDataSourceRead(ctx context.Context, d *schema.ResourceData, meta in } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "kendra", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/kendra/experience.go b/internal/service/kendra/experience.go index ee53a551b91..cb696745b8e 100644 --- a/internal/service/kendra/experience.go +++ b/internal/service/kendra/experience.go @@ -242,7 +242,7 @@ func resourceExperienceRead(ctx context.Context, d *schema.ResourceData, meta in } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "kendra", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/kendra/experience_data_source.go b/internal/service/kendra/experience_data_source.go index d0e090564c3..f0c464a8906 100644 --- a/internal/service/kendra/experience_data_source.go +++ b/internal/service/kendra/experience_data_source.go @@ -156,7 +156,7 @@ func dataSourceExperienceRead(ctx context.Context, d *schema.ResourceData, meta } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "kendra", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/kendra/faq.go b/internal/service/kendra/faq.go index 7a17dc4ae5b..0a82d227fc5 100644 --- a/internal/service/kendra/faq.go +++ b/internal/service/kendra/faq.go @@ -236,7 +236,7 @@ func resourceFaqRead(ctx context.Context, d *schema.ResourceData, meta interface } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "kendra", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/kendra/faq_data_source.go b/internal/service/kendra/faq_data_source.go index 22b1087392d..bc3bdf2fb40 100644 --- a/internal/service/kendra/faq_data_source.go +++ b/internal/service/kendra/faq_data_source.go @@ -125,7 +125,7 @@ func dataSourceFaqRead(ctx context.Context, d *schema.ResourceData, meta interfa } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "kendra", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/kendra/index.go b/internal/service/kendra/index.go index 63aa742c217..fe36e9440d4 100644 --- a/internal/service/kendra/index.go +++ b/internal/service/kendra/index.go @@ -485,7 +485,7 @@ func resourceIndexRead(ctx context.Context, d *schema.ResourceData, meta interfa } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "kendra", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/kendra/index_data_source.go b/internal/service/kendra/index_data_source.go index d1628e2d0b9..8f97063b830 100644 --- a/internal/service/kendra/index_data_source.go +++ b/internal/service/kendra/index_data_source.go @@ -302,7 +302,7 @@ func dataSourceIndexRead(ctx context.Context, d *schema.ResourceData, meta inter } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "kendra", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/kendra/query_suggestions_block_list.go b/internal/service/kendra/query_suggestions_block_list.go index 4ee4ceb079f..6d8014c3463 100644 --- a/internal/service/kendra/query_suggestions_block_list.go +++ b/internal/service/kendra/query_suggestions_block_list.go @@ -180,7 +180,7 @@ func resourceQuerySuggestionsBlockListRead(ctx context.Context, d *schema.Resour } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "kendra", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/kendra/query_suggestions_block_list_data_source.go b/internal/service/kendra/query_suggestions_block_list_data_source.go index f34cf47f97a..43d4dab8c04 100644 --- a/internal/service/kendra/query_suggestions_block_list_data_source.go +++ b/internal/service/kendra/query_suggestions_block_list_data_source.go @@ -118,7 +118,7 @@ func dataSourceQuerySuggestionsBlockListRead(ctx context.Context, d *schema.Reso } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "kendra", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/kendra/thesaurus.go b/internal/service/kendra/thesaurus.go index bb1cc677a4a..ba72b2a37d6 100644 --- a/internal/service/kendra/thesaurus.go +++ b/internal/service/kendra/thesaurus.go @@ -181,7 +181,7 @@ func resourceThesaurusRead(ctx context.Context, d *schema.ResourceData, meta int } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "kendra", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/kendra/thesaurus_data_source.go b/internal/service/kendra/thesaurus_data_source.go index adc8d45392e..766fe16f79e 100644 --- a/internal/service/kendra/thesaurus_data_source.go +++ b/internal/service/kendra/thesaurus_data_source.go @@ -125,7 +125,7 @@ func dataSourceThesaurusRead(ctx context.Context, d *schema.ResourceData, meta i } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "kendra", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/keyspaces/keyspace_test.go b/internal/service/keyspaces/keyspace_test.go index a04c964ee7c..bca2aeebcbc 100644 --- a/internal/service/keyspaces/keyspace_test.go +++ b/internal/service/keyspaces/keyspace_test.go @@ -8,6 +8,7 @@ import ( "fmt" "testing" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -19,7 +20,7 @@ import ( ) func testAccPreCheck(t *testing.T) { - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) } func TestAccKeyspacesKeyspace_basic(t *testing.T) { diff --git a/internal/service/lambda/alias.go b/internal/service/lambda/alias.go index e3250117291..e26ddc9f84d 100644 --- a/internal/service/lambda/alias.go +++ b/internal/service/lambda/alias.go @@ -126,7 +126,7 @@ func resourceAliasRead(ctx context.Context, d *schema.ResourceData, meta interfa d.Set(names.AttrARN, aliasARN) d.Set(names.AttrDescription, output.Description) d.Set("function_version", output.FunctionVersion) - d.Set("invoke_arn", invokeARN(meta.(*conns.AWSClient), aliasARN)) + d.Set("invoke_arn", invokeARN(ctx, meta.(*conns.AWSClient), aliasARN)) d.Set(names.AttrName, output.Name) if err := d.Set("routing_config", flattenAliasRoutingConfiguration(output.RoutingConfig)); err != nil { return sdkdiag.AppendErrorf(diags, "setting routing_config: %s", err) diff --git a/internal/service/lambda/alias_data_source.go b/internal/service/lambda/alias_data_source.go index dcfb776f65a..898aa789db1 100644 --- a/internal/service/lambda/alias_data_source.go +++ b/internal/service/lambda/alias_data_source.go @@ -63,7 +63,7 @@ func dataSourceAliasRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set(names.AttrARN, aliasARN) d.Set(names.AttrDescription, output.Description) d.Set("function_version", output.FunctionVersion) - d.Set("invoke_arn", invokeARN(meta.(*conns.AWSClient), aliasARN)) + d.Set("invoke_arn", invokeARN(ctx, meta.(*conns.AWSClient), aliasARN)) return diags } diff --git a/internal/service/lambda/code_signing_config_data_source_test.go b/internal/service/lambda/code_signing_config_data_source_test.go index d157f83e676..aa73f39c1fc 100644 --- a/internal/service/lambda/code_signing_config_data_source_test.go +++ b/internal/service/lambda/code_signing_config_data_source_test.go @@ -6,6 +6,7 @@ package lambda_test import ( "testing" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/names" @@ -19,7 +20,7 @@ func TestAccLambdaCodeSigningConfigDataSource_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -43,7 +44,7 @@ func TestAccLambdaCodeSigningConfigDataSource_policyID(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -69,7 +70,7 @@ func TestAccLambdaCodeSigningConfigDataSource_description(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/lambda/code_signing_config_test.go b/internal/service/lambda/code_signing_config_test.go index af21cd9aefc..25054b11d4e 100644 --- a/internal/service/lambda/code_signing_config_test.go +++ b/internal/service/lambda/code_signing_config_test.go @@ -9,6 +9,7 @@ import ( "testing" awstypes "github.com/aws/aws-sdk-go-v2/service/lambda/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -29,7 +30,7 @@ func TestAccLambdaCodeSigningConfig_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -63,7 +64,7 @@ func TestAccLambdaCodeSigningConfig_disappears(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -90,7 +91,7 @@ func TestAccLambdaCodeSigningConfig_tags(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -138,7 +139,7 @@ func TestAccLambdaCodeSigningConfig_updatePolicy(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -178,7 +179,7 @@ func TestAccLambdaCodeSigningConfig_updatePublishers(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/lambda/event_source_mapping.go b/internal/service/lambda/event_source_mapping.go index 5946ad4bfbd..7b652b4a1f6 100644 --- a/internal/service/lambda/event_source_mapping.go +++ b/internal/service/lambda/event_source_mapping.go @@ -503,7 +503,7 @@ func resourceEventSourceMappingCreate(ctx context.Context, d *schema.ResourceDat }) // Some partitions (e.g. US GovCloud) may not support tags. - if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { input.Tags = nil output, err = retryEventSourceMapping(ctx, func() (*lambda.CreateEventSourceMappingOutput, error) { diff --git a/internal/service/lambda/event_source_mapping_test.go b/internal/service/lambda/event_source_mapping_test.go index 41e54a5a064..3829b2c2d08 100644 --- a/internal/service/lambda/event_source_mapping_test.go +++ b/internal/service/lambda/event_source_mapping_test.go @@ -16,6 +16,7 @@ import ( awstypes "github.com/aws/aws-sdk-go-v2/service/lambda/types" "github.com/aws/aws-sdk-go-v2/service/mq" "github.com/aws/aws-sdk-go-v2/service/secretsmanager" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -125,7 +126,7 @@ func TestAccLambdaEventSourceMapping_tags(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/lambda/function.go b/internal/service/lambda/function.go index 8cbc84239c2..cf1b3489aeb 100644 --- a/internal/service/lambda/function.go +++ b/internal/service/lambda/function.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/lambda" awstypes "github.com/aws/aws-sdk-go-v2/service/lambda/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" @@ -676,7 +677,7 @@ func resourceFunctionRead(ctx context.Context, d *schema.ResourceData, meta inte if output.Code != nil { d.Set("image_uri", output.Code.ImageUri) } - d.Set("invoke_arn", invokeARN(meta.(*conns.AWSClient), functionARN)) + d.Set("invoke_arn", invokeARN(ctx, meta.(*conns.AWSClient), functionARN)) d.Set(names.AttrKMSKeyARN, function.KMSKeyArn) d.Set("last_modified", function.LastModified) if err := d.Set("layers", flattenLayers(function.Layers)); err != nil { @@ -721,7 +722,7 @@ func resourceFunctionRead(ctx context.Context, d *schema.ResourceData, meta inte if hasQualifier { d.Set("qualified_arn", functionARN) - d.Set("qualified_invoke_arn", invokeARN(meta.(*conns.AWSClient), functionARN)) + d.Set("qualified_invoke_arn", invokeARN(ctx, meta.(*conns.AWSClient), functionARN)) d.Set(names.AttrVersion, function.Version) } else { latest, err := findLatestFunctionVersionByName(ctx, conn, d.Id()) @@ -732,7 +733,7 @@ func resourceFunctionRead(ctx context.Context, d *schema.ResourceData, meta inte qualifiedARN := aws.ToString(latest.FunctionArn) d.Set("qualified_arn", qualifiedARN) - d.Set("qualified_invoke_arn", invokeARN(meta.(*conns.AWSClient), qualifiedARN)) + d.Set("qualified_invoke_arn", invokeARN(ctx, meta.(*conns.AWSClient), qualifiedARN)) d.Set(names.AttrVersion, latest.Version) setTagsOut(ctx, output.Tags) @@ -743,7 +744,7 @@ func resourceFunctionRead(ctx context.Context, d *schema.ResourceData, meta inte // in AWS GovCloud (US)) so we cannot just ignore the error as would typically. // Currently this functionality is not enabled in all Regions and returns ambiguous error codes // (e.g. AccessDeniedException), so we cannot just ignore the error as we would typically. - if partition, region := meta.(*conns.AWSClient).Partition, meta.(*conns.AWSClient).Region; partition == names.StandardPartitionID && signerServiceIsAvailable(region) { + if partition, region := meta.(*conns.AWSClient).Partition(ctx), meta.(*conns.AWSClient).Region; partition == endpoints.AwsPartitionID && signerServiceIsAvailable(region) { var codeSigningConfigARN string // Code Signing is only supported on zip packaged lambda functions. @@ -1383,9 +1384,9 @@ func needsFunctionConfigUpdate(d sdkv2.ResourceDiffer) bool { } // See https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-custom-integrations.html. -func invokeARN(c *conns.AWSClient, functionOrAliasARN string) string { +func invokeARN(ctx context.Context, c *conns.AWSClient, functionOrAliasARN string) string { return arn.ARN{ - Partition: c.Partition, + Partition: c.Partition(ctx), Service: "apigateway", Region: c.Region, AccountID: "lambda", diff --git a/internal/service/lambda/function_data_source.go b/internal/service/lambda/function_data_source.go index 4bd0ca2b2ba..5347ebf2f73 100644 --- a/internal/service/lambda/function_data_source.go +++ b/internal/service/lambda/function_data_source.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/lambda" awstypes "github.com/aws/aws-sdk-go-v2/service/lambda/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -320,7 +321,7 @@ func dataSourceFunctionRead(ctx context.Context, d *schema.ResourceData, meta in if output.Code != nil { d.Set("image_uri", output.Code.ImageUri) } - d.Set("invoke_arn", invokeARN(meta.(*conns.AWSClient), unqualifiedARN)) + d.Set("invoke_arn", invokeARN(ctx, meta.(*conns.AWSClient), unqualifiedARN)) d.Set(names.AttrKMSKeyARN, function.KMSKeyArn) d.Set("last_modified", function.LastModified) if err := d.Set("layers", flattenLayers(function.Layers)); err != nil { @@ -331,7 +332,7 @@ func dataSourceFunctionRead(ctx context.Context, d *schema.ResourceData, meta in } d.Set("memory_size", function.MemorySize) d.Set("qualified_arn", qualifiedARN) - d.Set("qualified_invoke_arn", invokeARN(meta.(*conns.AWSClient), qualifiedARN)) + d.Set("qualified_invoke_arn", invokeARN(ctx, meta.(*conns.AWSClient), qualifiedARN)) if output.Concurrency != nil { d.Set("reserved_concurrent_executions", output.Concurrency.ReservedConcurrentExecutions) } else { @@ -363,7 +364,7 @@ func dataSourceFunctionRead(ctx context.Context, d *schema.ResourceData, meta in setTagsOut(ctx, output.Tags) // See r/aws_lambda_function. - if partition, region := meta.(*conns.AWSClient).Partition, meta.(*conns.AWSClient).Region; partition == names.StandardPartitionID && signerServiceIsAvailable(region) { + if partition, region := meta.(*conns.AWSClient).Partition(ctx), meta.(*conns.AWSClient).Region; partition == endpoints.AwsPartitionID && signerServiceIsAvailable(region) { var codeSigningConfigARN string if function.PackageType == awstypes.PackageTypeZip { diff --git a/internal/service/lambda/function_recursion_config_test.go b/internal/service/lambda/function_recursion_config_test.go index a2c183ce5e2..06c1a9de5d4 100644 --- a/internal/service/lambda/function_recursion_config_test.go +++ b/internal/service/lambda/function_recursion_config_test.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/lambda" awstypes "github.com/aws/aws-sdk-go-v2/service/lambda/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -36,7 +37,7 @@ func TestAccLambdaFunctionRecursionConfig_basic(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.LambdaEndpointID) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -77,7 +78,7 @@ func TestAccLambdaFunctionRecursionConfig_update(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.LambdaEndpointID) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -125,7 +126,7 @@ func TestAccLambdaFunctionRecursionConfig_disappears_Function(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckPartitionHasService(t, names.LambdaEndpointID) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/lambda/function_test.go b/internal/service/lambda/function_test.go index 0831892037b..5a17323051e 100644 --- a/internal/service/lambda/function_test.go +++ b/internal/service/lambda/function_test.go @@ -18,6 +18,7 @@ import ( awstypes "github.com/aws/aws-sdk-go-v2/service/lambda/types" "github.com/aws/aws-sdk-go-v2/service/signer" signertypes "github.com/aws/aws-sdk-go-v2/service/signer/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -1261,7 +1262,7 @@ func TestAccLambdaFunction_tracing(t *testing.T) { resourceName := "aws_lambda_function.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LambdaServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckFunctionDestroy(ctx), diff --git a/internal/service/lambda/function_url_test.go b/internal/service/lambda/function_url_test.go index e1c07598fc9..8b6d7f13d0d 100644 --- a/internal/service/lambda/function_url_test.go +++ b/internal/service/lambda/function_url_test.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/lambda" awstypes "github.com/aws/aws-sdk-go-v2/service/lambda/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -21,7 +22,7 @@ import ( ) func testAccFunctionURLPreCheck(t *testing.T) { - acctest.PreCheckPartition(t, names.StandardPartitionID) + acctest.PreCheckPartition(t, endpoints.AwsPartitionID) } func TestAccLambdaFunctionURL_basic(t *testing.T) { diff --git a/internal/service/lambda/permission.go b/internal/service/lambda/permission.go index 7f9a0a75255..2e718ba1fbd 100644 --- a/internal/service/lambda/permission.go +++ b/internal/service/lambda/permission.go @@ -197,7 +197,7 @@ func resourcePermissionRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("qualifier", qualifier) // Save Lambda function name in the same format - if strings.HasPrefix(functionName, "arn:"+meta.(*conns.AWSClient).Partition+":lambda:") { + if strings.HasPrefix(functionName, "arn:"+meta.(*conns.AWSClient).Partition(ctx)+":lambda:") { // Strip qualifier off trimmed := strings.TrimSuffix(statement.Resource, ":"+qualifier) d.Set("function_name", trimmed) diff --git a/internal/service/lambda/runtime_management_config_test.go b/internal/service/lambda/runtime_management_config_test.go index 53ce489ce6a..816ce8b1ade 100644 --- a/internal/service/lambda/runtime_management_config_test.go +++ b/internal/service/lambda/runtime_management_config_test.go @@ -12,6 +12,7 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/service/lambda" "github.com/aws/aws-sdk-go-v2/service/lambda/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -109,7 +110,7 @@ func TestAccLambdaRuntimeManagementConfig_runtimeVersionARN(t *testing.T) { // There is currently no API to retrieve this ARN, so we have to hard-code // the value and restrict this test to us-west-2 in the standard commercial // partition. - acctest.PreCheckPartition(t, names.StandardPartitionID) + acctest.PreCheckPartition(t, endpoints.AwsPartitionID) acctest.PreCheckRegion(t, names.USWest2RegionID) acctest.PreCheckPartitionHasService(t, names.LambdaEndpointID) }, diff --git a/internal/service/lexmodels/bot.go b/internal/service/lexmodels/bot.go index 12896b85da5..7a5dd446e85 100644 --- a/internal/service/lexmodels/bot.go +++ b/internal/service/lexmodels/bot.go @@ -299,7 +299,7 @@ func resourceBotRead(ctx context.Context, d *schema.ResourceData, meta interface } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "lex", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/lexmodels/bot_alias.go b/internal/service/lexmodels/bot_alias.go index 9e6a798987d..bc27cfad6e7 100644 --- a/internal/service/lexmodels/bot_alias.go +++ b/internal/service/lexmodels/bot_alias.go @@ -199,7 +199,7 @@ func resourceBotAliasRead(ctx context.Context, d *schema.ResourceData, meta inte } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "lex", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/lexmodels/bot_alias_data_source.go b/internal/service/lexmodels/bot_alias_data_source.go index 4a38c55c25e..10539537afa 100644 --- a/internal/service/lexmodels/bot_alias_data_source.go +++ b/internal/service/lexmodels/bot_alias_data_source.go @@ -79,7 +79,7 @@ func dataSourceBotAliasRead(ctx context.Context, d *schema.ResourceData, meta in } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "lex", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/lexmodels/bot_data_source.go b/internal/service/lexmodels/bot_data_source.go index 413f0c07e07..b6d18609fed 100644 --- a/internal/service/lexmodels/bot_data_source.go +++ b/internal/service/lexmodels/bot_data_source.go @@ -106,7 +106,7 @@ func dataSourceBotRead(ctx context.Context, d *schema.ResourceData, meta interfa } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "lex", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/lexmodels/intent.go b/internal/service/lexmodels/intent.go index 8525d14370f..1f6bddf09be 100644 --- a/internal/service/lexmodels/intent.go +++ b/internal/service/lexmodels/intent.go @@ -369,7 +369,7 @@ func resourceIntentRead(ctx context.Context, d *schema.ResourceData, meta interf } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "lex", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/lexmodels/intent_data_source.go b/internal/service/lexmodels/intent_data_source.go index e63ac850804..eba04356ce4 100644 --- a/internal/service/lexmodels/intent_data_source.go +++ b/internal/service/lexmodels/intent_data_source.go @@ -85,7 +85,7 @@ func dataSourceIntentRead(ctx context.Context, d *schema.ResourceData, meta inte } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "lex", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/lexv2models/bot.go b/internal/service/lexv2models/bot.go index eb9c6f256f8..75e5b7f1b9e 100644 --- a/internal/service/lexv2models/bot.go +++ b/internal/service/lexv2models/bot.go @@ -10,7 +10,6 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/lexmodelsv2" awstypes "github.com/aws/aws-sdk-go-v2/service/lexmodelsv2/types" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" @@ -200,17 +199,11 @@ func (r *resourceBot) Create(ctx context.Context, req resource.CreateRequest, re ) return } - botArn := arn.ARN{ - Partition: r.Meta().Partition, - Service: "lex", - Region: r.Meta().Region, - AccountID: r.Meta().AccountID, - Resource: fmt.Sprintf("bot/%s", aws.ToString(out.BotId)), - }.String() + botARN := r.Meta().RegionalARN(ctx, "lex", fmt.Sprintf("bot/%s", aws.ToString(out.BotId))) plan.ID = flex.StringToFramework(ctx, out.BotId) state := plan state.Type = flex.StringValueToFramework(ctx, out.BotType) - state.ARN = flex.StringValueToFramework(ctx, botArn) + state.ARN = flex.StringValueToFramework(ctx, botARN) resp.Diagnostics.Append(resp.State.Set(ctx, state)...) @@ -246,14 +239,8 @@ func (r *resourceBot) Read(ctx context.Context, req resource.ReadRequest, resp * return } - botArn := arn.ARN{ - Partition: r.Meta().Partition, - Service: "lex", - Region: r.Meta().Region, - AccountID: r.Meta().AccountID, - Resource: fmt.Sprintf("bot/%s", aws.ToString(out.BotId)), - }.String() - state.ARN = flex.StringValueToFramework(ctx, botArn) + botARN := r.Meta().RegionalARN(ctx, "lex", fmt.Sprintf("bot/%s", aws.ToString(out.BotId))) + state.ARN = flex.StringValueToFramework(ctx, botARN) state.RoleARN = flex.StringToFrameworkARN(ctx, out.RoleArn) state.ID = flex.StringToFramework(ctx, out.BotId) state.Name = flex.StringToFramework(ctx, out.BotName) diff --git a/internal/service/logs/group_test.go b/internal/service/logs/group_test.go index 426f03e784a..01ea571cf66 100644 --- a/internal/service/logs/group_test.go +++ b/internal/service/logs/group_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -25,7 +26,7 @@ func TestAccLogsGroup_basic(t *testing.T) { resourceName := "aws_cloudwatch_log_group.test" expectedLogGroupClass := "STANDARD" - if acctest.Partition() != names.StandardPartitionID { + if acctest.Partition() != endpoints.AwsPartitionID { expectedLogGroupClass = "" } @@ -192,7 +193,7 @@ func TestAccLogsGroup_logGroupClass(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) // CloudWatch Logs IA is available in all AWS Commercial regions. - acctest.PreCheckPartition(t, names.StandardPartitionID) + acctest.PreCheckPartition(t, endpoints.AwsPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.LogsServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/memorydb/subnet_group_test.go b/internal/service/memorydb/subnet_group_test.go index c0747d7a297..3d9c31a19c2 100644 --- a/internal/service/memorydb/subnet_group_test.go +++ b/internal/service/memorydb/subnet_group_test.go @@ -8,6 +8,7 @@ import ( "fmt" "testing" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -19,7 +20,7 @@ import ( ) func testAccPreCheck(t *testing.T) { - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) } func TestAccMemoryDBSubnetGroup_basic(t *testing.T) { diff --git a/internal/service/meta/billing_service_account_data_source.go b/internal/service/meta/billing_service_account_data_source.go index bd98e3c37d7..863731077c8 100644 --- a/internal/service/meta/billing_service_account_data_source.go +++ b/internal/service/meta/billing_service_account_data_source.go @@ -55,7 +55,7 @@ func (d *billingServiceAccountDataSource) Read(ctx context.Context, request data const billingAccountID = "386209384616" arn := arn.ARN{ - Partition: d.Meta().Partition, + Partition: d.Meta().Partition(ctx), Service: "iam", AccountID: billingAccountID, Resource: "root", diff --git a/internal/service/meta/default_tags_data_source.go b/internal/service/meta/default_tags_data_source.go index e4fc47791f2..05796dd9f65 100644 --- a/internal/service/meta/default_tags_data_source.go +++ b/internal/service/meta/default_tags_data_source.go @@ -53,7 +53,7 @@ func (d *defaultTagsDataSource) Read(ctx context.Context, request datasource.Rea ignoreTagsConfig := d.Meta().IgnoreTagsConfig(ctx) tags := defaultTagsConfig.GetTags() - data.ID = fwflex.StringValueToFrameworkLegacy(ctx, d.Meta().Partition) + data.ID = fwflex.StringValueToFrameworkLegacy(ctx, d.Meta().Partition(ctx)) data.Tags = tftags.FlattenStringValueMap(ctx, tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig).Map()) response.Diagnostics.Append(response.State.Set(ctx, &data)...) diff --git a/internal/service/meta/partition_data_source.go b/internal/service/meta/partition_data_source.go index 26684a300a2..a8197182daa 100644 --- a/internal/service/meta/partition_data_source.go +++ b/internal/service/meta/partition_data_source.go @@ -57,8 +57,8 @@ func (d *partitionDataSource) Read(ctx context.Context, request datasource.ReadR } data.DNSSuffix = fwflex.StringValueToFrameworkLegacy(ctx, d.Meta().DNSSuffix(ctx)) - data.ID = fwflex.StringValueToFrameworkLegacy(ctx, d.Meta().Partition) - data.Partition = fwflex.StringValueToFrameworkLegacy(ctx, d.Meta().Partition) + data.ID = fwflex.StringValueToFrameworkLegacy(ctx, d.Meta().Partition(ctx)) + data.Partition = fwflex.StringValueToFrameworkLegacy(ctx, d.Meta().Partition(ctx)) data.ReverseDNSPrefix = fwflex.StringValueToFrameworkLegacy(ctx, d.Meta().ReverseDNSPrefix(ctx)) response.Diagnostics.Append(response.State.Set(ctx, &data)...) diff --git a/internal/service/meta/partition_data_source_test.go b/internal/service/meta/partition_data_source_test.go index 639f066e99a..a8b05099475 100644 --- a/internal/service/meta/partition_data_source_test.go +++ b/internal/service/meta/partition_data_source_test.go @@ -26,7 +26,7 @@ func TestAccMetaPartitionDataSource_basic(t *testing.T) { Config: testAccPartitionDataSourceConfig_basic, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrWith(dataSourceName, "partition", func(value string) error { - expected := acctest.Provider.Meta().(*conns.AWSClient).Partition + expected := acctest.Provider.Meta().(*conns.AWSClient).Partition(ctx) if value != expected { return fmt.Errorf("Incorrect Partition: expected %q, got %q", expected, value) } diff --git a/internal/service/meta/regions_data_source.go b/internal/service/meta/regions_data_source.go index ed167c0efca..532f184eaa4 100644 --- a/internal/service/meta/regions_data_source.go +++ b/internal/service/meta/regions_data_source.go @@ -77,7 +77,7 @@ func (d *regionsDataSource) Read(ctx context.Context, request datasource.ReadReq return } - data.ID = fwflex.StringValueToFrameworkLegacy(ctx, d.Meta().Partition) + data.ID = fwflex.StringValueToFrameworkLegacy(ctx, d.Meta().Partition(ctx)) names := tfslices.ApplyToAll(output.Regions, func(v awstypes.Region) string { return aws.ToString(v.RegionName) }) diff --git a/internal/service/meta/service_data_source_test.go b/internal/service/meta/service_data_source_test.go index 6541f718100..20fbd4a93ef 100644 --- a/internal/service/meta/service_data_source_test.go +++ b/internal/service/meta/service_data_source_test.go @@ -7,6 +7,7 @@ import ( "fmt" "testing" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" tfmeta "github.com/hashicorp/terraform-provider-aws/internal/service/meta" @@ -170,7 +171,7 @@ func TestAccMetaServiceDataSource_unsupported(t *testing.T) { Config: testAccServiceDataSourceConfig_unsupported(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(dataSourceName, names.AttrDNSName, fmt.Sprintf("%s.%s.%s", names.WAFEndpointID, names.USGovWest1RegionID, "amazonaws.com")), - resource.TestCheckResourceAttr(dataSourceName, "partition", names.USGovCloudPartitionID), + resource.TestCheckResourceAttr(dataSourceName, "partition", endpoints.AwsUsGovPartitionID), resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_prefix", "com.amazonaws"), resource.TestCheckResourceAttr(dataSourceName, names.AttrRegion, names.USGovWest1RegionID), resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "com.amazonaws", names.USGovWest1RegionID, names.WAFEndpointID)), diff --git a/internal/service/meta/service_principal_data_source.go b/internal/service/meta/service_principal_data_source.go index 79e372e4cbb..21a22bccd82 100644 --- a/internal/service/meta/service_principal_data_source.go +++ b/internal/service/meta/service_principal_data_source.go @@ -91,20 +91,14 @@ func (d *servicePrincipalDataSource) Read(ctx context.Context, request datasourc region = matchingRegion } - partition := names.PartitionForRegion(region.ID()) + regionID := region.ID() + serviceName := fwflex.StringValueFromFramework(ctx, data.ServiceName) + sourceServicePrincipal := servicePrincipalNameForPartition(serviceName, names.PartitionForRegion(regionID)) - serviceName := "" - - if !data.ServiceName.IsNull() { - serviceName = data.ServiceName.ValueString() - } - - sourceServicePrincipal := names.ServicePrincipalNameForPartition(serviceName, partition) - - data.ID = fwflex.StringValueToFrameworkLegacy(ctx, serviceName+"."+region.ID()+"."+sourceServicePrincipal) + data.ID = fwflex.StringValueToFrameworkLegacy(ctx, serviceName+"."+regionID+"."+sourceServicePrincipal) data.Name = fwflex.StringValueToFrameworkLegacy(ctx, serviceName+"."+sourceServicePrincipal) data.Suffix = fwflex.StringValueToFrameworkLegacy(ctx, sourceServicePrincipal) - data.Region = fwflex.StringValueToFrameworkLegacy(ctx, region.ID()) + data.Region = fwflex.StringValueToFrameworkLegacy(ctx, regionID) response.Diagnostics.Append(response.State.Set(ctx, &data)...) } @@ -116,3 +110,35 @@ type servicePrincipalDataSourceModel struct { ServiceName types.String `tfsdk:"service_name"` Suffix types.String `tfsdk:"suffix"` } + +// SPN region unique taken from +// https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/region-info/lib/default.ts +func servicePrincipalNameForPartition(service string, partition endpoints.Partition) string { + if partitionID := partition.ID(); service != "" && partitionID != endpoints.AwsPartitionID { + switch partitionID { + case endpoints.AwsIsoPartitionID: + switch service { + case "cloudhsm", + "config", + "logs", + "workspaces": + return partition.DNSSuffix() + } + case endpoints.AwsIsoBPartitionID: + switch service { + case "dms", + "logs": + return partition.DNSSuffix() + } + case endpoints.AwsCnPartitionID: + switch service { + case "codedeploy", + "elasticmapreduce", + "logs": + return partition.DNSSuffix() + } + } + } + + return "amazonaws.com" +} diff --git a/internal/service/neptune/cluster_endpoint.go b/internal/service/neptune/cluster_endpoint.go index 86bf7119bfd..e951927bac8 100644 --- a/internal/service/neptune/cluster_endpoint.go +++ b/internal/service/neptune/cluster_endpoint.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/neptune" awstypes "github.com/aws/aws-sdk-go-v2/service/neptune/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -105,7 +106,7 @@ func resourceClusterEndpointCreate(ctx context.Context, d *schema.ResourceData, } // Tags are currently only supported in AWS Commercial. - if meta.(*conns.AWSClient).Partition != names.StandardPartitionID { + if meta.(*conns.AWSClient).Partition(ctx) != endpoints.AwsPartitionID { input.Tags = nil } diff --git a/internal/service/neptune/cluster_endpoint_test.go b/internal/service/neptune/cluster_endpoint_test.go index 69857868826..2d539cbb04c 100644 --- a/internal/service/neptune/cluster_endpoint_test.go +++ b/internal/service/neptune/cluster_endpoint_test.go @@ -10,6 +10,7 @@ import ( "github.com/YakDriver/regexache" awstypes "github.com/aws/aws-sdk-go-v2/service/neptune/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -61,7 +62,7 @@ func TestAccNeptuneClusterEndpoint_tags(t *testing.T) { resourceName := "aws_neptune_cluster_endpoint.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.NeptuneServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckClusterEndpointDestroy(ctx), diff --git a/internal/service/networkmanager/connect_attachment.go b/internal/service/networkmanager/connect_attachment.go index 8da4936f69f..6897ae3d255 100644 --- a/internal/service/networkmanager/connect_attachment.go +++ b/internal/service/networkmanager/connect_attachment.go @@ -214,7 +214,7 @@ func resourceConnectAttachmentRead(ctx context.Context, d *schema.ResourceData, a := connectAttachment.Attachment arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "networkmanager", AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("attachment/%s", d.Id()), diff --git a/internal/service/networkmanager/connect_peer.go b/internal/service/networkmanager/connect_peer.go index a295dc60b92..b8bba578f6a 100644 --- a/internal/service/networkmanager/connect_peer.go +++ b/internal/service/networkmanager/connect_peer.go @@ -278,7 +278,7 @@ func resourceConnectPeerRead(ctx context.Context, d *schema.ResourceData, meta i } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "networkmanager", AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("connect-peer/%s", d.Id()), diff --git a/internal/service/networkmanager/site_to_site_vpn_attachment.go b/internal/service/networkmanager/site_to_site_vpn_attachment.go index a06aa0d8a60..ebe2225a8b8 100644 --- a/internal/service/networkmanager/site_to_site_vpn_attachment.go +++ b/internal/service/networkmanager/site_to_site_vpn_attachment.go @@ -150,7 +150,7 @@ func resourceSiteToSiteVPNAttachmentRead(ctx context.Context, d *schema.Resource a := vpnAttachment.Attachment arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "networkmanager", AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("attachment/%s", d.Id()), diff --git a/internal/service/networkmanager/transit_gateway_peering.go b/internal/service/networkmanager/transit_gateway_peering.go index bf2164db16d..ee11704df21 100644 --- a/internal/service/networkmanager/transit_gateway_peering.go +++ b/internal/service/networkmanager/transit_gateway_peering.go @@ -140,7 +140,7 @@ func resourceTransitGatewayPeeringRead(ctx context.Context, d *schema.ResourceDa p := transitGatewayPeering.Peering arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "networkmanager", AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("peering/%s", d.Id()), diff --git a/internal/service/networkmanager/transit_gateway_route_table_attachment.go b/internal/service/networkmanager/transit_gateway_route_table_attachment.go index 0d8222fdfe2..a21ca03525a 100644 --- a/internal/service/networkmanager/transit_gateway_route_table_attachment.go +++ b/internal/service/networkmanager/transit_gateway_route_table_attachment.go @@ -152,7 +152,7 @@ func resourceTransitGatewayRouteTableAttachmentRead(ctx context.Context, d *sche a := transitGatewayRouteTableAttachment.Attachment arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "networkmanager", AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("attachment/%s", d.Id()), diff --git a/internal/service/networkmanager/vpc_attachment.go b/internal/service/networkmanager/vpc_attachment.go index 3cbac4b54b8..69851b84eb6 100644 --- a/internal/service/networkmanager/vpc_attachment.go +++ b/internal/service/networkmanager/vpc_attachment.go @@ -212,7 +212,7 @@ func resourceVPCAttachmentRead(ctx context.Context, d *schema.ResourceData, meta a := vpcAttachment.Attachment arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "networkmanager", AccountID: meta.(*conns.AWSClient).AccountID, Resource: fmt.Sprintf("attachment/%s", d.Id()), diff --git a/internal/service/opensearch/domain_policy_test.go b/internal/service/opensearch/domain_policy_test.go index b52df99049a..010822b7102 100644 --- a/internal/service/opensearch/domain_policy_test.go +++ b/internal/service/opensearch/domain_policy_test.go @@ -63,7 +63,7 @@ func TestAccOpenSearchDomainPolicy_basic(t *testing.T) { testAccCheckDomainExists(ctx, "aws_opensearch_domain.test", &domain), func(s *terraform.State) error { awsClient := acctest.Provider.Meta().(*conns.AWSClient) - expectedArn, err := buildDomainARN(name, awsClient.Partition, awsClient.AccountID, awsClient.Region) + expectedArn, err := buildDomainARN(name, awsClient.Partition(ctx), awsClient.AccountID, awsClient.Region) if err != nil { return err } diff --git a/internal/service/opsworks/stack.go b/internal/service/opsworks/stack.go index 18de0e8ebb0..3e118f417dd 100644 --- a/internal/service/opsworks/stack.go +++ b/internal/service/opsworks/stack.go @@ -295,7 +295,7 @@ func resourceStackCreate(ctx context.Context, d *schema.ResourceData, meta inter d.SetId(aws.ToString(outputRaw.(*opsworks.CreateStackOutput).StackId)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.OpsWorks, Region: region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/rbin/rule.go b/internal/service/rbin/rule.go index f1e6e92a249..0ddbe950c32 100644 --- a/internal/service/rbin/rule.go +++ b/internal/service/rbin/rule.go @@ -211,7 +211,7 @@ func resourceRuleRead(ctx context.Context, d *schema.ResourceData, meta interfac } ruleArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: rbin.ServiceID, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/rds/cluster_activity_stream_test.go b/internal/service/rds/cluster_activity_stream_test.go index 90972e11844..845ec9ad067 100644 --- a/internal/service/rds/cluster_activity_stream_test.go +++ b/internal/service/rds/cluster_activity_stream_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/aws/aws-sdk-go-v2/service/rds/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -28,7 +29,7 @@ func TestAccRDSClusterActivityStream_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartition(t, names.StandardPartitionID) + acctest.PreCheckPartition(t, endpoints.AwsPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.RDSServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -61,7 +62,7 @@ func TestAccRDSClusterActivityStream_disappears(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartition(t, names.StandardPartitionID) + acctest.PreCheckPartition(t, endpoints.AwsPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.RDSServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/rds/instance_test.go b/internal/service/rds/instance_test.go index 8a552d6357a..e5c19c2ab75 100644 --- a/internal/service/rds/instance_test.go +++ b/internal/service/rds/instance_test.go @@ -16,6 +16,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/rds" "github.com/aws/aws-sdk-go-v2/service/rds/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -348,7 +349,7 @@ func TestAccRDSInstance_customIAMInstanceProfile(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.RDSServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/redshift/cluster.go b/internal/service/redshift/cluster.go index 1dcf7b6eac1..10b94152367 100644 --- a/internal/service/redshift/cluster.go +++ b/internal/service/redshift/cluster.go @@ -658,7 +658,7 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set("allow_version_upgrade", rsc.AllowVersionUpgrade) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.Redshift, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/redshift/cluster_data_source.go b/internal/service/redshift/cluster_data_source.go index d55fcfd7798..9286d0f308c 100644 --- a/internal/service/redshift/cluster_data_source.go +++ b/internal/service/redshift/cluster_data_source.go @@ -221,7 +221,7 @@ func dataSourceClusterRead(ctx context.Context, d *schema.ResourceData, meta int d.SetId(clusterID) d.Set("allow_version_upgrade", rsc.AllowVersionUpgrade) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.Redshift, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/redshift/event_subscription.go b/internal/service/redshift/event_subscription.go index 761f6ff868e..cb2e3acd425 100644 --- a/internal/service/redshift/event_subscription.go +++ b/internal/service/redshift/event_subscription.go @@ -170,7 +170,7 @@ func resourceEventSubscriptionRead(ctx context.Context, d *schema.ResourceData, } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.Redshift, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/redshift/hsm_client_certificate.go b/internal/service/redshift/hsm_client_certificate.go index 9df6c0b1a9d..140c2616bca 100644 --- a/internal/service/redshift/hsm_client_certificate.go +++ b/internal/service/redshift/hsm_client_certificate.go @@ -96,7 +96,7 @@ func resourceHSMClientCertificateRead(ctx context.Context, d *schema.ResourceDat } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.Redshift, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/redshift/hsm_configuration.go b/internal/service/redshift/hsm_configuration.go index 1b3c25a67f0..850e076187f 100644 --- a/internal/service/redshift/hsm_configuration.go +++ b/internal/service/redshift/hsm_configuration.go @@ -123,7 +123,7 @@ func resourceHSMConfigurationRead(ctx context.Context, d *schema.ResourceData, m } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.Redshift, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/redshift/parameter_group.go b/internal/service/redshift/parameter_group.go index 77b03bfca47..54483a22772 100644 --- a/internal/service/redshift/parameter_group.go +++ b/internal/service/redshift/parameter_group.go @@ -148,7 +148,7 @@ func resourceParameterGroupRead(ctx context.Context, d *schema.ResourceData, met } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.Redshift, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/redshift/service_account_data_source.go b/internal/service/redshift/service_account_data_source.go index 33073f7e084..221b9b2f8e0 100644 --- a/internal/service/redshift/service_account_data_source.go +++ b/internal/service/redshift/service_account_data_source.go @@ -77,7 +77,7 @@ func dataSourceServiceAccountRead(ctx context.Context, d *schema.ResourceData, m if accid, ok := ServiceAccountPerRegionMap[region]; ok { d.SetId(accid) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "iam", AccountID: accid, Resource: "user/logs", diff --git a/internal/service/redshift/snapshot_copy_grant.go b/internal/service/redshift/snapshot_copy_grant.go index bb51b9f7021..f3afd0785a0 100644 --- a/internal/service/redshift/snapshot_copy_grant.go +++ b/internal/service/redshift/snapshot_copy_grant.go @@ -112,7 +112,7 @@ func resourceSnapshotCopyGrantRead(ctx context.Context, d *schema.ResourceData, } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.Redshift, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/redshift/snapshot_schedule.go b/internal/service/redshift/snapshot_schedule.go index df405972321..63408aa23a3 100644 --- a/internal/service/redshift/snapshot_schedule.go +++ b/internal/service/redshift/snapshot_schedule.go @@ -123,7 +123,7 @@ func resourceSnapshotScheduleRead(ctx context.Context, d *schema.ResourceData, m } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.Redshift, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/redshift/subnet_group.go b/internal/service/redshift/subnet_group.go index 6812406afad..f1663cad7cf 100644 --- a/internal/service/redshift/subnet_group.go +++ b/internal/service/redshift/subnet_group.go @@ -118,7 +118,7 @@ func resourceSubnetGroupRead(ctx context.Context, d *schema.ResourceData, meta i } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.Redshift, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/redshift/subnet_group_data_source.go b/internal/service/redshift/subnet_group_data_source.go index 6529a5c817c..216ee80516a 100644 --- a/internal/service/redshift/subnet_group_data_source.go +++ b/internal/service/redshift/subnet_group_data_source.go @@ -58,7 +58,7 @@ func dataSourceSubnetGroupRead(ctx context.Context, d *schema.ResourceData, meta d.SetId(aws.ToString(subnetgroup.ClusterSubnetGroupName)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.Redshift, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/redshift/usage_limit.go b/internal/service/redshift/usage_limit.go index 6ed1411d5a1..b1b7b12dbc6 100644 --- a/internal/service/redshift/usage_limit.go +++ b/internal/service/redshift/usage_limit.go @@ -133,7 +133,7 @@ func resourceUsageLimitRead(ctx context.Context, d *schema.ResourceData, meta in } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: names.Redshift, Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/resiliencehub/resiliency_policy_test.go b/internal/service/resiliencehub/resiliency_policy_test.go index b91f56aac2b..d778366aa5b 100644 --- a/internal/service/resiliencehub/resiliency_policy_test.go +++ b/internal/service/resiliencehub/resiliency_policy_test.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/resiliencehub" awstypes "github.com/aws/aws-sdk-go-v2/service/resiliencehub/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-testing/compare" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -41,7 +42,7 @@ func TestAccResilienceHubResiliencyPolicy_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.ResilienceHubServiceID), @@ -93,7 +94,7 @@ func TestAccResilienceHubResiliencyPolicy_dataLocationConstraint(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.ResilienceHubServiceID), @@ -168,7 +169,7 @@ func TestAccResilienceHubResiliencyPolicy_description(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.ResilienceHubServiceID), @@ -239,7 +240,7 @@ func TestAccResilienceHubResiliencyPolicy_name(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.ResilienceHubServiceID), @@ -314,7 +315,7 @@ func TestAccResilienceHubResiliencyPolicy_policy(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.ResilienceHubServiceID), @@ -432,7 +433,7 @@ func TestAccResilienceHubResiliencyPolicy_policyWithRegion(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.ResilienceHubServiceID), @@ -545,7 +546,7 @@ func TestAccResilienceHubResiliencyPolicy_tier(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.ResilienceHubServiceID), @@ -613,7 +614,7 @@ func TestAccResilienceHubResiliencyPolicy_disappears(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) testAccPreCheck(ctx, t) }, ErrorCheck: acctest.ErrorCheck(t, names.ResilienceHubServiceID), diff --git a/internal/service/resourcegroupstaggingapi/resources_data_source.go b/internal/service/resourcegroupstaggingapi/resources_data_source.go index 177868c90bb..27cab8d865f 100644 --- a/internal/service/resourcegroupstaggingapi/resources_data_source.go +++ b/internal/service/resourcegroupstaggingapi/resources_data_source.go @@ -142,7 +142,7 @@ func dataSourceResourcesRead(ctx context.Context, d *schema.ResourceData, meta i taggings = append(taggings, page.ResourceTagMappingList...) } - d.SetId(meta.(*conns.AWSClient).Partition) + d.SetId(meta.(*conns.AWSClient).Partition(ctx)) if err := d.Set("resource_tag_mapping_list", flattenResourceTagMappings(ctx, taggings)); err != nil { return sdkdiag.AppendErrorf(diags, "setting resource tag mapping list: %s", err) diff --git a/internal/service/route53/delegation_set.go b/internal/service/route53/delegation_set.go index 629aed1cc60..73989f44840 100644 --- a/internal/service/route53/delegation_set.go +++ b/internal/service/route53/delegation_set.go @@ -97,7 +97,7 @@ func resourceDelegationSetRead(ctx context.Context, d *schema.ResourceData, meta } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "route53", Resource: "delegationset/" + d.Id(), }.String() diff --git a/internal/service/route53/delegation_set_data_source.go b/internal/service/route53/delegation_set_data_source.go index 78203804ff5..83582f100ad 100644 --- a/internal/service/route53/delegation_set_data_source.go +++ b/internal/service/route53/delegation_set_data_source.go @@ -54,7 +54,7 @@ func dataSourceDelegationSetRead(ctx context.Context, d *schema.ResourceData, me d.SetId(id) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "route53", Resource: "delegationset/" + d.Id(), }.String() diff --git a/internal/service/route53/health_check.go b/internal/service/route53/health_check.go index 745e21f37ca..b0de6b40e30 100644 --- a/internal/service/route53/health_check.go +++ b/internal/service/route53/health_check.go @@ -310,7 +310,7 @@ func resourceHealthCheckRead(ctx context.Context, d *schema.ResourceData, meta i } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "route53", Resource: "healthcheck/" + d.Id(), }.String() diff --git a/internal/service/route53/health_check_test.go b/internal/service/route53/health_check_test.go index 5bf8a6b6609..fe686309f91 100644 --- a/internal/service/route53/health_check_test.go +++ b/internal/service/route53/health_check_test.go @@ -11,6 +11,7 @@ import ( "github.com/YakDriver/regexache" awstypes "github.com/aws/aws-sdk-go-v2/service/route53/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -174,7 +175,7 @@ func TestAccRoute53HealthCheck_withHealthCheckRegions(t *testing.T) { resourceName := "aws_route53_health_check.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartition(t, names.StandardPartitionID) }, // GovCloud has 2 regions, test requires 3 + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartition(t, endpoints.AwsPartitionID) }, // GovCloud has 2 regions, test requires 3 ErrorCheck: acctest.ErrorCheck(t, names.Route53ServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckHealthCheckDestroy(ctx), diff --git a/internal/service/route53/query_log.go b/internal/service/route53/query_log.go index 1d447f84e78..b258c2039cd 100644 --- a/internal/service/route53/query_log.go +++ b/internal/service/route53/query_log.go @@ -90,7 +90,7 @@ func resourceQueryLogRead(ctx context.Context, d *schema.ResourceData, meta inte } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "route53", Resource: "queryloggingconfig/" + d.Id(), }.String() diff --git a/internal/service/route53/service_package.go b/internal/service/route53/service_package.go index 1b84a77adec..f3733ce2bc2 100644 --- a/internal/service/route53/service_package.go +++ b/internal/service/route53/service_package.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/route53" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -22,7 +23,7 @@ func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) ( func(o *route53.Options) { // Always override the service region switch config["partition"].(string) { - case names.StandardPartitionID: + case endpoints.AwsPartitionID: // https://docs.aws.amazon.com/general/latest/gr/r53.html Setting default to us-east-1. if cfg.Region != names.USEast1RegionID { tflog.Info(ctx, "overriding region", map[string]any{ @@ -31,14 +32,14 @@ func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) ( }) } o.Region = names.USEast1RegionID - case names.ChinaPartitionID: + case endpoints.AwsCnPartitionID: // The AWS Go SDK is missing endpoint information for Route 53 in the AWS China partition. // This can likely be removed in the future. if aws.ToString(o.BaseEndpoint) == "" { o.BaseEndpoint = aws.String("https://api.route53.cn") } o.Region = names.CNNorthwest1RegionID - case names.USGovCloudPartitionID: + case endpoints.AwsUsGovPartitionID: if cfg.Region != names.USGovWest1RegionID { tflog.Info(ctx, "overriding region", map[string]any{ "original_region": cfg.Region, diff --git a/internal/service/route53/traffic_policy_instance_test.go b/internal/service/route53/traffic_policy_instance_test.go index 558392f4ffd..6a4cdb5d22b 100644 --- a/internal/service/route53/traffic_policy_instance_test.go +++ b/internal/service/route53/traffic_policy_instance_test.go @@ -9,6 +9,7 @@ import ( "testing" awstypes "github.com/aws/aws-sdk-go-v2/service/route53/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -20,7 +21,7 @@ import ( ) func testAccPreCheckTrafficPolicy(t *testing.T) { - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) } func TestAccRoute53TrafficPolicyInstance_basic(t *testing.T) { diff --git a/internal/service/route53/zone.go b/internal/service/route53/zone.go index 940e3bf78db..fab2d7cd8f5 100644 --- a/internal/service/route53/zone.go +++ b/internal/service/route53/zone.go @@ -193,7 +193,7 @@ func resourceZoneRead(ctx context.Context, d *schema.ResourceData, meta interfac zoneID := cleanZoneID(aws.ToString(output.HostedZone.Id)) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "route53", Resource: "hostedzone/" + zoneID, }.String() diff --git a/internal/service/route53/zone_data_source.go b/internal/service/route53/zone_data_source.go index c4581cb186d..7d4093ab7e3 100644 --- a/internal/service/route53/zone_data_source.go +++ b/internal/service/route53/zone_data_source.go @@ -155,7 +155,7 @@ func dataSourceZoneRead(ctx context.Context, d *schema.ResourceData, meta interf hostedZoneID := cleanZoneID(aws.ToString(hostedZone.Id)) d.SetId(hostedZoneID) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "route53", Resource: "hostedzone/" + d.Id(), }.String() diff --git a/internal/service/route53domains/service_package.go b/internal/service/route53domains/service_package.go index 61d598743f1..374fb73efb6 100644 --- a/internal/service/route53domains/service_package.go +++ b/internal/service/route53domains/service_package.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/route53domains" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -20,7 +21,7 @@ func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) ( route53domains.WithEndpointResolverV2(newEndpointResolverV2()), withBaseEndpoint(config[names.AttrEndpoint].(string)), func(o *route53domains.Options) { - if config["partition"].(string) == names.StandardPartitionID { + if config["partition"].(string) == endpoints.AwsPartitionID { // Route 53 Domains is only available in AWS Commercial us-east-1 Region. if cfg.Region != names.USEast1RegionID { tflog.Info(ctx, "overriding region", map[string]any{ diff --git a/internal/service/route53profiles/association.go b/internal/service/route53profiles/association.go index 7511a8a5544..ed90c77ffae 100644 --- a/internal/service/route53profiles/association.go +++ b/internal/service/route53profiles/association.go @@ -11,7 +11,6 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/route53profiles" awstypes "github.com/aws/aws-sdk-go-v2/service/route53profiles/types" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" @@ -158,16 +157,8 @@ func (r *resourceAssociation) Create(ctx context.Context, req resource.CreateReq } data.ID = flex.StringToFramework(ctx, out.ProfileAssociation.Id) - - associationArn := arn.ARN{ - Partition: r.Meta().Partition, - Service: "route53profiles", - Region: r.Meta().Region, - AccountID: r.Meta().AccountID, - Resource: fmt.Sprintf("profile-association/%s", aws.ToString(out.ProfileAssociation.Id)), - }.String() - - data.ARN = flex.StringValueToFramework(ctx, associationArn) + associationARN := r.Meta().RegionalARN(ctx, "route53profiles", fmt.Sprintf("profile-association/%s", aws.ToString(out.ProfileAssociation.Id))) + data.ARN = flex.StringValueToFramework(ctx, associationARN) createTimeout := r.CreateTimeout(ctx, data.Timeouts) profileAssociation, err := waitAssociationCreated(ctx, conn, data.ID.ValueString(), createTimeout) @@ -209,14 +200,8 @@ func (r *resourceAssociation) Read(ctx context.Context, req resource.ReadRequest return } - associationArn := arn.ARN{ - Partition: r.Meta().Partition, - Service: "route53profiles", - Region: r.Meta().Region, - AccountID: r.Meta().AccountID, - Resource: fmt.Sprintf("profile-association/%s", aws.ToString(out.Id)), - }.String() - state.ARN = flex.StringValueToFramework(ctx, associationArn) + associationARN := r.Meta().RegionalARN(ctx, "route53profiles", fmt.Sprintf("profile-association/%s", aws.ToString(out.Id))) + state.ARN = flex.StringValueToFramework(ctx, associationARN) resp.Diagnostics.Append(flex.Flatten(ctx, out, &state)...) if resp.Diagnostics.HasError() { diff --git a/internal/service/route53recoverycontrolconfig/service_package.go b/internal/service/route53recoverycontrolconfig/service_package.go index deecc258267..2f80dd5fa3d 100644 --- a/internal/service/route53recoverycontrolconfig/service_package.go +++ b/internal/service/route53recoverycontrolconfig/service_package.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" r53rcc "github.com/aws/aws-sdk-go-v2/service/route53recoverycontrolconfig" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -22,7 +23,7 @@ func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) ( func(o *r53rcc.Options) { // Always override the service region switch config["partition"].(string) { - case names.StandardPartitionID: + case endpoints.AwsPartitionID: // https://docs.aws.amazon.com/general/latest/gr/r53arc.html Setting default to us-west-2. if cfg.Region != names.USWest2RegionID { tflog.Info(ctx, "overriding region", map[string]any{ diff --git a/internal/service/route53recoveryreadiness/service_package.go b/internal/service/route53recoveryreadiness/service_package.go index 779b964ede9..a520f0cdf88 100644 --- a/internal/service/route53recoveryreadiness/service_package.go +++ b/internal/service/route53recoveryreadiness/service_package.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/route53recoveryreadiness" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -22,7 +23,7 @@ func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) ( func(o *route53recoveryreadiness.Options) { // Always override the service region switch config["partition"].(string) { - case names.StandardPartitionID: + case endpoints.AwsPartitionID: // https://docs.aws.amazon.com/general/latest/gr/r53arc.html Setting default to us-west-2. if cfg.Region != names.USWest2RegionID { tflog.Info(ctx, "overriding region", map[string]any{ diff --git a/internal/service/route53resolver/dnssec_config.go b/internal/service/route53resolver/dnssec_config.go index e9b7e2d763b..35ce97be053 100644 --- a/internal/service/route53resolver/dnssec_config.go +++ b/internal/service/route53resolver/dnssec_config.go @@ -100,7 +100,7 @@ func resourceDNSSECConfigRead(ctx context.Context, d *schema.ResourceData, meta ownerID := aws.ToString(dnssecConfig.OwnerId) resourceID := aws.ToString(dnssecConfig.ResourceId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "route53resolver", Region: meta.(*conns.AWSClient).Region, AccountID: ownerID, diff --git a/internal/service/rum/app_monitor.go b/internal/service/rum/app_monitor.go index f634adb088c..1b51a1a7106 100644 --- a/internal/service/rum/app_monitor.go +++ b/internal/service/rum/app_monitor.go @@ -209,7 +209,7 @@ func resourceAppMonitorRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("app_monitor_id", appMon.Id) name := aws.ToString(appMon.Name) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "rum", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/s3/bucket.go b/internal/service/s3/bucket.go index d4be72a0cee..21f85025f51 100644 --- a/internal/service/s3/bucket.go +++ b/internal/service/s3/bucket.go @@ -22,6 +22,7 @@ import ( "github.com/aws/aws-sdk-go-v2/feature/s3/manager" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" @@ -719,7 +720,7 @@ func resourceBucketCreate(ctx context.Context, d *schema.ResourceData, meta inte // Special case: us-east-1 does not return error if the bucket already exists and is owned by // current account. It also resets the Bucket ACLs. - if region == names.USEast1RegionID { + if region == endpoints.UsEast1RegionID { if err := findBucket(ctx, conn, bucket); err == nil { return sdkdiag.AppendErrorf(diags, "creating S3 Bucket (%s): %s", bucket, errors.New(errCodeBucketAlreadyExists)) } @@ -740,7 +741,7 @@ func resourceBucketCreate(ctx context.Context, d *schema.ResourceData, meta inte } // See https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html#AmazonS3-CreateBucket-request-LocationConstraint. - if region != names.USEast1RegionID { + if region != endpoints.UsEast1RegionID { input.CreateBucketConfiguration = &types.CreateBucketConfiguration{ LocationConstraint: types.BucketLocationConstraint(region), } @@ -798,7 +799,7 @@ func resourceBucketRead(ctx context.Context, d *schema.ResourceData, meta interf } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "s3", Resource: d.Id(), }.String() @@ -1107,7 +1108,7 @@ func resourceBucketRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set("object_lock_configuration", nil) d.Set("object_lock_enabled", nil) default: - if partition := meta.(*conns.AWSClient).Partition; partition == names.StandardPartitionID || partition == names.USGovCloudPartitionID { + if partition := meta.(*conns.AWSClient).Partition(ctx); partition == endpoints.AwsPartitionID || partition == endpoints.AwsUsGovPartitionID { return sdkdiag.AppendErrorf(diags, "reading S3 Bucket (%s) object lock configuration: %s", d.Id(), err) } log.Printf("[WARN] Unable to read S3 Bucket (%s) Object Lock Configuration: %s", d.Id(), err) @@ -1668,7 +1669,7 @@ func bucketRegionalDomainName(bucket, region string) string { if region == "" { return fmt.Sprintf("%s.s3.amazonaws.com", bucket) //lintignore:AWSR001 } - return fmt.Sprintf("%s.s3.%s.%s", bucket, region, names.DNSSuffixForPartition(names.PartitionForRegion(region))) + return fmt.Sprintf("%s.s3.%s.%s", bucket, region, names.PartitionForRegion(region).DNSSuffix()) } func bucketWebsiteEndpointAndDomain(bucket, region string) (string, string) { @@ -1677,28 +1678,27 @@ func bucketWebsiteEndpointAndDomain(bucket, region string) (string, string) { // Default to us-east-1 if the bucket doesn't have a region: // http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETlocation.html if region == "" { - region = names.USEast1RegionID + region = endpoints.UsEast1RegionID } // Different regions have different syntax for website endpoints: // https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html // https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_website_region_endpoints oldRegions := []string{ - names.APNortheast1RegionID, - names.APSoutheast1RegionID, - names.APSoutheast2RegionID, - names.EUWest1RegionID, - names.SAEast1RegionID, - names.USEast1RegionID, - names.USGovWest1RegionID, - names.USWest1RegionID, - names.USWest2RegionID, + endpoints.ApNortheast1RegionID, + endpoints.ApSoutheast1RegionID, + endpoints.ApSoutheast2RegionID, + endpoints.EuWest1RegionID, + endpoints.SaEast1RegionID, + endpoints.UsEast1RegionID, + endpoints.UsGovWest1RegionID, + endpoints.UsWest1RegionID, + endpoints.UsWest2RegionID, } if slices.Contains(oldRegions, region) { domain = fmt.Sprintf("s3-website-%s.amazonaws.com", region) //lintignore:AWSR001 } else { - dnsSuffix := names.DNSSuffixForPartition(names.PartitionForRegion(region)) - domain = fmt.Sprintf("s3-website.%s.%s", region, dnsSuffix) + domain = fmt.Sprintf("s3-website.%s.%s", region, names.PartitionForRegion(region).DNSSuffix()) } return fmt.Sprintf("%s.%s", bucket, domain), domain @@ -2962,7 +2962,7 @@ func flattenObjectLockConfiguration(apiObject *types.ObjectLockConfiguration) [] // Buckets outside of this region have to be DNS-compliant. After the same restrictions are // applied to buckets in the us-east-1 region, this function can be refactored as a SchemaValidateFunc func validBucketName(value string, region string) error { - if region != names.USEast1RegionID { + if region != endpoints.UsEast1RegionID { if (len(value) < 3) || (len(value) > 63) { return fmt.Errorf("%q must contain from 3 to 63 characters", value) } diff --git a/internal/service/s3/bucket_data_source.go b/internal/service/s3/bucket_data_source.go index 10ceae523e1..7f4455a0dbc 100644 --- a/internal/service/s3/bucket_data_source.go +++ b/internal/service/s3/bucket_data_source.go @@ -87,7 +87,7 @@ func dataSourceBucketRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set(names.AttrARN, bucket) } else { arn := arn.ARN{ - Partition: awsClient.Partition, + Partition: awsClient.Partition(ctx), Service: "s3", Resource: bucket, }.String() diff --git a/internal/service/s3/bucket_object.go b/internal/service/s3/bucket_object.go index 631a49255c5..535382eae74 100644 --- a/internal/service/s3/bucket_object.go +++ b/internal/service/s3/bucket_object.go @@ -220,7 +220,7 @@ func resourceBucketObjectRead(ctx context.Context, d *schema.ResourceData, meta return sdkdiag.AppendErrorf(diags, "reading S3 Object (%s): %s", d.Id(), err) } - arn, err := newObjectARN(meta.(*conns.AWSClient).Partition, bucket, key) + arn, err := newObjectARN(meta.(*conns.AWSClient).Partition(ctx), bucket, key) if err != nil { return sdkdiag.AppendErrorf(diags, "reading S3 Object (%s): %s", d.Id(), err) } diff --git a/internal/service/s3/bucket_object_data_source.go b/internal/service/s3/bucket_object_data_source.go index bcd732bbc9e..579bfce3292 100644 --- a/internal/service/s3/bucket_object_data_source.go +++ b/internal/service/s3/bucket_object_data_source.go @@ -174,7 +174,7 @@ func dataSourceBucketObjectRead(ctx context.Context, d *schema.ResourceData, met } d.SetId(id) - arn, err := newObjectARN(meta.(*conns.AWSClient).Partition, bucket, key) + arn, err := newObjectARN(meta.(*conns.AWSClient).Partition(ctx), bucket, key) if err != nil { return sdkdiag.AppendErrorf(diags, "reading S3 Bucket (%s) Object (%s): %s", bucket, key, err) } diff --git a/internal/service/s3/bucket_test.go b/internal/service/s3/bucket_test.go index 3e19f182067..80fb15f9812 100644 --- a/internal/service/s3/bucket_test.go +++ b/internal/service/s3/bucket_test.go @@ -19,6 +19,7 @@ import ( cloudformationtypes "github.com/aws/aws-sdk-go-v2/service/cloudformation/types" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -453,7 +454,7 @@ func TestAccS3Bucket_Duplicate_UsEast1(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartition(t, names.StandardPartitionID) + acctest.PreCheckPartition(t, endpoints.AwsPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -473,7 +474,7 @@ func TestAccS3Bucket_Duplicate_UsEast1AltAccount(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartition(t, names.StandardPartitionID) + acctest.PreCheckPartition(t, endpoints.AwsPartitionID) acctest.PreCheckAlternateAccount(t) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ServiceID), diff --git a/internal/service/s3/directory_bucket.go b/internal/service/s3/directory_bucket.go index 61efcf2d309..19a22a000d5 100644 --- a/internal/service/s3/directory_bucket.go +++ b/internal/service/s3/directory_bucket.go @@ -168,7 +168,7 @@ func (r *directoryBucketResource) Create(ctx context.Context, request resource.C } // Set values for unknowns. - data.ARN = types.StringValue(r.arn(data.Bucket.ValueString())) + data.ARN = types.StringValue(r.arn(ctx, data.Bucket.ValueString())) data.setID() response.Diagnostics.Append(response.State.Set(ctx, &data)...) @@ -207,7 +207,7 @@ func (r *directoryBucketResource) Read(ctx context.Context, request resource.Rea } // Set attributes for import. - data.ARN = types.StringValue(r.arn(data.Bucket.ValueString())) + data.ARN = types.StringValue(r.arn(ctx, data.Bucket.ValueString())) // No API to return bucket type, location etc. data.DataRedundancy = fwtypes.StringEnumValue(awstypes.DataRedundancySingleAvailabilityZone) @@ -284,8 +284,8 @@ func (r *directoryBucketResource) Delete(ctx context.Context, request resource.D } // arn returns the ARN of the specified bucket. -func (r *directoryBucketResource) arn(bucket string) string { - return r.RegionalARN("s3express", fmt.Sprintf("bucket/%s", bucket)) +func (r *directoryBucketResource) arn(ctx context.Context, bucket string) string { + return r.Meta().RegionalARN(ctx, "s3express", fmt.Sprintf("bucket/%s", bucket)) } type directoryBucketResourceModel struct { diff --git a/internal/service/s3/directory_buckets_data_source.go b/internal/service/s3/directory_buckets_data_source.go index 83f3a0248bc..645cb587af1 100644 --- a/internal/service/s3/directory_buckets_data_source.go +++ b/internal/service/s3/directory_buckets_data_source.go @@ -78,7 +78,7 @@ func (d *directoryBucketsDataSource) Read(ctx context.Context, request datasourc } data.ARNs = flex.FlattenFrameworkStringValueList(ctx, tfslices.ApplyToAll(buckets, func(v string) string { - return d.RegionalARN("s3express", fmt.Sprintf("bucket/%s", v)) + return d.Meta().RegionalARN(ctx, "s3express", fmt.Sprintf("bucket/%s", v)) })) data.Buckets = flex.FlattenFrameworkStringValueList(ctx, buckets) data.ID = types.StringValue(d.Meta().Region) diff --git a/internal/service/s3/object.go b/internal/service/s3/object.go index 274df8ee1b0..5bf30aecfdb 100644 --- a/internal/service/s3/object.go +++ b/internal/service/s3/object.go @@ -276,7 +276,7 @@ func resourceObjectRead(ctx context.Context, d *schema.ResourceData, meta interf return sdkdiag.AppendErrorf(diags, "reading S3 Object (%s): %s", d.Id(), err) } - arn, err := newObjectARN(meta.(*conns.AWSClient).Partition, bucket, key) + arn, err := newObjectARN(meta.(*conns.AWSClient).Partition(ctx), bucket, key) if err != nil { return sdkdiag.AppendErrorf(diags, "reading S3 Object (%s): %s", d.Id(), err) } diff --git a/internal/service/s3/object_copy.go b/internal/service/s3/object_copy.go index b6fedba198d..098e411abb8 100644 --- a/internal/service/s3/object_copy.go +++ b/internal/service/s3/object_copy.go @@ -359,7 +359,7 @@ func resourceObjectCopyRead(ctx context.Context, d *schema.ResourceData, meta in return sdkdiag.AppendErrorf(diags, "reading S3 Object (%s): %s", d.Id(), err) } - arn, err := newObjectARN(meta.(*conns.AWSClient).Partition, bucket, key) + arn, err := newObjectARN(meta.(*conns.AWSClient).Partition(ctx), bucket, key) if err != nil { return sdkdiag.AppendErrorf(diags, "reading S3 Object (%s): %s", d.Id(), err) } diff --git a/internal/service/s3/object_data_source.go b/internal/service/s3/object_data_source.go index c88076290a6..3ccd63de3a9 100644 --- a/internal/service/s3/object_data_source.go +++ b/internal/service/s3/object_data_source.go @@ -203,7 +203,7 @@ func dataSourceObjectRead(ctx context.Context, d *schema.ResourceData, meta inte } d.SetId(id) - arn, err := newObjectARN(meta.(*conns.AWSClient).Partition, bucket, key) + arn, err := newObjectARN(meta.(*conns.AWSClient).Partition(ctx), bucket, key) if err != nil { return sdkdiag.AppendErrorf(diags, "reading S3 Bucket (%s) Object (%s): %s", bucket, key, err) } diff --git a/internal/service/s3control/access_point.go b/internal/service/s3control/access_point.go index 92e4e096333..91e88623098 100644 --- a/internal/service/s3control/access_point.go +++ b/internal/service/s3control/access_point.go @@ -273,7 +273,7 @@ func resourceAccessPointRead(ctx context.Context, d *schema.ResourceData, meta i } else { // https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3.html#amazons3-resources-for-iam-policies. accessPointARN := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "s3", Region: meta.(*conns.AWSClient).Region, AccountID: accountID, diff --git a/internal/service/s3control/multi_region_access_point.go b/internal/service/s3control/multi_region_access_point.go index 65f22733d00..40c13b19519 100644 --- a/internal/service/s3control/multi_region_access_point.go +++ b/internal/service/s3control/multi_region_access_point.go @@ -210,7 +210,7 @@ func resourceMultiRegionAccessPointRead(ctx context.Context, d *schema.ResourceD alias := aws.ToString(accessPoint.Alias) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "s3", AccountID: accountID, Resource: fmt.Sprintf("accesspoint/%s", alias), diff --git a/internal/service/s3control/multi_region_access_point_data_source.go b/internal/service/s3control/multi_region_access_point_data_source.go index 4c82271dd7f..35a60c62a42 100644 --- a/internal/service/s3control/multi_region_access_point_data_source.go +++ b/internal/service/s3control/multi_region_access_point_data_source.go @@ -122,7 +122,7 @@ func dataSourceMultiRegionAccessPointBlockRead(ctx context.Context, d *schema.Re alias := aws.ToString(accessPoint.Alias) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "s3", AccountID: accountID, Resource: fmt.Sprintf("accesspoint/%s", alias), diff --git a/internal/service/s3control/multi_region_access_point_data_source_test.go b/internal/service/s3control/multi_region_access_point_data_source_test.go index a2025557bd6..a66ea34c36b 100644 --- a/internal/service/s3control/multi_region_access_point_data_source_test.go +++ b/internal/service/s3control/multi_region_access_point_data_source_test.go @@ -7,6 +7,7 @@ import ( "fmt" "testing" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" @@ -25,7 +26,7 @@ func TestAccS3ControlMultiRegionAccessPointDataSource_basic(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckMultipleRegion(t, 2) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ControlServiceID), ProtoV5ProviderFactories: acctest.ProtoV5FactoriesMultipleRegions(ctx, t, 2), diff --git a/internal/service/s3control/multi_region_access_point_policy_test.go b/internal/service/s3control/multi_region_access_point_policy_test.go index 31fc8ba3c6d..8193fb37d23 100644 --- a/internal/service/s3control/multi_region_access_point_policy_test.go +++ b/internal/service/s3control/multi_region_access_point_policy_test.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3control/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -27,7 +28,7 @@ func TestAccS3ControlMultiRegionAccessPointPolicy_basic(t *testing.T) { multiRegionAccessPointName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ControlServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, // Multi-Region Access Point Policy cannot be deleted once applied. @@ -65,7 +66,7 @@ func TestAccS3ControlMultiRegionAccessPointPolicy_disappears_MultiRegionAccessPo rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ControlServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, // Multi-Region Access Point Policy cannot be deleted once applied. @@ -92,7 +93,7 @@ func TestAccS3ControlMultiRegionAccessPointPolicy_details_policy(t *testing.T) { bucketName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ControlServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, // Multi-Region Access Point Policy cannot be deleted once applied. @@ -130,7 +131,7 @@ func TestAccS3ControlMultiRegionAccessPointPolicy_details_name(t *testing.T) { bucketName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ControlServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, // Multi-Region Access Point Policy cannot be deleted once applied. diff --git a/internal/service/s3control/multi_region_access_point_test.go b/internal/service/s3control/multi_region_access_point_test.go index f0daf8ac546..7045119cb14 100644 --- a/internal/service/s3control/multi_region_access_point_test.go +++ b/internal/service/s3control/multi_region_access_point_test.go @@ -11,6 +11,7 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3control/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -29,7 +30,7 @@ func TestAccS3ControlMultiRegionAccessPoint_basic(t *testing.T) { rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ControlServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckMultiRegionAccessPointDestroy(ctx), @@ -75,7 +76,7 @@ func TestAccS3ControlMultiRegionAccessPoint_disappears(t *testing.T) { rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ControlServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckMultiRegionAccessPointDestroy(ctx), @@ -100,7 +101,7 @@ func TestAccS3ControlMultiRegionAccessPoint_PublicAccessBlock(t *testing.T) { rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ControlServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckMultiRegionAccessPointDestroy(ctx), @@ -134,7 +135,7 @@ func TestAccS3ControlMultiRegionAccessPoint_name(t *testing.T) { bucketName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ControlServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckMultiRegionAccessPointDestroy(ctx), @@ -176,7 +177,7 @@ func TestAccS3ControlMultiRegionAccessPoint_threeRegions(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) acctest.PreCheckMultipleRegion(t, 3) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ControlServiceID), ProtoV5ProviderFactories: acctest.ProtoV5FactoriesMultipleRegions(ctx, t, 3), @@ -216,7 +217,7 @@ func TestAccS3ControlMultiRegionAccessPoint_putAndGetObject(t *testing.T) { rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.S3ControlServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckMultiRegionAccessPointDestroy(ctx), diff --git a/internal/service/s3control/object_lambda_access_point.go b/internal/service/s3control/object_lambda_access_point.go index ae5507dccd6..2f58a7ff898 100644 --- a/internal/service/s3control/object_lambda_access_point.go +++ b/internal/service/s3control/object_lambda_access_point.go @@ -187,7 +187,7 @@ func resourceObjectLambdaAccessPointRead(ctx context.Context, d *schema.Resource d.Set(names.AttrAccountID, accountID) // https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazons3objectlambda.html#amazons3objectlambda-resources-for-iam-policies. arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "s3-object-lambda", Region: meta.(*conns.AWSClient).Region, AccountID: accountID, diff --git a/internal/service/securityhub/account.go b/internal/service/securityhub/account.go index da5c2b84d4c..733f1372d33 100644 --- a/internal/service/securityhub/account.go +++ b/internal/service/securityhub/account.go @@ -5,7 +5,6 @@ package securityhub import ( "context" - "fmt" "log" "time" @@ -109,7 +108,7 @@ func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, meta int return sdkdiag.AppendErrorf(diags, "updating Security Hub Account (%s): %s", d.Id(), err) } - arn := accountHubARN(meta.(*conns.AWSClient)) + arn := accountHubARN(ctx, meta.(*conns.AWSClient)) const ( timeout = 1 * time.Minute ) @@ -134,7 +133,7 @@ func resourceAccountRead(ctx context.Context, d *schema.ResourceData, meta inter var diags diag.Diagnostics conn := meta.(*conns.AWSClient).SecurityHubClient(ctx) - arn := accountHubARN(meta.(*conns.AWSClient)) + arn := accountHubARN(ctx, meta.(*conns.AWSClient)) output, err := findHubByARN(ctx, conn, arn) if !d.IsNewResource() && tfresource.NotFound(err) { @@ -227,6 +226,6 @@ func findHub(ctx context.Context, conn *securityhub.Client, input *securityhub.D } // Security Hub ARN: https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssecurityhub.html#awssecurityhub-resources-for-iam-policies -func accountHubARN(meta *conns.AWSClient) string { - return fmt.Sprintf("arn:%s:securityhub:%s:%s:hub/default", meta.Partition, meta.Region, meta.AccountID) +func accountHubARN(ctx context.Context, c *conns.AWSClient) string { + return c.RegionalARN(ctx, "securityhub", "hub/default") } diff --git a/internal/service/securityhub/account_test.go b/internal/service/securityhub/account_test.go index 238676e20d7..f9956e69ec5 100644 --- a/internal/service/securityhub/account_test.go +++ b/internal/service/securityhub/account_test.go @@ -8,6 +8,7 @@ import ( "fmt" "testing" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" @@ -21,7 +22,7 @@ func testAccAccount_basic(t *testing.T) { ctx := acctest.Context(t) resourceName := "aws_securityhub_account.test" controlFindingGeneratorDefaultValueFromAWS := "SECURITY_CONTROL" - if acctest.Partition() == names.USGovCloudPartitionID { + if acctest.Partition() == endpoints.AwsUsGovPartitionID { controlFindingGeneratorDefaultValueFromAWS = "" } @@ -99,7 +100,7 @@ func testAccAccount_full(t *testing.T) { resource.Test(t, resource.TestCase{ // control_finding_generator not supported in AWS GovCloud. - PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.SecurityHubServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckAccountDestroy(ctx), @@ -163,10 +164,10 @@ func testAccAccount_removeControlFindingGeneratorDefaultValue(t *testing.T) { ctx := acctest.Context(t) resourceName := "aws_securityhub_account.test" controlFindingGeneratorExpectedValue := "SECURITY_CONTROL" - if acctest.Partition() == names.USGovCloudPartitionID { + if acctest.Partition() == endpoints.AwsUsGovPartitionID { controlFindingGeneratorExpectedValue = "" } - expectNonEmptyPlan := acctest.Partition() == names.USGovCloudPartitionID + expectNonEmptyPlan := acctest.Partition() == endpoints.AwsUsGovPartitionID resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) }, @@ -208,7 +209,7 @@ func testAccCheckAccountExists(ctx context.Context, n string) resource.TestCheck awsClient := acctest.Provider.Meta().(*conns.AWSClient) conn := awsClient.SecurityHubClient(ctx) - arn := tfsecurityhub.AccountHubARN(awsClient) + arn := tfsecurityhub.AccountHubARN(ctx, awsClient) _, err := tfsecurityhub.FindHubByARN(ctx, conn, arn) return err @@ -225,7 +226,7 @@ func testAccCheckAccountDestroy(ctx context.Context) resource.TestCheckFunc { continue } - arn := tfsecurityhub.AccountHubARN(awsClient) + arn := tfsecurityhub.AccountHubARN(ctx, awsClient) _, err := tfsecurityhub.FindHubByARN(ctx, conn, arn) if tfresource.NotFound(err) { diff --git a/internal/service/serverlessrepo/cloudformation_stack_test.go b/internal/service/serverlessrepo/cloudformation_stack_test.go index a31c7aa13f5..db024f0f35b 100644 --- a/internal/service/serverlessrepo/cloudformation_stack_test.go +++ b/internal/service/serverlessrepo/cloudformation_stack_test.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/cloudformation" cloudformationtypes "github.com/aws/aws-sdk-go-v2/service/cloudformation/types" "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" @@ -316,7 +317,7 @@ func testAccCloudFormationStackNameImportStateIdFunc(resourceName string) resour func testAccCloudFormationApplicationID() string { arnRegion := names.USEast1RegionID arnAccountID := "297356227824" - if acctest.Partition() == names.USGovCloudPartitionID { + if acctest.Partition() == endpoints.AwsUsGovPartitionID { arnRegion = names.USGovWest1RegionID arnAccountID = "023102451235" } diff --git a/internal/service/ses/active_receipt_rule_set.go b/internal/service/ses/active_receipt_rule_set.go index e3cfea4e2da..023bc3e924d 100644 --- a/internal/service/ses/active_receipt_rule_set.go +++ b/internal/service/ses/active_receipt_rule_set.go @@ -86,7 +86,7 @@ func resourceActiveReceiptRuleSetRead(ctx context.Context, d *schema.ResourceDat } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, @@ -132,7 +132,7 @@ func resourceActiveReceiptRuleSetImport(ctx context.Context, d *schema.ResourceD d.Set("rule_set_name", response.Metadata.Name) arnValue := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ses/active_receipt_rule_set_data_source.go b/internal/service/ses/active_receipt_rule_set_data_source.go index 150e025822d..4eef919c8dc 100644 --- a/internal/service/ses/active_receipt_rule_set_data_source.go +++ b/internal/service/ses/active_receipt_rule_set_data_source.go @@ -47,7 +47,7 @@ func dataSourceActiveReceiptRuleSetRead(ctx context.Context, d *schema.ResourceD name := aws.ToString(data.Name) d.SetId(name) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ses/configuration_set.go b/internal/service/ses/configuration_set.go index 5842a6f9796..3e8e0b0f3c3 100644 --- a/internal/service/ses/configuration_set.go +++ b/internal/service/ses/configuration_set.go @@ -196,7 +196,7 @@ func resourceConfigurationSetRead(ctx context.Context, d *schema.ResourceData, m } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ses/domain_identity.go b/internal/service/ses/domain_identity.go index e66c0d1252a..c4ace7609ed 100644 --- a/internal/service/ses/domain_identity.go +++ b/internal/service/ses/domain_identity.go @@ -87,7 +87,7 @@ func resourceDomainIdentityRead(ctx context.Context, d *schema.ResourceData, met } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ses/domain_identity_data_source.go b/internal/service/ses/domain_identity_data_source.go index 88068fd18d8..a6d192a03e6 100644 --- a/internal/service/ses/domain_identity_data_source.go +++ b/internal/service/ses/domain_identity_data_source.go @@ -53,7 +53,7 @@ func dataSourceDomainIdentityRead(ctx context.Context, d *schema.ResourceData, m d.SetId(domainName) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ses/domain_identity_data_source_test.go b/internal/service/ses/domain_identity_data_source_test.go index 74d8571ffc8..e7c3a873a2c 100644 --- a/internal/service/ses/domain_identity_data_source_test.go +++ b/internal/service/ses/domain_identity_data_source_test.go @@ -26,7 +26,7 @@ func TestAccSESDomainIdentityDataSource_basic(t *testing.T) { Config: testAccDomainIdentityDataSourceConfig_basic(domain), Check: resource.ComposeTestCheckFunc( testAccCheckDomainIdentityExists(ctx, "aws_ses_domain_identity.test"), - testAccCheckDomainIdentityARN("data.aws_ses_domain_identity.test", domain), + testAccCheckDomainIdentityARN(ctx, "data.aws_ses_domain_identity.test", domain), ), }, }, diff --git a/internal/service/ses/domain_identity_test.go b/internal/service/ses/domain_identity_test.go index e705106f494..330ffc1d47a 100644 --- a/internal/service/ses/domain_identity_test.go +++ b/internal/service/ses/domain_identity_test.go @@ -10,7 +10,6 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/ses" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -36,7 +35,7 @@ func TestAccSESDomainIdentity_basic(t *testing.T) { Config: testAccDomainIdentityConfig_basic(domain), Check: resource.ComposeTestCheckFunc( testAccCheckDomainIdentityExists(ctx, resourceName), - testAccCheckDomainIdentityARN("aws_ses_domain_identity.test", domain), + testAccCheckDomainIdentityARN(ctx, resourceName, domain), ), }, }, @@ -127,20 +126,12 @@ func testAccCheckDomainIdentityExists(ctx context.Context, n string) resource.Te } } -func testAccCheckDomainIdentityARN(n string, domain string) resource.TestCheckFunc { +func testAccCheckDomainIdentityARN(ctx context.Context, n string, domain string) resource.TestCheckFunc { return func(s *terraform.State) error { rs := s.RootModule().Resources[n] - awsClient := acctest.Provider.Meta().(*conns.AWSClient) - - expected := arn.ARN{ - AccountID: awsClient.AccountID, - Partition: awsClient.Partition, - Region: awsClient.Region, - Resource: fmt.Sprintf("identity/%s", strings.TrimSuffix(domain, ".")), - Service: "ses", - } + expected := acctest.Provider.Meta().(*conns.AWSClient).RegionalARN(ctx, "ses", fmt.Sprintf("identity/%s", strings.TrimSuffix(domain, "."))) - if rs.Primary.Attributes[names.AttrARN] != expected.String() { + if rs.Primary.Attributes[names.AttrARN] != expected { return fmt.Errorf("Incorrect ARN: expected %q, got %q", expected, rs.Primary.Attributes[names.AttrARN]) } diff --git a/internal/service/ses/domain_identity_verification.go b/internal/service/ses/domain_identity_verification.go index d8e3c79ece6..65f291829e3 100644 --- a/internal/service/ses/domain_identity_verification.go +++ b/internal/service/ses/domain_identity_verification.go @@ -97,7 +97,7 @@ func resourceDomainIdentityVerificationRead(ctx context.Context, d *schema.Resou } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ses/email_identity.go b/internal/service/ses/email_identity.go index 949159533ae..c3427851ba7 100644 --- a/internal/service/ses/email_identity.go +++ b/internal/service/ses/email_identity.go @@ -88,7 +88,7 @@ func resourceEmailIdentityRead(ctx context.Context, d *schema.ResourceData, meta arn := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("identity/%s", d.Id()), Service: "ses", diff --git a/internal/service/ses/email_identity_data_source.go b/internal/service/ses/email_identity_data_source.go index 7391a29a14c..4f9fccfeb5f 100644 --- a/internal/service/ses/email_identity_data_source.go +++ b/internal/service/ses/email_identity_data_source.go @@ -51,7 +51,7 @@ func dataSourceEmailIdentityRead(ctx context.Context, d *schema.ResourceData, me d.SetId(email) arn := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("identity/%s", email), Service: "ses", diff --git a/internal/service/ses/event_destination.go b/internal/service/ses/event_destination.go index 599f02fc70d..83bb0d08f4d 100644 --- a/internal/service/ses/event_destination.go +++ b/internal/service/ses/event_destination.go @@ -209,7 +209,7 @@ func resourceEventDestinationRead(ctx context.Context, d *schema.ResourceData, m } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ses/receipt_filter.go b/internal/service/ses/receipt_filter.go index 92e6c556bf3..19d3906e37c 100644 --- a/internal/service/ses/receipt_filter.go +++ b/internal/service/ses/receipt_filter.go @@ -113,7 +113,7 @@ func resourceReceiptFilterRead(ctx context.Context, d *schema.ResourceData, meta } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ses/receipt_rule.go b/internal/service/ses/receipt_rule.go index 60095831c6c..dac0127bb23 100644 --- a/internal/service/ses/receipt_rule.go +++ b/internal/service/ses/receipt_rule.go @@ -336,7 +336,7 @@ func resourceReceiptRuleRead(ctx context.Context, d *schema.ResourceData, meta i } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ses/receipt_rule_set.go b/internal/service/ses/receipt_rule_set.go index 27624aa1375..12038f058be 100644 --- a/internal/service/ses/receipt_rule_set.go +++ b/internal/service/ses/receipt_rule_set.go @@ -87,7 +87,7 @@ func resourceReceiptRuleSetRead(ctx context.Context, d *schema.ResourceData, met name := aws.ToString(output.Metadata.Name) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ses/template.go b/internal/service/ses/template.go index 48b4c323b92..8a044896b21 100644 --- a/internal/service/ses/template.go +++ b/internal/service/ses/template.go @@ -116,7 +116,7 @@ func resourceTemplateRead(ctx context.Context, d *schema.ResourceData, meta inte } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/sesv2/configuration_set.go b/internal/service/sesv2/configuration_set.go index 20ef943f9c1..476c5baa6b1 100644 --- a/internal/service/sesv2/configuration_set.go +++ b/internal/service/sesv2/configuration_set.go @@ -11,7 +11,6 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/sesv2" "github.com/aws/aws-sdk-go-v2/service/sesv2/types" "github.com/hashicorp/go-cty/cty" @@ -257,7 +256,7 @@ func resourceConfigurationSetRead(ctx context.Context, d *schema.ResourceData, m return create.AppendDiagError(diags, names.SESV2, create.ErrActionReading, resNameConfigurationSet, d.Id(), err) } - d.Set(names.AttrARN, configurationSetNameToARN(meta, aws.ToString(out.ConfigurationSetName))) + d.Set(names.AttrARN, configurationSetARN(ctx, meta.(*conns.AWSClient), aws.ToString(out.ConfigurationSetName))) d.Set("configuration_set_name", out.ConfigurationSetName) if out.DeliveryOptions != nil { @@ -747,12 +746,6 @@ func expandGuardianOptions(tfMap map[string]interface{}) *types.GuardianOptions return a } -func configurationSetNameToARN(meta interface{}, configurationSetName string) string { - return arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, - Service: "ses", - Region: meta.(*conns.AWSClient).Region, - AccountID: meta.(*conns.AWSClient).AccountID, - Resource: fmt.Sprintf("configuration-set/%s", configurationSetName), - }.String() +func configurationSetARN(ctx context.Context, c *conns.AWSClient, configurationSetName string) string { + return c.RegionalARN(ctx, "ses", fmt.Sprintf("configuration-set/%s", configurationSetName)) } diff --git a/internal/service/sesv2/configuration_set_data_source.go b/internal/service/sesv2/configuration_set_data_source.go index dbad7c7e31c..17ccf0df05c 100644 --- a/internal/service/sesv2/configuration_set_data_source.go +++ b/internal/service/sesv2/configuration_set_data_source.go @@ -157,7 +157,7 @@ func dataSourceConfigurationSetRead(ctx context.Context, d *schema.ResourceData, d.SetId(aws.ToString(out.ConfigurationSetName)) - d.Set(names.AttrARN, configurationSetNameToARN(meta, aws.ToString(out.ConfigurationSetName))) + d.Set(names.AttrARN, configurationSetARN(ctx, meta.(*conns.AWSClient), aws.ToString(out.ConfigurationSetName))) d.Set("configuration_set_name", out.ConfigurationSetName) if out.DeliveryOptions != nil { diff --git a/internal/service/sesv2/contact_list.go b/internal/service/sesv2/contact_list.go index 327948d8587..a89faa09deb 100644 --- a/internal/service/sesv2/contact_list.go +++ b/internal/service/sesv2/contact_list.go @@ -148,7 +148,7 @@ func resourceContactListRead(ctx context.Context, d *schema.ResourceData, meta i } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ses", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/sesv2/dedicated_ip_pool.go b/internal/service/sesv2/dedicated_ip_pool.go index 0b699155554..d14c718d416 100644 --- a/internal/service/sesv2/dedicated_ip_pool.go +++ b/internal/service/sesv2/dedicated_ip_pool.go @@ -10,7 +10,6 @@ import ( "log" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/sesv2" "github.com/aws/aws-sdk-go-v2/service/sesv2/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -109,9 +108,9 @@ func resourceDedicatedIPPoolRead(ctx context.Context, d *schema.ResourceData, me } poolName := aws.ToString(out.PoolName) + d.Set(names.AttrARN, dedicatedIPPoolARN(ctx, meta.(*conns.AWSClient), poolName)) d.Set("pool_name", poolName) - d.Set("scaling_mode", string(out.ScalingMode)) - d.Set(names.AttrARN, dedicatedIPPoolARN(meta, poolName)) + d.Set("scaling_mode", out.ScalingMode) return diags } @@ -170,12 +169,6 @@ func findDedicatedIPPool(ctx context.Context, conn *sesv2.Client, input *sesv2.G return output.DedicatedIpPool, nil } -func dedicatedIPPoolARN(meta interface{}, poolName string) string { - return arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, - Service: "ses", - Region: meta.(*conns.AWSClient).Region, - AccountID: meta.(*conns.AWSClient).AccountID, - Resource: fmt.Sprintf("dedicated-ip-pool/%s", poolName), - }.String() +func dedicatedIPPoolARN(ctx context.Context, c *conns.AWSClient, poolName string) string { + return c.RegionalARN(ctx, "ses", fmt.Sprintf("dedicated-ip-pool/%s", poolName)) } diff --git a/internal/service/sesv2/dedicated_ip_pool_data_source.go b/internal/service/sesv2/dedicated_ip_pool_data_source.go index 0da7c6e3ce8..befb4992982 100644 --- a/internal/service/sesv2/dedicated_ip_pool_data_source.go +++ b/internal/service/sesv2/dedicated_ip_pool_data_source.go @@ -78,8 +78,8 @@ func dataSourceDedicatedIPPoolRead(ctx context.Context, d *schema.ResourceData, poolName := aws.ToString(out.PoolName) d.SetId(poolName) + d.Set(names.AttrARN, dedicatedIPPoolARN(ctx, meta.(*conns.AWSClient), poolName)) d.Set("scaling_mode", out.ScalingMode) - d.Set(names.AttrARN, dedicatedIPPoolARN(meta, poolName)) outIP, err := findDedicatedIPsByPoolName(ctx, conn, poolName) if err != nil { diff --git a/internal/service/sesv2/email_identity.go b/internal/service/sesv2/email_identity.go index b87d65ca63f..08a374bd946 100644 --- a/internal/service/sesv2/email_identity.go +++ b/internal/service/sesv2/email_identity.go @@ -11,7 +11,6 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/sesv2" "github.com/aws/aws-sdk-go-v2/service/sesv2/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -177,9 +176,7 @@ func resourceEmailIdentityRead(ctx context.Context, d *schema.ResourceData, meta return create.AppendDiagError(diags, names.SESV2, create.ErrActionReading, resNameEmailIdentity, d.Id(), err) } - arn := emailIdentityARN(meta, d.Id()) - - d.Set(names.AttrARN, arn) + d.Set(names.AttrARN, emailIdentityARN(ctx, meta.(*conns.AWSClient), d.Id())) d.Set("configuration_set_name", out.ConfigurationSetName) d.Set("email_identity", d.Id()) @@ -354,12 +351,6 @@ func flattenDKIMAttributes(apiObject *types.DkimAttributes) map[string]interface return m } -func emailIdentityARN(meta interface{}, emailIdentityName string) string { - return arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, - Service: "ses", - Region: meta.(*conns.AWSClient).Region, - AccountID: meta.(*conns.AWSClient).AccountID, - Resource: fmt.Sprintf("identity/%s", emailIdentityName), - }.String() +func emailIdentityARN(ctx context.Context, c *conns.AWSClient, emailIdentityName string) string { + return c.RegionalARN(ctx, "ses", fmt.Sprintf("identity/%s", emailIdentityName)) } diff --git a/internal/service/sesv2/email_identity_data_source.go b/internal/service/sesv2/email_identity_data_source.go index 9c41939c56b..f5cf0def43f 100644 --- a/internal/service/sesv2/email_identity_data_source.go +++ b/internal/service/sesv2/email_identity_data_source.go @@ -103,10 +103,8 @@ func dataSourceEmailIdentityRead(ctx context.Context, d *schema.ResourceData, me return create.AppendDiagError(diags, names.SESV2, create.ErrActionReading, dsNameEmailIdentity, name, err) } - arn := emailIdentityARN(meta, name) - d.SetId(name) - d.Set(names.AttrARN, arn) + d.Set(names.AttrARN, emailIdentityARN(ctx, meta.(*conns.AWSClient), name)) d.Set("configuration_set_name", out.ConfigurationSetName) d.Set("email_identity", name) diff --git a/internal/service/shield/service_package.go b/internal/service/shield/service_package.go index b6a97bb68e8..8b57023f53a 100644 --- a/internal/service/shield/service_package.go +++ b/internal/service/shield/service_package.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/shield" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -21,7 +22,7 @@ func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) ( withBaseEndpoint(config[names.AttrEndpoint].(string)), func(o *shield.Options) { // Force "global" services to correct Regions. - if config["partition"].(string) == names.StandardPartitionID { + if config["partition"].(string) == endpoints.AwsPartitionID { if cfg.Region != names.USEast1RegionID { tflog.Info(ctx, "overriding region", map[string]any{ "original_region": cfg.Region, diff --git a/internal/service/sns/topic.go b/internal/service/sns/topic.go index d69f2b026dc..4829f6aaa7d 100644 --- a/internal/service/sns/topic.go +++ b/internal/service/sns/topic.go @@ -288,7 +288,7 @@ func resourceTopicCreate(ctx context.Context, d *schema.ResourceData, meta inter output, err := conn.CreateTopic(ctx, input) // Some partitions (e.g. ISO) may not support tag-on-create. - if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { input.Tags = nil output, err = conn.CreateTopic(ctx, input) @@ -316,7 +316,7 @@ func resourceTopicCreate(ctx context.Context, d *schema.ResourceData, meta inter err := createTags(ctx, conn, d.Id(), tags) // If default tags only, continue. Otherwise, error. - if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return append(diags, resourceTopicRead(ctx, d, meta)...) } diff --git a/internal/service/sqs/queue.go b/internal/service/sqs/queue.go index a8e56163754..3696cc20971 100644 --- a/internal/service/sqs/queue.go +++ b/internal/service/sqs/queue.go @@ -233,7 +233,7 @@ func resourceQueueCreate(ctx context.Context, d *schema.ResourceData, meta inter }, errCodeQueueDeletedRecently) // Some partitions (e.g. ISO) may not support tag-on-create. - if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if input.Tags != nil && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { input.Tags = nil outputRaw, err = tfresource.RetryWhenAWSErrCodeEquals(ctx, queueCreatedTimeout, func() (interface{}, error) { @@ -256,7 +256,7 @@ func resourceQueueCreate(ctx context.Context, d *schema.ResourceData, meta inter err := createTags(ctx, conn, d.Id(), tags) // If default tags only, continue. Otherwise, error. - if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if v, ok := d.GetOk(names.AttrTags); (!ok || len(v.(map[string]interface{})) == 0) && errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { return append(diags, resourceQueueRead(ctx, d, meta)...) } diff --git a/internal/service/sqs/queue_data_source.go b/internal/service/sqs/queue_data_source.go index 2a98b1591e6..59468b45547 100644 --- a/internal/service/sqs/queue_data_source.go +++ b/internal/service/sqs/queue_data_source.go @@ -68,7 +68,7 @@ func dataSourceQueueRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set(names.AttrARN, attributesOutput) d.Set(names.AttrURL, queueURL) - if errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition, err) { + if errs.IsUnsupportedOperationInPartitionError(meta.(*conns.AWSClient).Partition(ctx), err) { // Some partitions may not support tagging, giving error log.Printf("[WARN] failed listing tags for SQS Queue (%s): %s", d.Id(), err) return diags diff --git a/internal/service/ssm/association.go b/internal/service/ssm/association.go index 7ab40237eca..fd491082a2c 100644 --- a/internal/service/ssm/association.go +++ b/internal/service/ssm/association.go @@ -277,7 +277,7 @@ func resourceAssociationRead(ctx context.Context, d *schema.ResourceData, meta i d.Set("apply_only_at_cron_interval", association.ApplyOnlyAtCronInterval) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ssm", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ssm/document.go b/internal/service/ssm/document.go index 066190eb545..b7742298983 100644 --- a/internal/service/ssm/document.go +++ b/internal/service/ssm/document.go @@ -15,7 +15,6 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/aws/arn" "github.com/aws/aws-sdk-go-v2/service/ssm" awstypes "github.com/aws/aws-sdk-go-v2/service/ssm/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" @@ -330,7 +329,7 @@ func resourceDocumentRead(ctx context.Context, d *schema.ResourceData, meta inte } documentType, name := doc.DocumentType, aws.ToString(doc.Name) - d.Set(names.AttrARN, documentARN(meta.(*conns.AWSClient), documentType, name)) + d.Set(names.AttrARN, documentARN(ctx, meta.(*conns.AWSClient), documentType, name)) d.Set(names.AttrCreatedDate, aws.ToTime(doc.CreatedDate).Format(time.RFC3339)) d.Set("default_version", doc.DefaultVersion) d.Set(names.AttrDescription, doc.Description) @@ -716,20 +715,14 @@ func flattenDocumentParameters(apiObjects []awstypes.DocumentParameter) []interf return tfList } -func documentARN(c *conns.AWSClient, documentType awstypes.DocumentType, name string) string { - arn := arn.ARN{ - Partition: c.Partition, - Service: "ssm", - Region: c.Region, - AccountID: c.AccountID, - } - +func documentARN(ctx context.Context, c *conns.AWSClient, documentType awstypes.DocumentType, name string) string { + var resource string switch documentType { case awstypes.DocumentTypeAutomation: - arn.Resource = "automation-definition/" + name + resource = "automation-definition/" + name default: - arn.Resource = "document/" + name + resource = "document/" + name } - return arn.String() + return c.RegionalARN(ctx, "ssm", resource) } diff --git a/internal/service/ssm/document_data_source.go b/internal/service/ssm/document_data_source.go index cbeddb7d758..9e837e18c58 100644 --- a/internal/service/ssm/document_data_source.go +++ b/internal/service/ssm/document_data_source.go @@ -77,7 +77,7 @@ func dataDocumentRead(ctx context.Context, d *schema.ResourceData, meta interfac documentType, name := output.DocumentType, aws.ToString(output.Name) d.SetId(name) if !strings.HasPrefix(name, "AWS-") { - d.Set(names.AttrARN, documentARN(meta.(*conns.AWSClient), documentType, name)) + d.Set(names.AttrARN, documentARN(ctx, meta.(*conns.AWSClient), documentType, name)) } else { d.Set(names.AttrARN, name) } diff --git a/internal/service/ssm/maintenance_window_task.go b/internal/service/ssm/maintenance_window_task.go index 24acdec7895..809b208834e 100644 --- a/internal/service/ssm/maintenance_window_task.go +++ b/internal/service/ssm/maintenance_window_task.go @@ -397,7 +397,7 @@ func resourceMaintenanceWindowTaskRead(ctx context.Context, d *schema.ResourceDa windowTaskID := aws.ToString(output.WindowTaskId) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "ssm", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ssm/patch_baseline.go b/internal/service/ssm/patch_baseline.go index ed42708156f..a7fe6c33aab 100644 --- a/internal/service/ssm/patch_baseline.go +++ b/internal/service/ssm/patch_baseline.go @@ -328,7 +328,7 @@ func resourcePatchBaselineRead(ctx context.Context, d *schema.ResourceData, meta d.Set("approved_patches_compliance_level", output.ApprovedPatchesComplianceLevel) d.Set("approved_patches_enable_non_security", output.ApprovedPatchesEnableNonSecurity) arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Region: meta.(*conns.AWSClient).Region, Service: "ssm", AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/ssoadmin/trusted_token_issuer.go b/internal/service/ssoadmin/trusted_token_issuer.go index c54807a8ebd..2d53c30eb35 100644 --- a/internal/service/ssoadmin/trusted_token_issuer.go +++ b/internal/service/ssoadmin/trusted_token_issuer.go @@ -211,7 +211,7 @@ func (r *resourceTrustedTokenIssuer) Read(ctx context.Context, req resource.Read return } - instanceARN, _ := TrustedTokenIssuerParseInstanceARN(r.Meta(), aws.ToString(out.TrustedTokenIssuerArn)) + instanceARN, _ := TrustedTokenIssuerParseInstanceARN(ctx, r.Meta(), aws.ToString(out.TrustedTokenIssuerArn)) state.ARN = flex.StringToFramework(ctx, out.TrustedTokenIssuerArn) state.Name = flex.StringToFramework(ctx, out.Name) @@ -485,12 +485,12 @@ func flattenOIDCJWTConfiguration(ctx context.Context, apiObject *awstypes.OidcJw // Instance ARN is not returned by DescribeTrustedTokenIssuer but is needed for schema consistency when importing and tagging. // Instance ARN can be extracted from the Trusted Token Issuer ARN. -func TrustedTokenIssuerParseInstanceARN(conn *conns.AWSClient, id string) (string, diag.Diagnostics) { +func TrustedTokenIssuerParseInstanceARN(ctx context.Context, c *conns.AWSClient, id string) (string, diag.Diagnostics) { var diags diag.Diagnostics parts := strings.Split(id, "/") if len(parts) == 3 && parts[0] != "" && parts[1] != "" && parts[2] != "" { - return fmt.Sprintf("arn:%s:sso:::instance/%s", conn.Partition, parts[1]), diags + return fmt.Sprintf("arn:%s:sso:::instance/%s", c.Partition(ctx), parts[1]), diags } return "", diags diff --git a/internal/service/synthetics/canary.go b/internal/service/synthetics/canary.go index 88d3dd3e10c..a28d326e863 100644 --- a/internal/service/synthetics/canary.go +++ b/internal/service/synthetics/canary.go @@ -378,7 +378,7 @@ func resourceCanaryRead(ctx context.Context, d *schema.ResourceData, meta interf } canaryArn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "synthetics", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/transcribe/language_model.go b/internal/service/transcribe/language_model.go index 7830477c930..71231766130 100644 --- a/internal/service/transcribe/language_model.go +++ b/internal/service/transcribe/language_model.go @@ -167,7 +167,7 @@ func resourceLanguageModelRead(ctx context.Context, d *schema.ResourceData, meta arn := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "transcribe", Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("language-model/%s", d.Id()), diff --git a/internal/service/transcribe/medical_vocabulary.go b/internal/service/transcribe/medical_vocabulary.go index 7bfad126832..99e575dfc0b 100644 --- a/internal/service/transcribe/medical_vocabulary.go +++ b/internal/service/transcribe/medical_vocabulary.go @@ -127,7 +127,7 @@ func resourceMedicalVocabularyRead(ctx context.Context, d *schema.ResourceData, arn := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "transcribe", Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("medical-vocabulary/%s", d.Id()), diff --git a/internal/service/transcribe/vocabulary.go b/internal/service/transcribe/vocabulary.go index c4227005cc8..2d75aa35414 100644 --- a/internal/service/transcribe/vocabulary.go +++ b/internal/service/transcribe/vocabulary.go @@ -146,7 +146,7 @@ func resourceVocabularyRead(ctx context.Context, d *schema.ResourceData, meta in arn := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "transcribe", Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("vocabulary/%s", d.Id()), diff --git a/internal/service/transcribe/vocabulary_filter.go b/internal/service/transcribe/vocabulary_filter.go index 9bf672ad83e..f37045ca829 100644 --- a/internal/service/transcribe/vocabulary_filter.go +++ b/internal/service/transcribe/vocabulary_filter.go @@ -144,7 +144,7 @@ func resourceVocabularyFilterRead(ctx context.Context, d *schema.ResourceData, m arn := arn.ARN{ AccountID: meta.(*conns.AWSClient).AccountID, - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "transcribe", Region: meta.(*conns.AWSClient).Region, Resource: fmt.Sprintf("vocabulary-filter/%s", d.Id()), diff --git a/internal/service/transfer/server_test.go b/internal/service/transfer/server_test.go index fa2fbb4982c..e0d9089a913 100644 --- a/internal/service/transfer/server_test.go +++ b/internal/service/transfer/server_test.go @@ -12,6 +12,7 @@ import ( "github.com/YakDriver/regexache" acmpca_types "github.com/aws/aws-sdk-go-v2/service/acmpca/types" awstypes "github.com/aws/aws-sdk-go-v2/service/transfer/types" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -1207,7 +1208,7 @@ func testAccServer_vpcEndpointID(t *testing.T) { PreCheck: func() { acctest.PreCheck(ctx, t) testAccPreCheck(ctx, t) - acctest.PreCheckPartitionNot(t, names.USGovCloudPartitionID) + acctest.PreCheckPartitionNot(t, endpoints.AwsUsGovPartitionID) }, ErrorCheck: acctest.ErrorCheck(t, names.TransferServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/waf/geo_match_set.go b/internal/service/waf/geo_match_set.go index 457a7f90906..120edac868f 100644 --- a/internal/service/waf/geo_match_set.go +++ b/internal/service/waf/geo_match_set.go @@ -104,7 +104,7 @@ func resourceGeoMatchSetRead(ctx context.Context, d *schema.ResourceData, meta i } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf", AccountID: meta.(*conns.AWSClient).AccountID, Resource: "geomatchset/" + d.Id(), diff --git a/internal/service/waf/ipset.go b/internal/service/waf/ipset.go index 50981784b8b..cf0af6a96f8 100644 --- a/internal/service/waf/ipset.go +++ b/internal/service/waf/ipset.go @@ -114,7 +114,7 @@ func resourceIPSetRead(ctx context.Context, d *schema.ResourceData, meta interfa } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf", AccountID: meta.(*conns.AWSClient).AccountID, Resource: "ipset/" + d.Id(), diff --git a/internal/service/waf/rate_based_rule.go b/internal/service/waf/rate_based_rule.go index addde3861e7..bb9ac9ed2c8 100644 --- a/internal/service/waf/rate_based_rule.go +++ b/internal/service/waf/rate_based_rule.go @@ -155,7 +155,7 @@ func resourceRateBasedRuleRead(ctx context.Context, d *schema.ResourceData, meta } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf", AccountID: meta.(*conns.AWSClient).AccountID, Resource: "ratebasedrule/" + d.Id(), diff --git a/internal/service/waf/regex_match_set.go b/internal/service/waf/regex_match_set.go index e5181f149f8..567782034ee 100644 --- a/internal/service/waf/regex_match_set.go +++ b/internal/service/waf/regex_match_set.go @@ -128,7 +128,7 @@ func resourceRegexMatchSetRead(ctx context.Context, d *schema.ResourceData, meta } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf", AccountID: meta.(*conns.AWSClient).AccountID, Resource: "regexmatchset/" + d.Id(), diff --git a/internal/service/waf/regex_pattern_set.go b/internal/service/waf/regex_pattern_set.go index 3d2994b63b0..fcede9e747a 100644 --- a/internal/service/waf/regex_pattern_set.go +++ b/internal/service/waf/regex_pattern_set.go @@ -94,7 +94,7 @@ func resourceRegexPatternSetRead(ctx context.Context, d *schema.ResourceData, me } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf", AccountID: meta.(*conns.AWSClient).AccountID, Resource: "regexpatternset/" + d.Id(), diff --git a/internal/service/waf/rule.go b/internal/service/waf/rule.go index 60fde166d56..fe47ca0aeb0 100644 --- a/internal/service/waf/rule.go +++ b/internal/service/waf/rule.go @@ -147,7 +147,7 @@ func resourceRuleRead(ctx context.Context, d *schema.ResourceData, meta interfac } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf", AccountID: meta.(*conns.AWSClient).AccountID, Resource: "rule/" + d.Id(), diff --git a/internal/service/waf/rule_group.go b/internal/service/waf/rule_group.go index 9f6118a125c..bc03bf1d42c 100644 --- a/internal/service/waf/rule_group.go +++ b/internal/service/waf/rule_group.go @@ -166,7 +166,7 @@ func resourceRuleGroupRead(ctx context.Context, d *schema.ResourceData, meta int return sdkdiag.AppendErrorf(diags, "setting activated_rule: %s", err) } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf", AccountID: meta.(*conns.AWSClient).AccountID, Resource: "rulegroup/" + d.Id(), diff --git a/internal/service/waf/size_constraint_set.go b/internal/service/waf/size_constraint_set.go index 6f83baf206e..6f6a0338a72 100644 --- a/internal/service/waf/size_constraint_set.go +++ b/internal/service/waf/size_constraint_set.go @@ -125,7 +125,7 @@ func resourceSizeConstraintSetRead(ctx context.Context, d *schema.ResourceData, } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf", AccountID: meta.(*conns.AWSClient).AccountID, Resource: "sizeconstraintset/" + d.Id(), diff --git a/internal/service/waf/web_acl.go b/internal/service/waf/web_acl.go index 3e4a4d9e758..882637698d6 100644 --- a/internal/service/waf/web_acl.go +++ b/internal/service/waf/web_acl.go @@ -187,7 +187,7 @@ func resourceWebACLCreate(ctx context.Context, d *schema.ResourceData, meta inte if loggingConfiguration := d.Get(names.AttrLoggingConfiguration).([]interface{}); len(loggingConfiguration) == 1 { arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf", AccountID: meta.(*conns.AWSClient).AccountID, Resource: "webacl/" + d.Id(), diff --git a/internal/service/waf/xss_match_set.go b/internal/service/waf/xss_match_set.go index 2e3f708f815..01706e73924 100644 --- a/internal/service/waf/xss_match_set.go +++ b/internal/service/waf/xss_match_set.go @@ -126,7 +126,7 @@ func resourceXSSMatchSetRead(ctx context.Context, d *schema.ResourceData, meta i } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf", AccountID: meta.(*conns.AWSClient).AccountID, Resource: "xssmatchset/" + d.Id(), diff --git a/internal/service/wafregional/ipset.go b/internal/service/wafregional/ipset.go index da791e4c299..922cbde5d7c 100644 --- a/internal/service/wafregional/ipset.go +++ b/internal/service/wafregional/ipset.go @@ -105,7 +105,7 @@ func resourceIPSetRead(ctx context.Context, d *schema.ResourceData, meta interfa } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf-regional", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/wafregional/rate_based_rule.go b/internal/service/wafregional/rate_based_rule.go index ae83b42de15..cd0d2546860 100644 --- a/internal/service/wafregional/rate_based_rule.go +++ b/internal/service/wafregional/rate_based_rule.go @@ -157,7 +157,7 @@ func resourceRateBasedRuleRead(ctx context.Context, d *schema.ResourceData, meta } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf-regional", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/wafregional/rule.go b/internal/service/wafregional/rule.go index c556bca62f2..c6169f86fa9 100644 --- a/internal/service/wafregional/rule.go +++ b/internal/service/wafregional/rule.go @@ -134,7 +134,7 @@ func resourceRuleRead(ctx context.Context, d *schema.ResourceData, meta interfac } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf-regional", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/wafregional/rule_group.go b/internal/service/wafregional/rule_group.go index c84219e465c..4fa127edb19 100644 --- a/internal/service/wafregional/rule_group.go +++ b/internal/service/wafregional/rule_group.go @@ -167,7 +167,7 @@ func resourceRuleGroupRead(ctx context.Context, d *schema.ResourceData, meta int return sdkdiag.AppendErrorf(diags, "setting activated_rule: %s", err) } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf-regional", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/service/wafregional/web_acl.go b/internal/service/wafregional/web_acl.go index 25264936994..6b25700fb3a 100644 --- a/internal/service/wafregional/web_acl.go +++ b/internal/service/wafregional/web_acl.go @@ -190,7 +190,7 @@ func resourceWebACLCreate(ctx context.Context, d *schema.ResourceData, meta inte if loggingConfiguration := d.Get(names.AttrLoggingConfiguration).([]interface{}); len(loggingConfiguration) == 1 { arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf-regional", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, @@ -245,7 +245,7 @@ func resourceWebACLRead(ctx context.Context, d *schema.ResourceData, meta interf } arn := arn.ARN{ - Partition: meta.(*conns.AWSClient).Partition, + Partition: meta.(*conns.AWSClient).Partition(ctx), Service: "waf-regional", Region: meta.(*conns.AWSClient).Region, AccountID: meta.(*conns.AWSClient).AccountID, diff --git a/internal/sweep/sweep.go b/internal/sweep/sweep.go index 79efd4013f1..d5acb506da4 100644 --- a/internal/sweep/sweep.go +++ b/internal/sweep/sweep.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/envvar" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" - "github.com/hashicorp/terraform-provider-aws/names" ) const ( @@ -123,12 +122,4 @@ func SweepOrchestrator(ctx context.Context, sweepables []Sweepable, optFns ...tf return g.Wait().ErrorOrNil() } -func Partition(region string) string { - return names.PartitionForRegion(region) -} - -func PartitionDNSSuffix(region string) string { - return names.DNSSuffixForPartition(Partition(region)) -} - type SweeperFn func(ctx context.Context, client *conns.AWSClient) ([]Sweepable, error) diff --git a/names/names.go b/names/names.go index 3a5970179a5..1ef40ab6dee 100644 --- a/names/names.go +++ b/names/names.go @@ -18,8 +18,8 @@ package names import ( "fmt" "log" - "slices" + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" "github.com/hashicorp/terraform-provider-aws/names/data" ) @@ -144,18 +144,6 @@ const ( WAFRegionalEndpointID = "waf-regional" ) -// These should move to aws-sdk-go-base. -// See https://github.com/hashicorp/aws-sdk-go-base/issues/649. -const ( - ChinaPartitionID = "aws-cn" // AWS China partition. - ISOPartitionID = "aws-iso" // AWS ISO (US) partition. - ISOBPartitionID = "aws-iso-b" // AWS ISOB (US) partition. - ISOEPartitionID = "aws-iso-e" // AWS ISOE (Europe) partition. - ISOFPartitionID = "aws-iso-f" // AWS ISOF partition. - StandardPartitionID = "aws" // AWS Standard partition. - USGovCloudPartitionID = "aws-us-gov" // AWS GovCloud (US) partition. -) - const ( // AWS Standard partition's regions. GlobalRegionID = "aws-global" // AWS Standard global region. @@ -210,149 +198,19 @@ const ( EUISOEWest1RegionID = "eu-isoe-west-1" // EU ISOE West. ) -var allRegionIDs = []string{ - AFSouth1RegionID, - APEast1RegionID, - APNortheast1RegionID, - APNortheast2RegionID, - APNortheast3RegionID, - APSouth1RegionID, - APSouth2RegionID, - APSoutheast1RegionID, - APSoutheast2RegionID, - APSoutheast3RegionID, - APSoutheast4RegionID, - APSoutheast5RegionID, - CACentral1RegionID, - CAWest1RegionID, - EUCentral1RegionID, - EUCentral2RegionID, - EUNorth1RegionID, - EUSouth1RegionID, - EUSouth2RegionID, - EUWest1RegionID, - EUWest2RegionID, - EUWest3RegionID, - ILCentral1RegionID, - MECentral1RegionID, - MESouth1RegionID, - SAEast1RegionID, - USEast1RegionID, - USEast2RegionID, - USWest1RegionID, - USWest2RegionID, - CNNorth1RegionID, - CNNorthwest1RegionID, - USGovEast1RegionID, - USGovWest1RegionID, - USISOEast1RegionID, - USISOWest1RegionID, - USISOBEast1RegionID, - EUISOEWest1RegionID, -} - -func Regions() []string { - return slices.Clone(allRegionIDs) -} - -func DNSSuffixForPartition(partition string) string { - switch partition { - case "": - return "" - case ChinaPartitionID: - return "amazonaws.com.cn" - case ISOPartitionID: - return "c2s.ic.gov" - case ISOBPartitionID: - return "sc2s.sgov.gov" - case ISOEPartitionID: - return "cloud.adc-e.uk" - case ISOFPartitionID: - return "csp.hci.ic.gov" - default: - return "amazonaws.com" +// PartitionForRegion returns the partition for the given Region. +// Returns the empty partition if the Region is empty. +// Returns the standard partition if no known partition includes the Region. +func PartitionForRegion(region string) endpoints.Partition { + if region == "" { + return endpoints.Partition{} } -} -func ServicePrincipalSuffixForPartition(partition string) string { - switch partition { - case ChinaPartitionID: - return "amazonaws.com.cn" - case ISOPartitionID: - return "c2s.ic.gov" - case ISOBPartitionID: - return "sc2s.sgov.gov" - default: - return "amazonaws.com" + if partition, ok := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), region); ok { + return partition } -} -// SPN region unique taken from -// https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/region-info/lib/default.ts -func ServicePrincipalNameForPartition(service string, partition string) string { - if service != "" && partition != StandardPartitionID { - switch partition { - case ISOPartitionID: - switch service { - case "cloudhsm", - "config", - "logs", - "workspaces": - return DNSSuffixForPartition(partition) - } - case ISOBPartitionID: - switch service { - case "dms", - "logs": - return DNSSuffixForPartition(partition) - } - case ChinaPartitionID: - switch service { - case "codedeploy", - "elasticmapreduce", - "logs": - return DNSSuffixForPartition(partition) - } - } - } - - return "amazonaws.com" -} - -func IsOptInRegion(region string) bool { - switch region { - case AFSouth1RegionID, - APEast1RegionID, APSouth2RegionID, - APSoutheast3RegionID, APSoutheast4RegionID, APSoutheast5RegionID, - CAWest1RegionID, - EUCentral2RegionID, - EUSouth1RegionID, EUSouth2RegionID, - ILCentral1RegionID, - MECentral1RegionID, - MESouth1RegionID: - return true - default: - return false - } -} - -func PartitionForRegion(region string) string { - switch region { - case "": - return "" - case CNNorth1RegionID, CNNorthwest1RegionID: - return ChinaPartitionID - case USISOEast1RegionID, USISOWest1RegionID: - return ISOPartitionID - case USISOBEast1RegionID: - return ISOBPartitionID - case EUISOEWest1RegionID: - return ISOEPartitionID - case USGovEast1RegionID, USGovWest1RegionID: - return USGovCloudPartitionID - default: - return StandardPartitionID - } + return PartitionForRegion(endpoints.UsEast1RegionID) } // Type ServiceDatum corresponds closely to attributes and blocks in `data/names_data.hcl` and are diff --git a/names/names_test.go b/names/names_test.go index c9f1037a81d..5d47234f73f 100644 --- a/names/names_test.go +++ b/names/names_test.go @@ -9,99 +9,9 @@ import ( "io/fs" "os" "testing" -) - -func TestDNSSuffixForPartition(t *testing.T) { - t.Parallel() - testCases := []struct { - name string - input string - expected string - }{ - { - name: "empty", - input: "", - expected: "", - }, - { - name: "China", - input: ChinaPartitionID, - expected: "amazonaws.com.cn", - }, - { - name: "GovCloud", - input: USGovCloudPartitionID, - expected: "amazonaws.com", - }, - { - name: "standard", - input: StandardPartitionID, - expected: "amazonaws.com", - }, - { - name: "default", - input: "custom", - expected: "amazonaws.com", - }, - } - - for _, testCase := range testCases { - t.Run(testCase.name, func(t *testing.T) { - t.Parallel() - - if got, want := DNSSuffixForPartition(testCase.input), testCase.expected; got != want { - t.Errorf("got: %s, expected: %s", got, want) - } - }) - } -} - -func TestIsOptInRegion(t *testing.T) { - t.Parallel() - - testCases := []struct { - name string - input string - expected bool - }{ - { - name: "empty", - input: "", - expected: false, - }, - { - name: "China", - input: CNNorth1RegionID, - expected: false, - }, - { - name: "GovCloud", - input: USGovWest1RegionID, - expected: false, - }, - { - name: "standard opt-in", - input: CAWest1RegionID, - expected: true, - }, - { - name: "standard not opt-in", - input: CACentral1RegionID, - expected: false, - }, - } - - for _, testCase := range testCases { - t.Run(testCase.name, func(t *testing.T) { - t.Parallel() - - if got, want := IsOptInRegion(testCase.input), testCase.expected; got != want { - t.Errorf("got: %t, expected: %t", got, want) - } - }) - } -} + "github.com/hashicorp/aws-sdk-go-base/v2/endpoints" +) func TestPartitionForRegion(t *testing.T) { t.Parallel() @@ -118,23 +28,23 @@ func TestPartitionForRegion(t *testing.T) { }, { name: "China", - input: CNNorth1RegionID, - expected: ChinaPartitionID, + input: endpoints.CnNorth1RegionID, + expected: endpoints.AwsCnPartitionID, }, { name: "GovCloud", - input: USGovWest1RegionID, - expected: USGovCloudPartitionID, + input: endpoints.UsGovWest1RegionID, + expected: endpoints.AwsUsGovPartitionID, }, { name: "standard", - input: USWest2RegionID, - expected: StandardPartitionID, + input: endpoints.UsWest2RegionID, + expected: endpoints.AwsPartitionID, }, { name: "default", input: "custom", - expected: StandardPartitionID, + expected: endpoints.AwsPartitionID, }, } @@ -142,7 +52,7 @@ func TestPartitionForRegion(t *testing.T) { t.Run(testCase.name, func(t *testing.T) { t.Parallel() - if got, want := PartitionForRegion(testCase.input), testCase.expected; got != want { + if got, want := PartitionForRegion(testCase.input).ID(), testCase.expected; got != want { t.Errorf("got: %s, expected: %s", got, want) } })