From 06648cea10b4a01dda024b0623bd4b011a7c4d47 Mon Sep 17 00:00:00 2001 From: Angie Pinilla Date: Tue, 3 Aug 2021 01:04:54 -0400 Subject: [PATCH 1/2] add to deployment_strategy_id validation --- aws/resource_aws_appconfig_deployment.go | 2 +- aws/resource_aws_appconfig_deployment_test.go | 44 +++++++++++++++++++ .../docs/r/appconfig_deployment.html.markdown | 2 +- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_appconfig_deployment.go b/aws/resource_aws_appconfig_deployment.go index b02f480cd3d..6b0e429846e 100644 --- a/aws/resource_aws_appconfig_deployment.go +++ b/aws/resource_aws_appconfig_deployment.go @@ -58,7 +58,7 @@ func resourceAwsAppconfigDeployment() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateFunc: validation.StringMatch(regexp.MustCompile(`[a-z0-9]{4,7}`), ""), + ValidateFunc: validation.StringMatch(regexp.MustCompile(`(^[a-z0-9]{4,7}$|^AppConfig\.[A-Za-z0-9]{9,40}$)`), ""), }, "description": { Type: schema.TypeString, diff --git a/aws/resource_aws_appconfig_deployment_test.go b/aws/resource_aws_appconfig_deployment_test.go index 6371d26d329..4e2492217f9 100644 --- a/aws/resource_aws_appconfig_deployment_test.go +++ b/aws/resource_aws_appconfig_deployment_test.go @@ -53,6 +53,35 @@ func TestAccAWSAppConfigDeployment_basic(t *testing.T) { }) } +func TestAccAWSAppConfigDeployment_PredefinedStrategy(t *testing.T) { + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_deployment.test" + strategy := "AppConfig.Linear50PercentEvery30Seconds" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ErrorCheck: testAccErrorCheck(t, appconfig.EndpointsID), + Providers: testAccProviders, + // AppConfig Deployments cannot be destroyed, but we want to ensure + // the Application and its dependents are removed. + CheckDestroy: testAccCheckAppConfigApplicationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigDeploymentConfig_PredefinedStrategy(rName, strategy), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentExists(resourceName), + resource.TestCheckResourceAttr(resourceName, "deployment_strategy_id", strategy), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccAWSAppConfigDeployment_Tags(t *testing.T) { rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_deployment.test" @@ -189,6 +218,21 @@ resource "aws_appconfig_deployment" "test"{ `, rName)) } +func testAccAWSAppConfigDeploymentConfig_PredefinedStrategy(rName, strategy string) string { + return composeConfig( + testAccAWSAppConfigDeploymentConfigBase(rName), + fmt.Sprintf(` +resource "aws_appconfig_deployment" "test"{ + application_id = aws_appconfig_application.test.id + configuration_profile_id = aws_appconfig_configuration_profile.test.configuration_profile_id + configuration_version = aws_appconfig_hosted_configuration_version.test.version_number + description = %[1]q + deployment_strategy_id = %[2]q + environment_id = aws_appconfig_environment.test.environment_id +} +`, rName, strategy)) +} + func testAccAWSAppConfigDeploymentTags1(rName, tagKey1, tagValue1 string) string { return composeConfig( testAccAWSAppConfigDeploymentConfigBase(rName), diff --git a/website/docs/r/appconfig_deployment.html.markdown b/website/docs/r/appconfig_deployment.html.markdown index f24ec39d6c9..80c4923b4d0 100644 --- a/website/docs/r/appconfig_deployment.html.markdown +++ b/website/docs/r/appconfig_deployment.html.markdown @@ -34,7 +34,7 @@ The following arguments are supported: * `application_id` - (Required, Forces new resource) The application ID. Must be between 4 and 7 characters in length. * `configuration_profile_id` - (Required, Forces new resource) The configuration profile ID. Must be between 4 and 7 characters in length. * `configuration_version` - (Required, Forces new resource) The configuration version to deploy. Can be at most 1024 characters. -* `deployment_strategy_id` - (Required, Forces new resource) The deployment strategy ID. Must be between 4 and 7 characters in length. +* `deployment_strategy_id` - (Required, Forces new resource) The deployment strategy ID or name of a predefined deployment strategy. See [Predefined Deployment Strategies](https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-creating-deployment-strategy.html#appconfig-creating-deployment-strategy-predefined) for more details. * `description` - (Optional, Forces new resource) The description of the deployment. Can be at most 1024 characters. * `environment_id` - (Required, Forces new resource) The environment ID. Must be between 4 and 7 characters in length. * `tags` - (Optional) A map of tags to assign to the resource. If configured with a provider [`default_tags` configuration block](/docs/providers/aws/index.html#default_tags-configuration-block) present, tags with matching keys will overwrite those defined at the provider-level. From cd09dd6f60ad37ae4dff0c72ad483fa37fd77731 Mon Sep 17 00:00:00 2001 From: Angie Pinilla Date: Tue, 3 Aug 2021 01:11:05 -0400 Subject: [PATCH 2/2] Update CHANGELOG for #20420 --- .changelog/20420.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/20420.txt diff --git a/.changelog/20420.txt b/.changelog/20420.txt new file mode 100644 index 00000000000..e47ecd30f1f --- /dev/null +++ b/.changelog/20420.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/aws_appconfig_deployment: Include predefined strategies in plan time validation of `deployment_strategy_id` +``` \ No newline at end of file