From 8a0a52b990ceb9036c6e953341dc288585ab53d8 Mon Sep 17 00:00:00 2001 From: Graham Davison Date: Mon, 17 Jul 2023 18:03:07 -0700 Subject: [PATCH] Updates `aws-sdk-go-base` --- internal/conns/config.go | 17 +++++++++++------ .../service/configservice/configservice_test.go | 4 ++-- .../configservice/conformance_pack_test.go | 3 ++- .../organization_conformance_pack_test.go | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/internal/conns/config.go b/internal/conns/config.go index f0c1ec493e0..72c9cabde0e 100644 --- a/internal/conns/config.go +++ b/internal/conns/config.go @@ -6,7 +6,6 @@ package conns import ( "context" "fmt" - "log" aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" imds_sdkv2 "github.com/aws/aws-sdk-go-v2/feature/ec2/imds" @@ -16,6 +15,7 @@ import ( basediag "github.com/hashicorp/aws-sdk-go-base/v2/diag" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/names" @@ -147,14 +147,19 @@ func (c *Config) ConfigureProvider(ctx context.Context, client *AWSClient) (*AWS } tflog.Debug(ctx, "Retrieving AWS account details") - accountID, partition, err := awsbase.GetAwsAccountIDAndPartition(ctx, cfg, &awsbaseConfig) - if err != nil { - return nil, sdkdiag.AppendErrorf(diags, "retrieving AWS account details: %s", err) + accountID, partition, awsDiags := awsbase.GetAwsAccountIDAndPartition(ctx, cfg, &awsbaseConfig) + for _, d := range awsDiags { + diags = append(diags, diag.Diagnostic{ + Severity: baseSeverityToSdkSeverity(d.Severity()), + Summary: fmt.Sprintf("retrieving AWS account details: %s", d.Summary()), + Detail: d.Detail(), + }) } if accountID == "" { - // TODO: Make this a Warning Diagnostic - log.Println("[WARN] AWS account ID not found for provider. See https://www.terraform.io/docs/providers/aws/index.html#skip_requesting_account_id for implications.") + diags = append(diags, errs.NewWarningDiagnostic( + "AWS account ID not found for provider", + "See https://www.terraform.io/docs/providers/aws/index.html#skip_requesting_account_id for implications.")) } if len(c.ForbiddenAccountIds) > 0 { diff --git a/internal/service/configservice/configservice_test.go b/internal/service/configservice/configservice_test.go index bb7fedb380b..953d3092743 100644 --- a/internal/service/configservice/configservice_test.go +++ b/internal/service/configservice/configservice_test.go @@ -38,7 +38,7 @@ func TestAccConfigService_serial(t *testing.T) { "ConformancePack": { "basic": testAccConformancePack_basic, "disappears": testAccConformancePack_disappears, - "forceNew": testAccConformancePack_forceNew, + "updateName": testAccConformancePack_updateName, "inputParameters": testAccConformancePack_inputParameters, "S3Delivery": testAccConformancePack_S3Delivery, "S3Template": testAccConformancePack_S3Template, @@ -57,7 +57,7 @@ func TestAccConfigService_serial(t *testing.T) { "basic": testAccOrganizationConformancePack_basic, "disappears": testAccOrganizationConformancePack_disappears, "excludedAccounts": testAccOrganizationConformancePack_excludedAccounts, - "forceNew": testAccOrganizationConformancePack_forceNew, + "updateName": testAccOrganizationConformancePack_updateName, "inputParameters": testAccOrganizationConformancePack_inputParameters, "S3Delivery": testAccOrganizationConformancePack_S3Delivery, "S3Template": testAccOrganizationConformancePack_S3Template, diff --git a/internal/service/configservice/conformance_pack_test.go b/internal/service/configservice/conformance_pack_test.go index 2f71cd37422..c292248c951 100644 --- a/internal/service/configservice/conformance_pack_test.go +++ b/internal/service/configservice/conformance_pack_test.go @@ -55,7 +55,7 @@ func testAccConformancePack_basic(t *testing.T) { }) } -func testAccConformancePack_forceNew(t *testing.T) { +func testAccConformancePack_updateName(t *testing.T) { ctx := acctest.Context(t) var before, after configservice.ConformancePackDetail rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -72,6 +72,7 @@ func testAccConformancePack_forceNew(t *testing.T) { Config: testAccConformancePackConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckConformancePackExists(ctx, resourceName, &before), + resource.TestCheckResourceAttr(resourceName, "name", rName), ), }, { diff --git a/internal/service/configservice/organization_conformance_pack_test.go b/internal/service/configservice/organization_conformance_pack_test.go index a805cb2188d..cfc04f96c28 100644 --- a/internal/service/configservice/organization_conformance_pack_test.go +++ b/internal/service/configservice/organization_conformance_pack_test.go @@ -127,7 +127,7 @@ func testAccOrganizationConformancePack_excludedAccounts(t *testing.T) { }) } -func testAccOrganizationConformancePack_forceNew(t *testing.T) { +func testAccOrganizationConformancePack_updateName(t *testing.T) { ctx := acctest.Context(t) var before, after configservice.OrganizationConformancePack rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) @@ -144,6 +144,7 @@ func testAccOrganizationConformancePack_forceNew(t *testing.T) { Config: testAccOrganizationConformancePackConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckOrganizationConformancePackExists(ctx, resourceName, &before), + resource.TestCheckResourceAttr(resourceName, "name", rName), ), }, { @@ -650,7 +651,6 @@ resource "aws_s3_bucket" "test" { bucket = %q force_destroy = true } - `, rName, bName)) }