Skip to content

Commit

Permalink
Merge pull request #20420 from hashicorp/f-appconfig-deployment-valid…
Browse files Browse the repository at this point in the history
…ation

r/appconfig_deployment: add to `deployment_strategy_id` validation
  • Loading branch information
anGie44 authored Aug 4, 2021
2 parents 407a85c + cd09dd6 commit cff6ae4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/20420.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_appconfig_deployment: Include predefined strategies in plan time validation of `deployment_strategy_id`
```
2 changes: 1 addition & 1 deletion aws/resource_aws_appconfig_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
44 changes: 44 additions & 0 deletions aws/resource_aws_appconfig_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/appconfig_deployment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit cff6ae4

Please sign in to comment.