Skip to content

Commit

Permalink
additional updates from acctest errors
Browse files Browse the repository at this point in the history
  • Loading branch information
anGie44 committed May 18, 2021
1 parent de83fe7 commit 162b2c6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 21 deletions.
10 changes: 10 additions & 0 deletions aws/internal/service/apprunner/waiter/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
9 changes: 3 additions & 6 deletions aws/internal/service/apprunner/waiter/waiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import (
)

const (
AutoScalingConfigurationStatusActive = "active"
AutoScalingConfigurationStatusInactive = "inactive"

AutoScalingConfigurationCreateTimeout = 2 * time.Minute
AutoScalingConfigurationDeleteTimeout = 2 * time.Minute

Expand Down Expand Up @@ -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,
}
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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),
),
},
{
Expand Down Expand Up @@ -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),
),
},
{
Expand All @@ -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),
),
},
{
Expand All @@ -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),
),
},
},
Expand Down Expand Up @@ -201,15 +202,15 @@ 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"),
resource.TestCheckResourceAttr(otherResourceName, "latest", "true"),
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),
),
},
{
Expand Down Expand Up @@ -266,15 +267,15 @@ 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"),
resource.TestCheckResourceAttr(otherResourceName, "latest", "true"),
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),
),
},
{
Expand Down
7 changes: 6 additions & 1 deletion aws/resource_aws_apprunner_custom_domain_association.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -73,6 +73,10 @@ func resourceAwsAppRunnerCustomDomainAssociation() *schema.Resource {
ForceNew: true,
ValidateFunc: validateArn,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -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
}
Expand Down
14 changes: 8 additions & 6 deletions aws/resource_aws_apprunner_custom_domain_association_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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"},
},
},
})
Expand Down

0 comments on commit 162b2c6

Please sign in to comment.