From 162b2c697feea510851df9a4750befa541054205 Mon Sep 17 00:00:00 2001 From: Angie Pinilla Date: Tue, 18 May 2021 15:52:12 -0400 Subject: [PATCH] additional updates from acctest errors --- aws/internal/service/apprunner/waiter/status.go | 10 ++++++++++ aws/internal/service/apprunner/waiter/waiter.go | 9 +++------ ...r_auto_scaling_configuration_version_test.go | 17 +++++++++-------- ...e_aws_apprunner_custom_domain_association.go | 7 ++++++- ..._apprunner_custom_domain_association_test.go | 14 ++++++++------ 5 files changed, 36 insertions(+), 21 deletions(-) diff --git a/aws/internal/service/apprunner/waiter/status.go b/aws/internal/service/apprunner/waiter/status.go index c88c10debcb..137e205a5c5 100644 --- a/aws/internal/service/apprunner/waiter/status.go +++ b/aws/internal/service/apprunner/waiter/status.go @@ -9,6 +9,16 @@ import ( "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/apprunner/finder" ) +const ( + AutoScalingConfigurationStatusActive = "active" + AutoScalingConfigurationStatusInactive = "inactive" + + CustomDomainAssociationStatusActive = "active" + CustomDomainAssociationStatusCreating = "creating" + CustomDomainAssociationStatusDeleting = "deleting" + CustomDomainAssociationStatusPendingCertificateDnsValidation = "pending_certificate_dns_validation" +) + func AutoScalingConfigurationStatus(ctx context.Context, conn *apprunner.AppRunner, arn string) resource.StateRefreshFunc { return func() (interface{}, string, error) { input := &apprunner.DescribeAutoScalingConfigurationInput{ diff --git a/aws/internal/service/apprunner/waiter/waiter.go b/aws/internal/service/apprunner/waiter/waiter.go index 24e7eed4bbd..06e8e93e257 100644 --- a/aws/internal/service/apprunner/waiter/waiter.go +++ b/aws/internal/service/apprunner/waiter/waiter.go @@ -9,9 +9,6 @@ import ( ) const ( - AutoScalingConfigurationStatusActive = "active" - AutoScalingConfigurationStatusInactive = "inactive" - AutoScalingConfigurationCreateTimeout = 2 * time.Minute AutoScalingConfigurationDeleteTimeout = 2 * time.Minute @@ -66,8 +63,8 @@ func ConnectionDeleted(ctx context.Context, conn *apprunner.AppRunner, name stri func CustomDomainAssociationCreated(ctx context.Context, conn *apprunner.AppRunner, domainName, serviceArn string) error { stateConf := &resource.StateChangeConf{ - Pending: []string{apprunner.CustomDomainAssociationStatusCreating}, - Target: []string{apprunner.CustomDomainAssociationStatusPendingCertificateDnsValidation}, + Pending: []string{CustomDomainAssociationStatusCreating}, + Target: []string{CustomDomainAssociationStatusPendingCertificateDnsValidation}, Refresh: CustomDomainStatus(ctx, conn, domainName, serviceArn), Timeout: CustomDomainAssociationCreateTimeout, } @@ -79,7 +76,7 @@ func CustomDomainAssociationCreated(ctx context.Context, conn *apprunner.AppRunn func CustomDomainAssociationDeleted(ctx context.Context, conn *apprunner.AppRunner, domainName, serviceArn string) error { stateConf := &resource.StateChangeConf{ - Pending: []string{apprunner.CustomDomainAssociationStatusDeleting}, + Pending: []string{CustomDomainAssociationStatusActive, CustomDomainAssociationStatusDeleting}, Target: []string{}, Refresh: CustomDomainStatus(ctx, conn, domainName, serviceArn), Timeout: CustomDomainAssociationDeleteTimeout, diff --git a/aws/resource_aws_apprunner_auto_scaling_configuration_version_test.go b/aws/resource_aws_apprunner_auto_scaling_configuration_version_test.go index b873d7ef66b..696f49895a0 100644 --- a/aws/resource_aws_apprunner_auto_scaling_configuration_version_test.go +++ b/aws/resource_aws_apprunner_auto_scaling_configuration_version_test.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" + "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/apprunner/waiter" ) func init() { @@ -98,7 +99,7 @@ func TestAccAwsAppRunnerAutoScalingConfigurationVersion_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "max_concurrency", "100"), resource.TestCheckResourceAttr(resourceName, "max_size", "25"), resource.TestCheckResourceAttr(resourceName, "min_size", "1"), - resource.TestCheckResourceAttr(resourceName, "status", "active"), + resource.TestCheckResourceAttr(resourceName, "status", waiter.AutoScalingConfigurationStatusActive), ), }, { @@ -131,7 +132,7 @@ func TestAccAwsAppRunnerAutoScalingConfigurationVersion_complex(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "max_concurrency", "50"), resource.TestCheckResourceAttr(resourceName, "max_size", "10"), resource.TestCheckResourceAttr(resourceName, "min_size", "2"), - resource.TestCheckResourceAttr(resourceName, "status", "active"), + resource.TestCheckResourceAttr(resourceName, "status", waiter.AutoScalingConfigurationStatusActive), ), }, { @@ -151,7 +152,7 @@ func TestAccAwsAppRunnerAutoScalingConfigurationVersion_complex(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "max_concurrency", "150"), resource.TestCheckResourceAttr(resourceName, "max_size", "20"), resource.TestCheckResourceAttr(resourceName, "min_size", "5"), - resource.TestCheckResourceAttr(resourceName, "status", "active"), + resource.TestCheckResourceAttr(resourceName, "status", waiter.AutoScalingConfigurationStatusActive), ), }, { @@ -171,7 +172,7 @@ func TestAccAwsAppRunnerAutoScalingConfigurationVersion_complex(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "max_concurrency", "100"), resource.TestCheckResourceAttr(resourceName, "max_size", "25"), resource.TestCheckResourceAttr(resourceName, "min_size", "1"), - resource.TestCheckResourceAttr(resourceName, "status", "active"), + resource.TestCheckResourceAttr(resourceName, "status", waiter.AutoScalingConfigurationStatusActive), ), }, }, @@ -201,7 +202,7 @@ func TestAccAwsAppRunnerAutoScalingConfigurationVersion_MultipleVersions(t *test resource.TestCheckResourceAttr(resourceName, "max_concurrency", "100"), resource.TestCheckResourceAttr(resourceName, "max_size", "25"), resource.TestCheckResourceAttr(resourceName, "min_size", "1"), - resource.TestCheckResourceAttr(resourceName, "status", "active"), + resource.TestCheckResourceAttr(resourceName, "status", waiter.AutoScalingConfigurationStatusActive), testAccMatchResourceAttrRegionalARN(otherResourceName, "arn", "apprunner", regexp.MustCompile(fmt.Sprintf(`autoscalingconfiguration/%s/2/.+`, rName))), resource.TestCheckResourceAttr(otherResourceName, "auto_scaling_configuration_name", rName), resource.TestCheckResourceAttr(otherResourceName, "auto_scaling_configuration_revision", "2"), @@ -209,7 +210,7 @@ func TestAccAwsAppRunnerAutoScalingConfigurationVersion_MultipleVersions(t *test resource.TestCheckResourceAttr(otherResourceName, "max_concurrency", "100"), resource.TestCheckResourceAttr(otherResourceName, "max_size", "25"), resource.TestCheckResourceAttr(otherResourceName, "min_size", "1"), - resource.TestCheckResourceAttr(otherResourceName, "status", "active"), + resource.TestCheckResourceAttr(otherResourceName, "status", waiter.AutoScalingConfigurationStatusActive), ), }, { @@ -266,7 +267,7 @@ func TestAccAwsAppRunnerAutoScalingConfigurationVersion_UpdateMultipleVersions(t resource.TestCheckResourceAttr(resourceName, "max_concurrency", "100"), resource.TestCheckResourceAttr(resourceName, "max_size", "25"), resource.TestCheckResourceAttr(resourceName, "min_size", "1"), - resource.TestCheckResourceAttr(resourceName, "status", "active"), + resource.TestCheckResourceAttr(resourceName, "status", waiter.AutoScalingConfigurationStatusActive), testAccMatchResourceAttrRegionalARN(otherResourceName, "arn", "apprunner", regexp.MustCompile(fmt.Sprintf(`autoscalingconfiguration/%s/2/.+`, rName))), resource.TestCheckResourceAttr(otherResourceName, "auto_scaling_configuration_name", rName), resource.TestCheckResourceAttr(otherResourceName, "auto_scaling_configuration_revision", "2"), @@ -274,7 +275,7 @@ func TestAccAwsAppRunnerAutoScalingConfigurationVersion_UpdateMultipleVersions(t resource.TestCheckResourceAttr(otherResourceName, "max_concurrency", "125"), resource.TestCheckResourceAttr(otherResourceName, "max_size", "20"), resource.TestCheckResourceAttr(otherResourceName, "min_size", "1"), - resource.TestCheckResourceAttr(otherResourceName, "status", "active"), + resource.TestCheckResourceAttr(otherResourceName, "status", waiter.AutoScalingConfigurationStatusActive), ), }, { diff --git a/aws/resource_aws_apprunner_custom_domain_association.go b/aws/resource_aws_apprunner_custom_domain_association.go index bc8de2e084b..59a4063f201 100644 --- a/aws/resource_aws_apprunner_custom_domain_association.go +++ b/aws/resource_aws_apprunner_custom_domain_association.go @@ -27,7 +27,7 @@ func resourceAwsAppRunnerCustomDomainAssociation() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "certification_validation_records": { + "certificate_validation_records": { Type: schema.TypeSet, Computed: true, Elem: &schema.Resource{ @@ -73,6 +73,10 @@ func resourceAwsAppRunnerCustomDomainAssociation() *schema.Resource { ForceNew: true, ValidateFunc: validateArn, }, + "status": { + Type: schema.TypeString, + Computed: true, + }, }, } } @@ -142,6 +146,7 @@ func resourceAwsAppRunnerCustomDomainAssociationRead(ctx context.Context, d *sch d.Set("domain_name", customDomain.DomainName) d.Set("enable_www_subdomain", customDomain.EnableWWWSubdomain) d.Set("service_arn", serviceArn) + d.Set("status", customDomain.Status) return nil } diff --git a/aws/resource_aws_apprunner_custom_domain_association_test.go b/aws/resource_aws_apprunner_custom_domain_association_test.go index a4cb95a3ab2..72133393ac7 100644 --- a/aws/resource_aws_apprunner_custom_domain_association_test.go +++ b/aws/resource_aws_apprunner_custom_domain_association_test.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" tfapprunner "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/apprunner" "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/apprunner/finder" + "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/apprunner/waiter" ) func TestAccAwsAppRunnerCustomDomainAssociation_basic(t *testing.T) { @@ -29,18 +30,19 @@ func TestAccAwsAppRunnerCustomDomainAssociation_basic(t *testing.T) { Config: testAccAppRunnerCustomDomainAssociation_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckAwsAppRunnerCustomDomainAssociationExists(resourceName), - resource.TestCheckResourceAttr(resourceName, "certificate_validation_records.#", "2"), + resource.TestCheckResourceAttr(resourceName, "certificate_validation_records.#", "3"), resource.TestCheckResourceAttrSet(resourceName, "dns_target"), - resource.TestCheckResourceAttr(resourceName, "domain_name", "example.com"), + resource.TestCheckResourceAttr(resourceName, "domain_name", "hashicorp.com"), resource.TestCheckResourceAttr(resourceName, "enable_www_subdomain", "true"), - resource.TestCheckResourceAttr(resourceName, "status", apprunner.CustomDomainAssociationStatusPendingCertificateDnsValidation), + resource.TestCheckResourceAttr(resourceName, "status", waiter.CustomDomainAssociationStatusPendingCertificateDnsValidation), resource.TestCheckResourceAttrPair(resourceName, "service_arn", serviceResourceName, "arn"), ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"dns_target"}, }, }, })