diff --git a/docs/acc-test-environment-variables.md b/docs/acc-test-environment-variables.md index a3d5df02a9c..83c1d5f7613 100644 --- a/docs/acc-test-environment-variables.md +++ b/docs/acc-test-environment-variables.md @@ -51,7 +51,6 @@ Environment variables (beyond standard AWS Go SDK ones) used by acceptance testi | `AWS_CODEBUILD_GITHUB_SOURCE_LOCATION` | GitHub source URL for CodeBuild testing. CodeBuild must have access to this repository via OAuth or Source Credentials. Defaults to `https://github.com/hashibot-test/aws-test.git`. | | `AWS_DEFAULT_REGION` | Primary AWS region for tests. Defaults to `us-west-2`. | | `AWS_DETECTIVE_MEMBER_EMAIL` | Email address for Detective Member testing. A valid email address associated with an AWS root account is required for tests to pass. | -| `AWS_EC2_CLASSIC_REGION` | AWS region for EC2-Classic testing. Defaults to `us-east-1` in AWS Commercial and `AWS_DEFAULT_REGION` otherwise. | | `AWS_EC2_CLIENT_VPN_LIMIT` | Concurrency limit for Client VPN acceptance tests. [Default is 5](https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/limits.html) if not specified. | | `AWS_EC2_EIP_PUBLIC_IPV4_POOL` | Identifier for EC2 Public IPv4 Pool for EC2 EIP testing. | | `AWS_GUARDDUTY_MEMBER_ACCOUNT_ID` | Identifier of AWS Account for GuardDuty Member testing. **DEPRECATED:** Should be replaced with standard alternate account handling for tests. | diff --git a/internal/service/ecrpublic/authorization_token_data_source.go b/internal/service/ecrpublic/authorization_token_data_source.go index b93211356ee..b8564fe6f54 100644 --- a/internal/service/ecrpublic/authorization_token_data_source.go +++ b/internal/service/ecrpublic/authorization_token_data_source.go @@ -50,7 +50,7 @@ func dataSourceAuthorizationTokenRead(ctx context.Context, d *schema.ResourceDat out, err := conn.GetAuthorizationTokenWithContext(ctx, params) if err != nil { - return sdkdiag.AppendErrorf(diags, "getting Public ECR authorization token: %s", err) + return sdkdiag.AppendErrorf(diags, "getting ECR Public authorization token: %s", err) } authorizationData := out.AuthorizationData @@ -58,12 +58,12 @@ func dataSourceAuthorizationTokenRead(ctx context.Context, d *schema.ResourceDat expiresAt := aws.TimeValue(authorizationData.ExpiresAt).Format(time.RFC3339) authBytes, err := base64.URLEncoding.DecodeString(authorizationToken) if err != nil { - return sdkdiag.AppendErrorf(diags, "decoding Public ECR authorization token: %s", err) + return sdkdiag.AppendErrorf(diags, "decoding ECR Public authorization token: %s", err) } basicAuthorization := strings.Split(string(authBytes), ":") if len(basicAuthorization) != 2 { - return sdkdiag.AppendErrorf(diags, "unknown Public ECR authorization token format") + return sdkdiag.AppendErrorf(diags, "unknown ECR Public authorization token format") } userName := basicAuthorization[0] diff --git a/internal/service/ecrpublic/authorization_token_data_source_test.go b/internal/service/ecrpublic/authorization_token_data_source_test.go index ce5a4f160d0..8b5d2b1a7ec 100644 --- a/internal/service/ecrpublic/authorization_token_data_source_test.go +++ b/internal/service/ecrpublic/authorization_token_data_source_test.go @@ -4,6 +4,7 @@ import ( "regexp" "testing" + "github.com/aws/aws-sdk-go/aws/endpoints" "github.com/aws/aws-sdk-go/service/ecr" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" @@ -14,12 +15,12 @@ func TestAccECRPublicAuthorizationTokenDataSource_basic(t *testing.T) { dataSourceName := "data.aws_ecrpublic_authorization_token.repo" resource.Test(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecr.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, Steps: []resource.TestStep{ { - Config: testAccAuthorizationTokenDataSourceConfig_basic, + Config: testAccAuthorizationTokenDataSourceConfig_basic(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(dataSourceName, "authorization_token"), resource.TestCheckResourceAttrSet(dataSourceName, "expires_at"), @@ -32,6 +33,7 @@ func TestAccECRPublicAuthorizationTokenDataSource_basic(t *testing.T) { }) } -var testAccAuthorizationTokenDataSourceConfig_basic = ` -data "aws_ecrpublic_authorization_token" "repo" {} +func testAccAuthorizationTokenDataSourceConfig_basic() string { + return `data "aws_ecrpublic_authorization_token" "repo" {} ` +} diff --git a/internal/service/ecrpublic/repository_policy_test.go b/internal/service/ecrpublic/repository_policy_test.go index ecf7f505770..6580a9a3e6d 100644 --- a/internal/service/ecrpublic/repository_policy_test.go +++ b/internal/service/ecrpublic/repository_policy_test.go @@ -5,6 +5,7 @@ import ( "fmt" "testing" + "github.com/aws/aws-sdk-go/aws/endpoints" "github.com/aws/aws-sdk-go/service/ecrpublic" sdkacctest "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" @@ -21,7 +22,7 @@ func TestAccECRPublicRepositoryPolicy_basic(t *testing.T) { resourceName := "aws_ecrpublic_repository_policy.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryPolicyDestroy(ctx), @@ -55,7 +56,7 @@ func TestAccECRPublicRepositoryPolicy_disappears(t *testing.T) { resourceName := "aws_ecrpublic_repository_policy.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryPolicyDestroy(ctx), @@ -80,7 +81,7 @@ func TestAccECRPublicRepositoryPolicy_Disappears_repository(t *testing.T) { repositoryResourceName := "aws_ecrpublic_repository.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryPolicyDestroy(ctx), @@ -104,7 +105,7 @@ func TestAccECRPublicRepositoryPolicy_iam(t *testing.T) { resourceName := "aws_ecrpublic_repository_policy.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryPolicyDestroy(ctx), diff --git a/internal/service/ecrpublic/repository_test.go b/internal/service/ecrpublic/repository_test.go index b5811aa17bc..aebb34488d7 100644 --- a/internal/service/ecrpublic/repository_test.go +++ b/internal/service/ecrpublic/repository_test.go @@ -24,7 +24,7 @@ func TestAccECRPublicRepository_basic(t *testing.T) { resourceName := "aws_ecrpublic_repository.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryDestroy(ctx), @@ -54,7 +54,7 @@ func TestAccECRPublicRepository_tags(t *testing.T) { resourceName := "aws_ecrpublic_repository.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryDestroy(ctx), @@ -100,7 +100,7 @@ func TestAccECRPublicRepository_CatalogData_aboutText(t *testing.T) { resourceName := "aws_ecrpublic_repository.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryDestroy(ctx), @@ -137,7 +137,7 @@ func TestAccECRPublicRepository_CatalogData_architectures(t *testing.T) { resourceName := "aws_ecrpublic_repository.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryDestroy(ctx), @@ -174,7 +174,7 @@ func TestAccECRPublicRepository_CatalogData_description(t *testing.T) { resourceName := "aws_ecrpublic_repository.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryDestroy(ctx), @@ -211,7 +211,7 @@ func TestAccECRPublicRepository_CatalogData_operatingSystems(t *testing.T) { resourceName := "aws_ecrpublic_repository.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryDestroy(ctx), @@ -248,7 +248,7 @@ func TestAccECRPublicRepository_CatalogData_usageText(t *testing.T) { resourceName := "aws_ecrpublic_repository.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryDestroy(ctx), @@ -285,7 +285,7 @@ func TestAccECRPublicRepository_CatalogData_logoImageBlob(t *testing.T) { resourceName := "aws_ecrpublic_repository.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryDestroy(ctx), @@ -315,7 +315,7 @@ func TestAccECRPublicRepository_Basic_forceDestroy(t *testing.T) { resourceName := "aws_ecrpublic_repository.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryDestroy(ctx), @@ -346,7 +346,7 @@ func TestAccECRPublicRepository_disappears(t *testing.T) { resourceName := "aws_ecrpublic_repository.test" resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheck(ctx, t) }, + PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckRegion(t, endpoints.UsEast1RegionID) }, ErrorCheck: acctest.ErrorCheck(t, ecrpublic.EndpointsID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, CheckDestroy: testAccCheckRepositoryDestroy(ctx), @@ -533,23 +533,3 @@ resource "aws_ecrpublic_repository" "test" { } `, rName) } - -func testAccPreCheck(ctx context.Context, t *testing.T) { - // At this time, calls to DescribeRepositories returns (and by default, retries) - // an InternalFailure when the region is not supported i.e. not us-east-1. - // TODO: Remove when ECRPublic is supported across other known regions - // Reference: https://github.com/hashicorp/terraform-provider-aws/issues/18047 - if region := acctest.Provider.Meta().(*conns.AWSClient).Region; region != endpoints.UsEast1RegionID { - t.Skipf("skipping acceptance testing: region (%s) does not support ECR Public repositories", region) - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).ECRPublicConn() - input := &ecrpublic.DescribeRepositoriesInput{} - _, err := conn.DescribeRepositoriesWithContext(ctx, input) - if acctest.PreCheckSkipError(err) { - t.Skipf("skipping acceptance testing: %s", err) - } - if err != nil { - t.Fatalf("unexpected PreCheck error: %s", err) - } -} diff --git a/website/docs/d/ecrpublic_authorization_token.html.markdown b/website/docs/d/ecrpublic_authorization_token.html.markdown index 709a8fe3305..d837dd02d43 100644 --- a/website/docs/d/ecrpublic_authorization_token.html.markdown +++ b/website/docs/d/ecrpublic_authorization_token.html.markdown @@ -8,7 +8,9 @@ description: |- # Data Source: aws_ecrpublic_authorization_token -The Public ECR Authorization Token data source allows the authorization token, token expiration date, user name and password to be retrieved for a Public ECR repository. +The Public ECR Authorization Token data source allows the authorization token, token expiration date, user name, and password to be retrieved for a Public ECR repository. + +~> **NOTE:** This data source can only be used in the `us-east-1` region. ## Example Usage diff --git a/website/docs/r/ecrpublic_repository.html.markdown b/website/docs/r/ecrpublic_repository.html.markdown index 795e5548540..0efbaf84b36 100644 --- a/website/docs/r/ecrpublic_repository.html.markdown +++ b/website/docs/r/ecrpublic_repository.html.markdown @@ -10,7 +10,7 @@ description: |- Provides a Public Elastic Container Registry Repository. -~> **NOTE:** This resource can only be used with `us-east-1` region. +~> **NOTE:** This resource can only be used in the `us-east-1` region. ## Example Usage diff --git a/website/docs/r/ecrpublic_repository_policy.html.markdown b/website/docs/r/ecrpublic_repository_policy.html.markdown index 327a3ac54e7..02afe861260 100644 --- a/website/docs/r/ecrpublic_repository_policy.html.markdown +++ b/website/docs/r/ecrpublic_repository_policy.html.markdown @@ -12,7 +12,7 @@ Provides an Elastic Container Registry Public Repository Policy. Note that currently only one policy may be applied to a repository. -~> **NOTE:** This resource can only be used with `us-east-1` region. +~> **NOTE:** This resource can only be used in the `us-east-1` region. ## Example Usage