From 6a4208f4f6a1dfe7969f5aa976ae048d8cd81f0d Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Mon, 1 Mar 2021 13:11:47 -0500 Subject: [PATCH 01/25] Added appconfig service, application, and config profile --- aws/config.go | 3 + .../generators/servicetags/main.go | 1 + .../generators/updatetags/main.go | 1 + .../service_generation_customizations.go | 3 + aws/internal/keyvaluetags/service_tags_gen.go | 10 + aws/internal/keyvaluetags/update_tags_gen.go | 37 +++ aws/provider.go | 1 + aws/resource_aws_appconfig_application.go | 180 ++++++++++++++ ...resource_aws_appconfig_application_test.go | 220 +++++++++++++++++ ...rce_aws_appconfig_configuration_profile.go | 218 +++++++++++++++++ ...ws_appconfig_configuration_profile_test.go | 222 ++++++++++++++++++ tools/go.mod | 1 + tools/go.sum | 4 +- website/allowed-subcategories.txt | 1 + .../guides/custom-service-endpoints.html.md | 5 +- 15 files changed, 904 insertions(+), 3 deletions(-) create mode 100644 aws/resource_aws_appconfig_application.go create mode 100644 aws/resource_aws_appconfig_application_test.go create mode 100644 aws/resource_aws_appconfig_configuration_profile.go create mode 100644 aws/resource_aws_appconfig_configuration_profile_test.go diff --git a/aws/config.go b/aws/config.go index 9bc18b0aa60..afc3b13cc22 100644 --- a/aws/config.go +++ b/aws/config.go @@ -15,6 +15,7 @@ import ( "github.com/aws/aws-sdk-go/service/amplify" "github.com/aws/aws-sdk-go/service/apigateway" "github.com/aws/aws-sdk-go/service/apigatewayv2" + "github.com/aws/aws-sdk-go/service/appconfig" "github.com/aws/aws-sdk-go/service/applicationautoscaling" "github.com/aws/aws-sdk-go/service/applicationinsights" "github.com/aws/aws-sdk-go/service/appmesh" @@ -212,6 +213,7 @@ type AWSClient struct { amplifyconn *amplify.Amplify apigatewayconn *apigateway.APIGateway apigatewayv2conn *apigatewayv2.ApiGatewayV2 + appconfigconn *appconfig.AppConfig appautoscalingconn *applicationautoscaling.ApplicationAutoScaling applicationinsightsconn *applicationinsights.ApplicationInsights appmeshconn *appmesh.AppMesh @@ -454,6 +456,7 @@ func (c *Config) Client() (interface{}, error) { apigatewayconn: apigateway.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["apigateway"])})), apigatewayv2conn: apigatewayv2.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["apigateway"])})), appautoscalingconn: applicationautoscaling.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["applicationautoscaling"])})), + appconfigconn: appconfig.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["appconfig"])})), applicationinsightsconn: applicationinsights.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["applicationinsights"])})), appmeshconn: appmesh.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["appmesh"])})), appstreamconn: appstream.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["appstream"])})), diff --git a/aws/internal/keyvaluetags/generators/servicetags/main.go b/aws/internal/keyvaluetags/generators/servicetags/main.go index 413c2037e2d..73f8a9541e8 100644 --- a/aws/internal/keyvaluetags/generators/servicetags/main.go +++ b/aws/internal/keyvaluetags/generators/servicetags/main.go @@ -108,6 +108,7 @@ var mapServiceNames = []string{ "amplify", "apigateway", "apigatewayv2", + "appconfig", "appstream", "appsync", "backup", diff --git a/aws/internal/keyvaluetags/generators/updatetags/main.go b/aws/internal/keyvaluetags/generators/updatetags/main.go index 2dc4b622169..0dba6480a43 100644 --- a/aws/internal/keyvaluetags/generators/updatetags/main.go +++ b/aws/internal/keyvaluetags/generators/updatetags/main.go @@ -23,6 +23,7 @@ var serviceNames = []string{ "amplify", "apigateway", "apigatewayv2", + "appconfig", "appmesh", "appstream", "appsync", diff --git a/aws/internal/keyvaluetags/service_generation_customizations.go b/aws/internal/keyvaluetags/service_generation_customizations.go index e66c7688abb..639fb8c0c76 100644 --- a/aws/internal/keyvaluetags/service_generation_customizations.go +++ b/aws/internal/keyvaluetags/service_generation_customizations.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go/service/amplify" "github.com/aws/aws-sdk-go/service/apigateway" "github.com/aws/aws-sdk-go/service/apigatewayv2" + "github.com/aws/aws-sdk-go/service/appconfig" "github.com/aws/aws-sdk-go/service/appmesh" "github.com/aws/aws-sdk-go/service/appstream" "github.com/aws/aws-sdk-go/service/appsync" @@ -140,6 +141,8 @@ func ServiceClientType(serviceName string) string { funcType = reflect.TypeOf(apigateway.New) case "apigatewayv2": funcType = reflect.TypeOf(apigatewayv2.New) + case "appconfig": + funcType = reflect.TypeOf(appconfig.New) case "appmesh": funcType = reflect.TypeOf(appmesh.New) case "appstream": diff --git a/aws/internal/keyvaluetags/service_tags_gen.go b/aws/internal/keyvaluetags/service_tags_gen.go index bf7458fba54..d6b50d8518c 100644 --- a/aws/internal/keyvaluetags/service_tags_gen.go +++ b/aws/internal/keyvaluetags/service_tags_gen.go @@ -133,6 +133,16 @@ func Apigatewayv2KeyValueTags(tags map[string]*string) KeyValueTags { return New(tags) } +// AppconfigTags returns appconfig service tags. +func (tags KeyValueTags) AppconfigTags() map[string]*string { + return aws.StringMap(tags.Map()) +} + +// AppconfigKeyValueTags creates KeyValueTags from appconfig service tags. +func AppconfigKeyValueTags(tags map[string]*string) KeyValueTags { + return New(tags) +} + // AppstreamTags returns appstream service tags. func (tags KeyValueTags) AppstreamTags() map[string]*string { return aws.StringMap(tags.Map()) diff --git a/aws/internal/keyvaluetags/update_tags_gen.go b/aws/internal/keyvaluetags/update_tags_gen.go index d944f50f314..b25a379c907 100644 --- a/aws/internal/keyvaluetags/update_tags_gen.go +++ b/aws/internal/keyvaluetags/update_tags_gen.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go/service/amplify" "github.com/aws/aws-sdk-go/service/apigateway" "github.com/aws/aws-sdk-go/service/apigatewayv2" + "github.com/aws/aws-sdk-go/service/appconfig" "github.com/aws/aws-sdk-go/service/appmesh" "github.com/aws/aws-sdk-go/service/appstream" "github.com/aws/aws-sdk-go/service/appsync" @@ -335,6 +336,42 @@ func Apigatewayv2UpdateTags(conn *apigatewayv2.ApiGatewayV2, identifier string, return nil } +// AppconfigUpdateTags updates appconfig service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func AppconfigUpdateTags(conn *appconfig.AppConfig, identifier string, oldTagsMap interface{}, newTagsMap interface{}) error { + oldTags := New(oldTagsMap) + newTags := New(newTagsMap) + + if removedTags := oldTags.Removed(newTags); len(removedTags) > 0 { + input := &appconfig.UntagResourceInput{ + ResourceArn: aws.String(identifier), + TagKeys: aws.StringSlice(removedTags.IgnoreAws().Keys()), + } + + _, err := conn.UntagResource(input) + + if err != nil { + return fmt.Errorf("error untagging resource (%s): %w", identifier, err) + } + } + + if updatedTags := oldTags.Updated(newTags); len(updatedTags) > 0 { + input := &appconfig.TagResourceInput{ + ResourceArn: aws.String(identifier), + Tags: updatedTags.IgnoreAws().AppconfigTags(), + } + + _, err := conn.TagResource(input) + + if err != nil { + return fmt.Errorf("error tagging resource (%s): %w", identifier, err) + } + } + + return nil +} + // AppmeshUpdateTags updates appmesh service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. diff --git a/aws/provider.go b/aws/provider.go index f332f725c33..1e49be73654 100644 --- a/aws/provider.go +++ b/aws/provider.go @@ -1154,6 +1154,7 @@ func init() { "acmpca", "amplify", "apigateway", + "appconfig", "applicationautoscaling", "applicationinsights", "appmesh", diff --git a/aws/resource_aws_appconfig_application.go b/aws/resource_aws_appconfig_application.go new file mode 100644 index 00000000000..f9e37c008e8 --- /dev/null +++ b/aws/resource_aws_appconfig_application.go @@ -0,0 +1,180 @@ +package aws + +import ( + "fmt" + "log" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/arn" + "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" +) + +func resourceAwsAppconfigApplication() *schema.Resource { + return &schema.Resource{ + Create: resourceAwsAppconfigApplicationCreate, + Read: resourceAwsAppconfigApplicationRead, + Update: resourceAwsAppconfigApplicationUpdate, + Delete: resourceAwsAppconfigApplicationDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 64), + ), + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.All( + validation.StringLenBetween(0, 1024), + ), + }, + "tags": tagsSchema(), + "id": { + Type: schema.TypeString, + Computed: true, + }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func resourceAwsAppconfigApplicationCreate(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + applicationName := d.Get("name").(string) + + input := &appconfig.CreateApplicationInput{ + Name: aws.String(applicationName), + Description: aws.String(resource.UniqueId()), + Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppconfigTags(), + } + + app, err := conn.CreateApplication(input) + if err != nil { + return fmt.Errorf("Error creating AppConfig application: %s", err) + } + + d.SetId(aws.StringValue(app.Id)) + log.Printf("[INFO] AppConfig application ID: %s", d.Id()) + + return resourceAwsAppconfigApplicationRead(d, meta) +} + +func resourceAwsAppconfigApplicationRead(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig + + input := &appconfig.GetApplicationInput{ + ApplicationId: aws.String(d.Id()), + } + + output, err := conn.GetApplication(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + log.Printf("[WARN] Appconfig Application (%s) not found, removing from state", d.Id()) + d.SetId("") + return nil + } + + if err != nil { + return fmt.Errorf("error getting AppConfig Application (%s): %s", d.Id(), err) + } + + if output == nil { + return fmt.Errorf("error getting AppConfig Application (%s): empty response", d.Id()) + } + + appARN := arn.ARN{ + AccountID: meta.(*AWSClient).accountid, + Partition: meta.(*AWSClient).partition, + Region: meta.(*AWSClient).region, + Resource: fmt.Sprintf("application/%s", aws.StringValue(output.Id)), + Service: "appconfig", + }.String() + + d.Set("arn", appARN) + + tagInput := &appconfig.ListTagsForResourceInput{ + ResourceArn: aws.String(appARN), + } + + appTags, err := conn.ListTagsForResource(tagInput) + if err != nil { + return fmt.Errorf("error getting tags for AppConfig Application (%s): %s", d.Id(), err) + } + + if err := d.Set("tags", keyvaluetags.AppconfigKeyValueTags(appTags.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %s", err) + } + + return nil +} + +func resourceAwsAppconfigApplicationUpdate(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + + if d.HasChange("tags") { + o, n := d.GetChange("tags") + if err := keyvaluetags.AppconfigUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { + return fmt.Errorf("error updating AppConfig (%s) tags: %s", d.Id(), err) + } + } + + appDesc := d.Get("description").(string) + appName := d.Get("name").(string) + + updateInput := &appconfig.UpdateApplicationInput{ + ApplicationId: aws.String(d.Id()), + Description: aws.String(appDesc), + Name: aws.String(appName), + } + + if d.HasChange("description") { + _, n := d.GetChange("description") + updateInput.Description = aws.String(n.(string)) + } + + if d.HasChange("name") { + _, n := d.GetChange("name") + updateInput.Name = aws.String(n.(string)) + } + + _, err := conn.UpdateApplication(updateInput) + if err != nil { + return fmt.Errorf("error updating AppConfig (%s): %s", d.Id(), err) + } + + return resourceAwsAppconfigApplicationRead(d, meta) +} + +func resourceAwsAppconfigApplicationDelete(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + + input := &appconfig.DeleteApplicationInput{ + ApplicationId: aws.String(d.Id()), + } + + _, err := conn.DeleteApplication(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + return nil + } + + if err != nil { + return fmt.Errorf("error deleting Appconfig Application (%s): %s", d.Id(), err) + } + + return nil +} diff --git a/aws/resource_aws_appconfig_application_test.go b/aws/resource_aws_appconfig_application_test.go new file mode 100644 index 00000000000..9599101b2bb --- /dev/null +++ b/aws/resource_aws_appconfig_application_test.go @@ -0,0 +1,220 @@ +package aws + +import ( + "fmt" + "testing" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/appconfig" + "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" +) + +func TestAccAWSAppConfigApplication_basic(t *testing.T) { + var application appconfig.GetApplicationOutput + + rName := acctest.RandomWithPrefix("tf-acc-test") + rDesc := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_application.test" + fmt.Println("test starting") + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigApplicationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigApplicationName(rName, rDesc), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigApplicationExists(resourceName, &application), + resource.TestCheckResourceAttr(resourceName, "name", rName), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appconfig", aws.StringValue(application.Id)), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "description", ""), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAWSAppConfigApplication_disappears(t *testing.T) { + var application appconfig.GetApplicationOutput + + rName := acctest.RandomWithPrefix("tf-acc-test") + rDesc := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_application.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigApplicationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigApplicationName(rName, rDesc), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigApplicationExists(resourceName, &application), + testAccCheckAwsAppConfigApplicationDisappears(&application), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + +func TestAccAWSAppConfigApplication_Tags(t *testing.T) { + var application appconfig.GetApplicationOutput + + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_application.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigApplicationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigApplicationTags1(rName, "key1", "value1"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigApplicationExists(resourceName, &application), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccAWSAppConfigApplicationTags2(rName, "key1", "value1updated", "key2", "value2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigApplicationExists(resourceName, &application), + resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"), + resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), + ), + }, + { + Config: testAccAWSAppConfigApplicationTags1(rName, "key2", "value2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigApplicationExists(resourceName, &application), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), + ), + }, + }, + }) +} + +func testAccCheckAppConfigApplicationDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + for _, rs := range s.RootModule().Resources { + if rs.Type != "aws_appconfig_application" { + continue + } + + input := &appconfig.GetApplicationInput{ + ApplicationId: aws.String(rs.Primary.ID), + } + + output, err := conn.GetApplication(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + continue + } + + if err != nil { + return err + } + + if output != nil { + return fmt.Errorf("AppConfig Application (%s) still exists", rs.Primary.ID) + } + } + + return nil + +} + +func testAccCheckAwsAppConfigApplicationDisappears(application *appconfig.GetApplicationOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + input := &appconfig.DeleteApplicationInput{ + ApplicationId: aws.String(*application.Id), + } + + _, err := conn.DeleteApplication(input) + + return err + } +} + +func testAccCheckAwsAppConfigApplicationExists(resourceName string, application *appconfig.GetApplicationOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Resource not found: %s", resourceName) + } + + if rs.Primary.ID == "" { + return fmt.Errorf("Resource (%s) ID not set", resourceName) + } + + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + input := &appconfig.GetApplicationInput{ + ApplicationId: aws.String(rs.Primary.ID), + } + + output, err := conn.GetApplication(input) + + if err != nil { + return err + } + + *application = *output + + return nil + } +} + +func testAccAWSAppConfigApplicationName(rName, rDesc string) string { + return fmt.Sprintf(` +resource "aws_appconfig_application" "test" { + name = %[1]q + description = %[2]q +} +`, rName, rDesc) +} + +func testAccAWSAppConfigApplicationTags1(rName, tagKey1, tagValue1 string) string { + return fmt.Sprintf(` +resource "aws_appconfig_application" "test" { + name = %[1]q + + tags = { + %[2]q = %[3]q + } +} +`, rName, tagKey1, tagValue1) +} + +func testAccAWSAppConfigApplicationTags2(rName, tagKey1, tagValue1, tagKey2, tagValue2 string) string { + return fmt.Sprintf(` +resource "aws_appconfig_application" "test" { + name = %[1]q + + tags = { + %[2]q = %[3]q + %[4]q = %[5]q + } +} +`, rName, tagKey1, tagValue1, tagKey2, tagValue2) +} diff --git a/aws/resource_aws_appconfig_configuration_profile.go b/aws/resource_aws_appconfig_configuration_profile.go new file mode 100644 index 00000000000..a39d5c2f924 --- /dev/null +++ b/aws/resource_aws_appconfig_configuration_profile.go @@ -0,0 +1,218 @@ +package aws + +import ( + "fmt" + "log" + "regexp" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/arn" + "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" +) + +func resourceAwsAppconfigConfigurationProfile() *schema.Resource { + return &schema.Resource{ + Create: resourceAwsAppconfigApplicationCreate, + Read: resourceAwsAppconfigApplicationRead, + Update: resourceAwsAppconfigApplicationUpdate, + Delete: resourceAwsAppconfigApplicationDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 64), + ), + }, + "description": { + Type: schema.TypeString, + ValidateFunc: validation.All( + validation.StringLenBetween(0, 1024), + ), + }, + "tags": tagsSchema(), + "location_uri": { + Type: schema.TypeString, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 2048), + ), + }, + "retrieval_role_arn": { + Type: schema.TypeString, + ValidateFunc: validation.All( + validation.StringLenBetween(20, 2048), + ), + }, + "validator": { + Type: schema.TypeList, + Required: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "content": { + Type: schema.TypeString, + ValidateFunc: validation.All( + validation.StringLenBetween(0, 32768), + ), + }, + "type": { + Type: schema.TypeString, + ValidateFunc: validation.All( + validation.StringMatch(regexp.MustCompile(`JSON_SCHEMA | LAMBDA`), "must be JSON_SCHEMA or LAMBDA"), + ), + }, + }, + }, + }, + "application_id": { + Type: schema.TypeString, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 1024), + ), + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func resourceAwsAppconfigConfigurationProfileCreate(d *schema.ResourceData, meta interface{}) error { + return fmt.Errorf("error creating config profile") + conn := meta.(*AWSClient).appconfigconn + applicationName := d.Get("name").(string) + + input := &appconfig.CreateApplicationInput{ + Name: aws.String(applicationName), + Description: aws.String(resource.UniqueId()), + Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppconfigTags(), + } + + app, err := conn.CreateApplication(input) + if err != nil { + return fmt.Errorf("Error creating AppConfig application: %s", err) + } + + d.SetId(aws.StringValue(app.Id)) + log.Printf("[INFO] AppConfig application ID: %s", d.Id()) + + return resourceAwsAppconfigApplicationRead(d, meta) +} + +func resourceAwsAppconfigConfigurationProfileRead(d *schema.ResourceData, meta interface{}) error { + return fmt.Errorf("error reading config profile") + conn := meta.(*AWSClient).appconfigconn + ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig + + input := &appconfig.GetApplicationInput{ + ApplicationId: aws.String(d.Id()), + } + + output, err := conn.GetApplication(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + log.Printf("[WARN] Appconfig Application (%s) not found, removing from state", d.Id()) + d.SetId("") + return nil + } + + if err != nil { + return fmt.Errorf("error getting AppConfig Application (%s): %s", d.Id(), err) + } + + if output == nil { + return fmt.Errorf("error getting AppConfig Application (%s): empty response", d.Id()) + } + + appARN := arn.ARN{ + AccountID: meta.(*AWSClient).accountid, + Partition: meta.(*AWSClient).partition, + Region: meta.(*AWSClient).region, + Resource: fmt.Sprintf("application/%s", aws.StringValue(output.Id)), + Service: "appconfig", + }.String() + + d.Set("arn", appARN) + + tagInput := &appconfig.ListTagsForResourceInput{ + ResourceArn: aws.String(appARN), + } + + appTags, err := conn.ListTagsForResource(tagInput) + if err != nil { + return fmt.Errorf("error getting tags for AppConfig Application (%s): %s", d.Id(), err) + } + + if err := d.Set("tags", keyvaluetags.AppconfigKeyValueTags(appTags.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %s", err) + } + + return nil +} + +func resourceAwsAppconfigConfigurationProfileUpdate(d *schema.ResourceData, meta interface{}) error { + return fmt.Errorf("error updating config profile") + conn := meta.(*AWSClient).appconfigconn + + if d.HasChange("tags") { + o, n := d.GetChange("tags") + if err := keyvaluetags.AppconfigUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { + return fmt.Errorf("error updating AppConfig (%s) tags: %s", d.Id(), err) + } + } + + appDesc := d.Get("description").(string) + appName := d.Get("name").(string) + + updateInput := &appconfig.UpdateApplicationInput{ + ApplicationId: aws.String(d.Id()), + Description: aws.String(appDesc), + Name: aws.String(appName), + } + + if d.HasChange("description") { + _, n := d.GetChange("description") + updateInput.Description = aws.String(n.(string)) + } + + if d.HasChange("name") { + _, n := d.GetChange("name") + updateInput.Name = aws.String(n.(string)) + } + + _, err := conn.UpdateApplication(updateInput) + if err != nil { + return fmt.Errorf("error updating AppConfig (%s): %s", d.Id(), err) + } + + return resourceAwsAppconfigApplicationRead(d, meta) +} + +func resourceAwsAppconfigConfigurationProfileDelete(d *schema.ResourceData, meta interface{}) error { + return fmt.Errorf("error deleting config profile") + conn := meta.(*AWSClient).appconfigconn + + input := &appconfig.DeleteApplicationInput{ + ApplicationId: aws.String(d.Id()), + } + + _, err := conn.DeleteApplication(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + return nil + } + + if err != nil { + return fmt.Errorf("error deleting Appconfig Application (%s): %s", d.Id(), err) + } + + return nil +} diff --git a/aws/resource_aws_appconfig_configuration_profile_test.go b/aws/resource_aws_appconfig_configuration_profile_test.go new file mode 100644 index 00000000000..99706b89a1c --- /dev/null +++ b/aws/resource_aws_appconfig_configuration_profile_test.go @@ -0,0 +1,222 @@ +package aws + +import ( + "fmt" + "testing" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/appconfig" + "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" +) + +func TestAccAwsAppConfigConfigurationProfile_basic(t *testing.T) { + var profile appconfig.GetConfigurationProfileOutput + + rName := acctest.RandomWithPrefix("tf-acc-test") + rDesc := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_configuration_profile.test" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigApplicationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigConfigurationProfileName(rName, rDesc), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + resource.TestCheckResourceAttr(resourceName, "name", rName), + testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appconfig", fmt.Sprintf("application/%s", rName)), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "description", ""), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAwsAppConfigConfigurationProfile_disappears(t *testing.T) { + var profile appconfig.GetConfigurationProfileOutput + + rName := acctest.RandomWithPrefix("tf-acc-test") + rDesc := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_configuration_profile.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigApplicationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigConfigurationProfileName(rName, rDesc), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + testAccCheckAwsAppConfigConfigurationProfileDisappears(&profile), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + +func TestAccAwsAppConfigConfigurationProfile_Tags(t *testing.T) { + var profile appconfig.GetConfigurationProfileOutput + + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_configuration_profile.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigApplicationDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigConfigurationProfileTags1(rName, "key1", "value1"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccAWSAppConfigConfigurationProfileTags2(rName, "key1", "value1updated", "key2", "value2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"), + resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), + ), + }, + { + Config: testAccAWSAppConfigConfigurationProfileTags1(rName, "key2", "value2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), + ), + }, + }, + }) +} + +func testAccCheckAppConfigConfigurationProfileDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + for _, rs := range s.RootModule().Resources { + if rs.Type != "aws_appconfig_configuration_profile" { + continue + } + + input := &appconfig.GetConfigurationProfileInput{ + ApplicationId: aws.String(rs.Primary.Attributes["application_id"]), + ConfigurationProfileId: aws.String(rs.Primary.ID), + } + + output, err := conn.GetConfigurationProfile(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + continue + } + + if err != nil { + return err + } + + if output != nil { + return fmt.Errorf("AppConfig Configuration Profile (%s) still exists", rs.Primary.ID) + } + } + + return nil + +} + +func testAccCheckAwsAppConfigConfigurationProfileDisappears(profile *appconfig.GetConfigurationProfileOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + input := &appconfig.DeleteConfigurationProfileInput{ + ApplicationId: aws.String(*profile.ApplicationId), + ConfigurationProfileId: aws.String(*profile.Id), + } + + _, err := conn.DeleteConfigurationProfile(input) + + return err + } +} + +func testAccCheckAwsAppConfigConfigurationProfileExists(resourceName string, profile *appconfig.GetConfigurationProfileOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Resource not found: %s", resourceName) + } + + if rs.Primary.ID == "" { + return fmt.Errorf("Resource (%s) ID not set", resourceName) + } + + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + input := &appconfig.GetConfigurationProfileInput{ + ApplicationId: aws.String(rs.Primary.Attributes["application_id"]), + ConfigurationProfileId: aws.String(rs.Primary.ID), + } + + output, err := conn.GetConfigurationProfile(input) + + if err != nil { + return err + } + + *profile = *output + + return nil + } +} + +func testAccAWSAppConfigConfigurationProfileName(rName, rDesc string) string { + return fmt.Sprintf(` +resource "aws_appconfig_configuration_profile" "test" { + name = %[1]q + description = %[2]q +} +`, rName, rDesc) +} + +func testAccAWSAppConfigConfigurationProfileTags1(rName, tagKey1, tagValue1 string) string { + return fmt.Sprintf(` +resource "aws_appconfig_configuration_profile" "test" { + analyzer_name = %[1]q + + tags = { + %[2]q = %[3]q + } +} +`, rName, tagKey1, tagValue1) +} + +func testAccAWSAppConfigConfigurationProfileTags2(rName, tagKey1, tagValue1, tagKey2, tagValue2 string) string { + return fmt.Sprintf(` +resource "aws_appconfig_configuration_profile" "test" { + analyzer_name = %[1]q + + tags = { + %[2]q = %[3]q + %[4]q = %[5]q + } +} +`, rName, tagKey1, tagValue1, tagKey2, tagValue2) +} diff --git a/tools/go.mod b/tools/go.mod index 69b4bf6a6cc..22515b99490 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -8,6 +8,7 @@ require ( github.com/golangci/golangci-lint v1.35.2 github.com/hashicorp/go-changelog v0.0.0-20201005170154-56335215ce3a github.com/katbyte/terrafmt v0.2.1-0.20200913185704-5ff4421407b4 + github.com/pavius/impi v0.0.3 // indirect github.com/terraform-linters/tflint v0.20.3 ) diff --git a/tools/go.sum b/tools/go.sum index bb430a73fbf..4771f9b706b 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -328,9 +328,9 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= @@ -667,6 +667,8 @@ github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs= github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/packer-community/winrmcp v0.0.0-20180921211025-c76d91c1e7db/go.mod h1:f6Izs6JvFTdnRbziASagjZ2vmf55NSIkC/weStxCHqk= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pavius/impi v0.0.3 h1:DND6MzU+BLABhOZXbELR3FU8b+zDgcq4dOCNLhiTYuI= +github.com/pavius/impi v0.0.3/go.mod h1:x/hU0bfdWIhuOT1SKwiJg++yvkk6EuOtJk8WtDZqgr8= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= diff --git a/website/allowed-subcategories.txt b/website/allowed-subcategories.txt index b45b2e9eadc..e7bc80c1c64 100644 --- a/website/allowed-subcategories.txt +++ b/website/allowed-subcategories.txt @@ -4,6 +4,7 @@ ACM API Gateway (REST APIs) API Gateway v2 (WebSocket and HTTP APIs) Access Analyzer +AppConfig AppMesh AppSync Application Autoscaling diff --git a/website/docs/guides/custom-service-endpoints.html.md b/website/docs/guides/custom-service-endpoints.html.md index f91175ce951..5e03e5aafb1 100644 --- a/website/docs/guides/custom-service-endpoints.html.md +++ b/website/docs/guides/custom-service-endpoints.html.md @@ -19,8 +19,8 @@ This guide outlines how to get started with customizing endpoints, the available - [Getting Started with Custom Endpoints](#getting-started-with-custom-endpoints) - [Available Endpoint Customizations](#available-endpoint-customizations) - [Connecting to Local AWS Compatible Solutions](#connecting-to-local-aws-compatible-solutions) - - [DynamoDB Local](#dynamodb-local) - - [LocalStack](#localstack) + - [DynamoDB Local](#dynamodb-local) + - [LocalStack](#localstack) @@ -59,6 +59,7 @@ The Terraform AWS Provider allows the following endpoints to be customized:
  • acmpca
  • amplify
  • apigateway
  • +
  • appconfig
  • applicationautoscaling
  • applicationinsights
  • appmesh
  • From 3c765d7278047200b2acc882c766f7bbd58caaf1 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Wed, 3 Mar 2021 15:54:43 -0500 Subject: [PATCH 02/25] Added tag support for AppConfig --- .../keyvaluetags/generators/listtags/main.go | 1 + aws/internal/keyvaluetags/list_tags_gen.go | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/aws/internal/keyvaluetags/generators/listtags/main.go b/aws/internal/keyvaluetags/generators/listtags/main.go index ea4014ec53d..307774251b3 100644 --- a/aws/internal/keyvaluetags/generators/listtags/main.go +++ b/aws/internal/keyvaluetags/generators/listtags/main.go @@ -22,6 +22,7 @@ var serviceNames = []string{ "acmpca", "amplify", "apigatewayv2", + "appconfig", "appmesh", "appstream", "appsync", diff --git a/aws/internal/keyvaluetags/list_tags_gen.go b/aws/internal/keyvaluetags/list_tags_gen.go index e73978a76ea..0be3afdb979 100644 --- a/aws/internal/keyvaluetags/list_tags_gen.go +++ b/aws/internal/keyvaluetags/list_tags_gen.go @@ -9,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go/service/acmpca" "github.com/aws/aws-sdk-go/service/amplify" "github.com/aws/aws-sdk-go/service/apigatewayv2" + "github.com/aws/aws-sdk-go/service/appconfig" "github.com/aws/aws-sdk-go/service/appmesh" "github.com/aws/aws-sdk-go/service/appstream" "github.com/aws/aws-sdk-go/service/appsync" @@ -195,6 +196,23 @@ func Apigatewayv2ListTags(conn *apigatewayv2.ApiGatewayV2, identifier string) (K return Apigatewayv2KeyValueTags(output.Tags), nil } +// AppconfigListTags lists appconfig service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func AppconfigListTags(conn *appconfig.AppConfig, identifier string) (KeyValueTags, error) { + input := &appconfig.ListTagsForResourceInput{ + ResourceArn: aws.String(identifier), + } + + output, err := conn.ListTagsForResource(input) + + if err != nil { + return New(nil), err + } + + return AppconfigKeyValueTags(output.Tags), nil +} + // AppmeshListTags lists appmesh service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. From 6fd923bdce03264e7f62bc63c5c903fbe0844cd8 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Wed, 3 Mar 2021 15:55:00 -0500 Subject: [PATCH 03/25] Updated testing framework --- go.mod | 19 +++++++- go.sum | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 215bb416f38..7d9e8d0cb8f 100644 --- a/go.mod +++ b/go.mod @@ -3,22 +3,37 @@ module github.com/terraform-providers/terraform-provider-aws go 1.15 require ( - github.com/aws/aws-sdk-go v1.36.28 + cloud.google.com/go v0.78.0 // indirect + cloud.google.com/go/storage v1.14.0 // indirect + github.com/aws/aws-sdk-go v1.37.21 github.com/beevik/etree v1.1.0 github.com/fatih/color v1.9.0 // indirect github.com/hashicorp/aws-sdk-go-base v0.7.0 - github.com/hashicorp/go-cleanhttp v0.5.1 + github.com/hashicorp/go-cleanhttp v0.5.2 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/go-multierror v1.1.0 + github.com/hashicorp/go-uuid v1.0.2 // indirect github.com/hashicorp/go-version v1.2.1 + github.com/hashicorp/terraform-exec v0.13.0 // indirect github.com/hashicorp/terraform-plugin-sdk v1.16.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.1 + github.com/hashicorp/terraform-plugin-test/v2 v2.1.3 // indirect github.com/jen20/awspolicyequivalence v1.1.0 github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba + github.com/klauspost/compress v1.11.9 // indirect github.com/mattn/go-colorable v0.1.7 // indirect github.com/mitchellh/copystructure v1.0.0 github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-testing-interface v1.14.1 github.com/pquerna/otp v1.3.0 + github.com/ulikunitz/xz v0.5.10 // indirect + github.com/zclconf/go-cty v1.8.0 // indirect + go.opencensus.io v0.23.0 // indirect + golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 // indirect + golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect + golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93 // indirect + golang.org/x/sys v0.0.0-20210301091718-77cc2087c03b // indirect + google.golang.org/genproto v0.0.0-20210302174412-5ede27ff9881 // indirect + google.golang.org/grpc v1.36.0 // indirect gopkg.in/yaml.v2 v2.3.0 ) diff --git a/go.sum b/go.sum index a245bffb41e..2341c4cb0da 100644 --- a/go.sum +++ b/go.sum @@ -15,6 +15,13 @@ cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKV cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= cloud.google.com/go v0.61.0 h1:NLQf5e1OMspfNT1RAHOB3ublr1TW3YTXO8OiWwVjK2U= cloud.google.com/go v0.61.0/go.mod h1:XukKJg4Y7QsUu0Hxg3qQKUWR4VuWivmyMK2+rUyxAqw= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= +cloud.google.com/go v0.78.0 h1:oKpsiyKMfVpwR3zSAkQixGzlVE5ovitBuO0qSmCf0bI= +cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= cloud.google.com/go/bigquery v1.0.1 h1:hL+ycaJpVE9M7nLoiXb/Pn10ENE2u+oddxbD8uu0ZVU= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= @@ -37,6 +44,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0 h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.14.0 h1:6RRlFMv1omScs6iq2hfE3IvgE+l6RfJPampq8UZc5TU= +cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -59,6 +68,8 @@ github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:o github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec= +github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= +github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= @@ -69,6 +80,8 @@ github.com/aws/aws-sdk-go v1.25.3/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN github.com/aws/aws-sdk-go v1.31.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.36.28 h1:JVRN7BZgwQ31SQCBwG5QM445+ynJU0ruKu+miFIijYY= github.com/aws/aws-sdk-go v1.36.28/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= +github.com/aws/aws-sdk-go v1.37.21 h1:h3DUhpeOT0TQIwaSzXsBl+jwppfNR/Pc2T5k3SHVKPA= +github.com/aws/aws-sdk-go v1.37.21/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/beevik/etree v1.1.0 h1:T0xke/WvNtMoCqgzPhkX2r4rjY3GDZFi+FjpRZY2Jbs= github.com/beevik/etree v1.1.0/go.mod h1:r8Aw8JqVegEf0w2fDnATrX9VpkMcyFeM0FhwO62wh+A= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= @@ -84,6 +97,8 @@ github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5P github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -93,6 +108,8 @@ github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3 github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= @@ -127,6 +144,7 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3 h1:GV+pQPG/EUUbkh47niozDcADz6go/dUwhVzdUQHIVRw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -142,6 +160,8 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -151,12 +171,17 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0 h1:pMen7vLs8nvgEYhywH3KDWJIJTeEr2ULsVWHWYHQyBs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -164,9 +189,15 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -179,12 +210,16 @@ github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuD github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI= github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= github.com/hashicorp/go-getter v1.4.0/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY= github.com/hashicorp/go-getter v1.4.2-0.20200106182914-9813cbd4eb02/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY= github.com/hashicorp/go-getter v1.5.0 h1:ciWJaeZWSMbc5OiLMpKp40MKFPqO44i0h3uyfXPBkkk= github.com/hashicorp/go-getter v1.5.0/go.mod h1:a7z7NPPfNQpJWcn4rSWFtdrSldqLdLPEF3d8nFMsSLM= +github.com/hashicorp/go-getter v1.5.2 h1:XDo8LiAcDisiqZdv0TKgz+HtX3WN7zA2JD1R1tjsabE= +github.com/hashicorp/go-getter v1.5.2/go.mod h1:orNH3BTYLu/fIxGIdLjLoAJHWMDQ/UKQr5O4m3iBuoo= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= @@ -201,6 +236,8 @@ github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoD github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= @@ -219,6 +256,8 @@ github.com/hashicorp/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8 github.com/hashicorp/terraform-exec v0.10.0/go.mod h1:tOT8j1J8rP05bZBGWXfMyU3HkLi1LWyqL3Bzsc3CJjo= github.com/hashicorp/terraform-exec v0.12.0 h1:Tb1VC2gqArl9EJziJjoazep2MyxMk00tnNKV/rgMba0= github.com/hashicorp/terraform-exec v0.12.0/go.mod h1:SGhto91bVRlgXQWcJ5znSz+29UZIa8kpBbkGwQ+g9E8= +github.com/hashicorp/terraform-exec v0.13.0 h1:1Pth+pdWJAufJuWWjaVOVNEkoRTOjGn3hQpAqj4aPdg= +github.com/hashicorp/terraform-exec v0.13.0/go.mod h1:SGhto91bVRlgXQWcJ5znSz+29UZIa8kpBbkGwQ+g9E8= github.com/hashicorp/terraform-json v0.5.0/go.mod h1:eAbqb4w0pSlRmdvl8fOyHAi/+8jnkVYN28gJkSJrLhU= github.com/hashicorp/terraform-json v0.8.0 h1:XObQ3PgqU52YLQKEaJ08QtUshAfN3yu4u8ebSW0vztc= github.com/hashicorp/terraform-json v0.8.0/go.mod h1:3defM4kkMfttwiE7VakJDwCd4R+umhSQnvJwORXbprE= @@ -230,12 +269,15 @@ github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.1 h1:k2rpom9wG2cdi5iLRH80EdQB7 github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.1/go.mod h1:jgCWyjKf1BRqzuA3IPJb6PJ2YY86ePJurX9xfJtuYNU= github.com/hashicorp/terraform-plugin-test/v2 v2.1.2 h1:p96IIn+XpvVjw7AtN8y9MKxn0x69S7wtbGf7JgDJoIk= github.com/hashicorp/terraform-plugin-test/v2 v2.1.2/go.mod h1:jerO5mrd+jVNALy8aiq+VZOg/CR8T2T1QR3jd6JKGOI= +github.com/hashicorp/terraform-plugin-test/v2 v2.1.3 h1:sMsxHctzjATk+ICHAqiHFqLkjosl4fjMyFxMthLRH2Q= +github.com/hashicorp/terraform-plugin-test/v2 v2.1.3/go.mod h1:pmaUHiUtDL/8Mz3FuyZ/vRDb0LpaOWQjVRW9ORF7FHs= github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596 h1:hjyO2JsNZUKT1ym+FAdlBEkGPevazYsmVgIMw7dVELg= github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.9 h1:UauaLniWCFHWd+Jp9oCEkTBj8VO/9DKg3PV3VCNMDIg= github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= @@ -260,6 +302,10 @@ github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba h1:NARVGAAgEXvoMeNPHhPFt1SBt1VMznA3Gnz9d0qj+co= github.com/keybase/go-crypto v0.0.0-20161004153544-93f5b35093ba/go.mod h1:ghbZscTyKdM07+Fw3KSi0hcJm+AlEUWj8QLlPtijN/M= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.11.2 h1:MiK62aErc3gIiVEtyzKfeOHgW7atJb5g/KNX5m3c2nQ= +github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.11.9 h1:5OCMOdde1TCT2sookEuVeEZzA8bmRSFV3AwPDZAG8AA= +github.com/klauspost/compress v1.11.9/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -343,20 +389,29 @@ github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4A github.com/ulikunitz/xz v0.5.7/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ= github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/ulikunitz/xz v0.5.10 h1:t92gobL9l3HE202wg3rlk19F6X+JOxl9BBrCCMYEYd8= +github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= +github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U= +github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= +github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= +github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.2.1 h1:vGMsygfmeCl4Xb6OA5U5XVAaQZ69FvoG7X2jUtQujb8= github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= +github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA= +github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8= github.com/zclconf/go-cty-yaml v1.0.1 h1:up11wlgAaDvlAGENcFDnZgkn0qUJurso7k6EpURKNF8= github.com/zclconf/go-cty-yaml v1.0.1/go.mod h1:IP3Ylp0wQpYm50IHK8OZWKMu6sPJIUgKa8XhiVHura0= @@ -366,6 +421,9 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4 h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -375,6 +433,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g= +golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -398,6 +458,8 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b h1:Wh+f8QHJXR411sJR8/vRBTZ7YapZaRvUcLFFJhusH0k= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -407,6 +469,9 @@ golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzB golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -435,14 +500,28 @@ golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/ golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b h1:uwuIcX0g4Yl1NC5XAz37xsr2lTtcqevgzYNVt49waME= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d h1:TzXSXBo42m9gQenoE3b9BGiEpg5IG2JkU5FkPIawgtw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93 h1:alLDrZkL34Y2bnGHfvC1CYBRBXCXgx8AC2vY4MRtYX4= +golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -451,6 +530,8 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -482,14 +563,29 @@ golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210301091718-77cc2087c03b h1:kHlr0tATeLRMEiZJu5CknOw/E8V6h69sXXQFGoPtjcc= +golang.org/x/sys v0.0.0-20210301091718-77cc2087c03b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -532,10 +628,23 @@ golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed h1:+qzWo37K31KxduIYaBeMqJ8MUOyTayOQKpH9aDPLMSY= golang.org/x/tools v0.0.0-20200713011307-fd294ab11aed/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -552,6 +661,11 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0 h1:BaiDisFir8O4IJxvAabCGGkQ6yCJegNQqSVoYUNAnbk= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0 h1:uWrpz12dpVPn7cojP82mk02XDgTJLDPc2KbVTxrWb4A= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -559,6 +673,8 @@ google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6 h1:lMO5rYAqUxkmaj76jAkRUvt5JZgFymx/+Q5Mzfivuhc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= @@ -588,6 +704,19 @@ google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEY google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200711021454-869866162049 h1:YFTFpQhgvrLrmxtiIncJxFXeCyq84ixuKWVCaCAi9Oc= google.golang.org/genproto v0.0.0-20200711021454-869866162049/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210302174412-5ede27ff9881 h1:SYuy3hIRsBIROE0aZwsJZOEJNC/n9/p0FmLEU9C31AE= +google.golang.org/genproto v0.0.0-20210302174412-5ede27ff9881/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -600,8 +729,15 @@ google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.32.0 h1:zWTV+LMdc3kaiJMSTOFz2UgSBgx8RNQoTGiZu3fR9S0= google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.0 h1:o1bcQ6imQMIOpdrO3SWf2z5RV72WbDwdXuK0MDlc8As= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From 2317ca741097a0459418f7482414c3a73de93241 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Wed, 3 Mar 2021 15:55:55 -0500 Subject: [PATCH 04/25] Fixed application acceptance tests --- aws/resource_aws_appconfig_application.go | 15 ++++++------- ...resource_aws_appconfig_application_test.go | 21 +++++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/aws/resource_aws_appconfig_application.go b/aws/resource_aws_appconfig_application.go index f9e37c008e8..5e273747f81 100644 --- a/aws/resource_aws_appconfig_application.go +++ b/aws/resource_aws_appconfig_application.go @@ -7,7 +7,6 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" @@ -54,10 +53,11 @@ func resourceAwsAppconfigApplication() *schema.Resource { func resourceAwsAppconfigApplicationCreate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).appconfigconn applicationName := d.Get("name").(string) + applicationDescription := d.Get("description").(string) input := &appconfig.CreateApplicationInput{ Name: aws.String(applicationName), - Description: aws.String(resource.UniqueId()), + Description: aws.String(applicationDescription), Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppconfigTags(), } @@ -67,7 +67,6 @@ func resourceAwsAppconfigApplicationCreate(d *schema.ResourceData, meta interfac } d.SetId(aws.StringValue(app.Id)) - log.Printf("[INFO] AppConfig application ID: %s", d.Id()) return resourceAwsAppconfigApplicationRead(d, meta) } @@ -105,17 +104,15 @@ func resourceAwsAppconfigApplicationRead(d *schema.ResourceData, meta interface{ }.String() d.Set("arn", appARN) + d.Set("name", output.Name) + d.Set("description", output.Description) - tagInput := &appconfig.ListTagsForResourceInput{ - ResourceArn: aws.String(appARN), - } - - appTags, err := conn.ListTagsForResource(tagInput) + tags, err := keyvaluetags.AppconfigListTags(conn, appARN) if err != nil { return fmt.Errorf("error getting tags for AppConfig Application (%s): %s", d.Id(), err) } - if err := d.Set("tags", keyvaluetags.AppconfigKeyValueTags(appTags.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { return fmt.Errorf("error setting tags: %s", err) } diff --git a/aws/resource_aws_appconfig_application_test.go b/aws/resource_aws_appconfig_application_test.go index 9599101b2bb..7dee88e1368 100644 --- a/aws/resource_aws_appconfig_application_test.go +++ b/aws/resource_aws_appconfig_application_test.go @@ -13,12 +13,10 @@ import ( func TestAccAWSAppConfigApplication_basic(t *testing.T) { var application appconfig.GetApplicationOutput - rName := acctest.RandomWithPrefix("tf-acc-test") - rDesc := acctest.RandomWithPrefix("tf-acc-test") + rDesc := acctest.RandomWithPrefix("desc") resourceName := "aws_appconfig_application.test" - fmt.Println("test starting") - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigApplicationDestroy, @@ -28,9 +26,9 @@ func TestAccAWSAppConfigApplication_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckAwsAppConfigApplicationExists(resourceName, &application), resource.TestCheckResourceAttr(resourceName, "name", rName), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appconfig", aws.StringValue(application.Id)), + testAccCheckAWSAppConfigApplicationARN(resourceName, &application), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), - resource.TestCheckResourceAttr(resourceName, "description", ""), + resource.TestCheckResourceAttr(resourceName, "description", rDesc), ), }, { @@ -49,7 +47,7 @@ func TestAccAWSAppConfigApplication_disappears(t *testing.T) { rDesc := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_application.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigApplicationDestroy, @@ -72,7 +70,7 @@ func TestAccAWSAppConfigApplication_Tags(t *testing.T) { rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_application.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigApplicationDestroy, @@ -174,7 +172,6 @@ func testAccCheckAwsAppConfigApplicationExists(resourceName string, application } output, err := conn.GetApplication(input) - if err != nil { return err } @@ -185,6 +182,12 @@ func testAccCheckAwsAppConfigApplicationExists(resourceName string, application } } +func testAccCheckAWSAppConfigApplicationARN(resourceName string, application *appconfig.GetApplicationOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + return testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appconfig", fmt.Sprintf("application/%s", aws.StringValue(application.Id)))(s) + } +} + func testAccAWSAppConfigApplicationName(rName, rDesc string) string { return fmt.Sprintf(` resource "aws_appconfig_application" "test" { From fe80b389504c36813913707266b1a16d20dd4ef3 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Wed, 3 Mar 2021 15:56:29 -0500 Subject: [PATCH 05/25] Updated to ecs task set to sdk v2 --- aws/resource_aws_ecs_task_set_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_ecs_task_set_test.go b/aws/resource_aws_ecs_task_set_test.go index a11b27e746f..671a09e0e57 100644 --- a/aws/resource_aws_ecs_task_set_test.go +++ b/aws/resource_aws_ecs_task_set_test.go @@ -7,9 +7,9 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ecs" - "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" + "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" ) func TestAccAwsEcsTaskSet_basic(t *testing.T) { From 80891608ef5edc5e8f35d1a10dbc3d7736ffcbac Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Wed, 3 Mar 2021 15:57:09 -0500 Subject: [PATCH 06/25] Added configuration profile functionality and tests --- aws/provider.go | 2 + ...rce_aws_appconfig_configuration_profile.go | 204 ++++++++----- ...ws_appconfig_configuration_profile_test.go | 273 +++++++++++++++--- 3 files changed, 366 insertions(+), 113 deletions(-) diff --git a/aws/provider.go b/aws/provider.go index 1e49be73654..c9be7da5db5 100644 --- a/aws/provider.go +++ b/aws/provider.go @@ -449,6 +449,8 @@ func Provider() *schema.Provider { "aws_appautoscaling_target": resourceAwsAppautoscalingTarget(), "aws_appautoscaling_policy": resourceAwsAppautoscalingPolicy(), "aws_appautoscaling_scheduled_action": resourceAwsAppautoscalingScheduledAction(), + "aws_appconfig_application": resourceAwsAppconfigApplication(), + "aws_appconfig_configuration_profile": resourceAwsAppconfigConfigurationProfile(), "aws_appmesh_gateway_route": resourceAwsAppmeshGatewayRoute(), "aws_appmesh_mesh": resourceAwsAppmeshMesh(), "aws_appmesh_route": resourceAwsAppmeshRoute(), diff --git a/aws/resource_aws_appconfig_configuration_profile.go b/aws/resource_aws_appconfig_configuration_profile.go index a39d5c2f924..5b8d6100f8c 100644 --- a/aws/resource_aws_appconfig_configuration_profile.go +++ b/aws/resource_aws_appconfig_configuration_profile.go @@ -3,12 +3,10 @@ package aws import ( "fmt" "log" - "regexp" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" @@ -16,15 +14,16 @@ import ( func resourceAwsAppconfigConfigurationProfile() *schema.Resource { return &schema.Resource{ - Create: resourceAwsAppconfigApplicationCreate, - Read: resourceAwsAppconfigApplicationRead, - Update: resourceAwsAppconfigApplicationUpdate, - Delete: resourceAwsAppconfigApplicationDelete, - Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, - }, + Create: resourceAwsAppconfigConfigurationProfileCreate, + Read: resourceAwsAppconfigConfigurationProfileRead, + Update: resourceAwsAppconfigConfigurationProfileUpdate, + Delete: resourceAwsAppconfigConfigurationProfileDelete, Schema: map[string]*schema.Schema{ + "application_id": { + Type: schema.TypeString, + Required: true, + }, "name": { Type: schema.TypeString, Required: true, @@ -33,125 +32,139 @@ func resourceAwsAppconfigConfigurationProfile() *schema.Resource { ), }, "description": { - Type: schema.TypeString, + Type: schema.TypeString, + Optional: true, ValidateFunc: validation.All( validation.StringLenBetween(0, 1024), ), }, - "tags": tagsSchema(), "location_uri": { - Type: schema.TypeString, + Type: schema.TypeString, + Required: true, ValidateFunc: validation.All( validation.StringLenBetween(1, 2048), ), }, "retrieval_role_arn": { - Type: schema.TypeString, - ValidateFunc: validation.All( - validation.StringLenBetween(20, 2048), - ), + Type: schema.TypeString, + Optional: true, + ValidateFunc: validateArn, }, - "validator": { - Type: schema.TypeList, - Required: true, + "validators": { + Type: schema.TypeSet, + Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "content": { - Type: schema.TypeString, - ValidateFunc: validation.All( - validation.StringLenBetween(0, 32768), - ), - }, "type": { - Type: schema.TypeString, - ValidateFunc: validation.All( - validation.StringMatch(regexp.MustCompile(`JSON_SCHEMA | LAMBDA`), "must be JSON_SCHEMA or LAMBDA"), - ), + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.StringInSlice([]string{"JSON_SCHEMA", "LAMBDA"}, false), + }, + "content": { + Type: schema.TypeInt, + Required: true, }, }, }, }, - "application_id": { - Type: schema.TypeString, - ValidateFunc: validation.All( - validation.StringLenBetween(1, 1024), - ), - }, + "tags": tagsSchema(), "id": { Type: schema.TypeString, Computed: true, }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, }, } } func resourceAwsAppconfigConfigurationProfileCreate(d *schema.ResourceData, meta interface{}) error { - return fmt.Errorf("error creating config profile") conn := meta.(*AWSClient).appconfigconn - applicationName := d.Get("name").(string) + applicationID := aws.String(d.Get("application_id").(string)) + configProfileName := aws.String(d.Get("name").(string)) + configProfileDescription := aws.String(d.Get("description").(string)) + locationURI := aws.String(d.Get("location_uri").(string)) + retreivalRoleArn := aws.String(d.Get("retrieval_role_arn").(string)) + if *retreivalRoleArn == "" { + retreivalRoleArn = nil + } - input := &appconfig.CreateApplicationInput{ - Name: aws.String(applicationName), - Description: aws.String(resource.UniqueId()), - Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppconfigTags(), + log.Printf("[INFO] on create, validators %#v", d.Get("validators").(*schema.Set).List()) + var validatorList []*appconfig.Validator + if validators := d.Get("validators").(*schema.Set).List(); len(validators) > 0 { + validatorList = convertMapToValidators(validators) } - app, err := conn.CreateApplication(input) + input := &appconfig.CreateConfigurationProfileInput{ + ApplicationId: (applicationID), + Name: configProfileName, + Description: configProfileDescription, + LocationUri: locationURI, + RetrievalRoleArn: retreivalRoleArn, + Validators: validatorList, + Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppconfigTags(), + } + + config, err := conn.CreateConfigurationProfile(input) if err != nil { - return fmt.Errorf("Error creating AppConfig application: %s", err) + return fmt.Errorf("Error creating AppConfig configuration profile: %s", err) } - d.SetId(aws.StringValue(app.Id)) - log.Printf("[INFO] AppConfig application ID: %s", d.Id()) + d.SetId(aws.StringValue(config.Id)) - return resourceAwsAppconfigApplicationRead(d, meta) + return resourceAwsAppconfigConfigurationProfileRead(d, meta) } func resourceAwsAppconfigConfigurationProfileRead(d *schema.ResourceData, meta interface{}) error { - return fmt.Errorf("error reading config profile") conn := meta.(*AWSClient).appconfigconn ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig - input := &appconfig.GetApplicationInput{ - ApplicationId: aws.String(d.Id()), + input := &appconfig.GetConfigurationProfileInput{ + ApplicationId: aws.String(d.Get("application_id").(string)), + ConfigurationProfileId: aws.String(d.Id()), } - output, err := conn.GetApplication(input) + output, err := conn.GetConfigurationProfile(input) if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { - log.Printf("[WARN] Appconfig Application (%s) not found, removing from state", d.Id()) + log.Printf("[WARN] Appconfig Configuration Profile (%s) not found, removing from state", d.Id()) d.SetId("") return nil } if err != nil { - return fmt.Errorf("error getting AppConfig Application (%s): %s", d.Id(), err) + return fmt.Errorf("error getting AppConfig Configuration Profile (%s): %s", d.Id(), err) } if output == nil { - return fmt.Errorf("error getting AppConfig Application (%s): empty response", d.Id()) + return fmt.Errorf("error getting AppConfig Configuration Profile (%s): empty response", d.Id()) } appARN := arn.ARN{ AccountID: meta.(*AWSClient).accountid, Partition: meta.(*AWSClient).partition, Region: meta.(*AWSClient).region, - Resource: fmt.Sprintf("application/%s", aws.StringValue(output.Id)), + Resource: fmt.Sprintf("application/%s/configurationprofile/%s", aws.StringValue(output.ApplicationId), aws.StringValue(output.Id)), Service: "appconfig", }.String() d.Set("arn", appARN) - - tagInput := &appconfig.ListTagsForResourceInput{ - ResourceArn: aws.String(appARN), - } - - appTags, err := conn.ListTagsForResource(tagInput) + d.Set("name", output.Name) + d.Set("description", output.Description) + d.Set("location_uri", output.LocationUri) + d.Set("retrieval_role_arn", output.RetrievalRoleArn) + log.Printf("[INFO] on set, validators from output %#v", output.Validators) + log.Printf("[INFO] on set, validators map %#v", convertValidatorsToMap(output.Validators)) + d.Set("validators", convertValidatorsToMap(output.Validators)) + + tags, err := keyvaluetags.AppconfigListTags(conn, appARN) if err != nil { - return fmt.Errorf("error getting tags for AppConfig Application (%s): %s", d.Id(), err) + return fmt.Errorf("error getting tags for AppConfig Configuration Profile (%s): %s", d.Id(), err) } - if err := d.Set("tags", keyvaluetags.AppconfigKeyValueTags(appTags.Tags).IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { return fmt.Errorf("error setting tags: %s", err) } @@ -159,7 +172,6 @@ func resourceAwsAppconfigConfigurationProfileRead(d *schema.ResourceData, meta i } func resourceAwsAppconfigConfigurationProfileUpdate(d *schema.ResourceData, meta interface{}) error { - return fmt.Errorf("error updating config profile") conn := meta.(*AWSClient).appconfigconn if d.HasChange("tags") { @@ -169,13 +181,26 @@ func resourceAwsAppconfigConfigurationProfileUpdate(d *schema.ResourceData, meta } } - appDesc := d.Get("description").(string) - appName := d.Get("name").(string) + applicationID := aws.String(d.Get("application_id").(string)) + configProfileID := aws.String(d.Id()) + configProfileName := aws.String(d.Get("name").(string)) + configProfileDescription := aws.String(d.Get("description").(string)) + retreivalRoleArn := aws.String(d.Get("retrieval_role_arn").(string)) + if *retreivalRoleArn == "" { + retreivalRoleArn = nil + } + var validatorList []*appconfig.Validator + if validators := d.Get("validators").(*schema.Set).List(); len(validators) > 0 { + validatorList = convertMapToValidators(validators) + } - updateInput := &appconfig.UpdateApplicationInput{ - ApplicationId: aws.String(d.Id()), - Description: aws.String(appDesc), - Name: aws.String(appName), + updateInput := &appconfig.UpdateConfigurationProfileInput{ + ApplicationId: applicationID, + ConfigurationProfileId: configProfileID, + Description: configProfileDescription, + Name: configProfileName, + RetrievalRoleArn: retreivalRoleArn, + Validators: validatorList, } if d.HasChange("description") { @@ -188,31 +213,56 @@ func resourceAwsAppconfigConfigurationProfileUpdate(d *schema.ResourceData, meta updateInput.Name = aws.String(n.(string)) } - _, err := conn.UpdateApplication(updateInput) + _, err := conn.UpdateConfigurationProfile(updateInput) if err != nil { - return fmt.Errorf("error updating AppConfig (%s): %s", d.Id(), err) + return fmt.Errorf("error updating AppConfig Configuration Profile (%s): %s", d.Id(), err) } - return resourceAwsAppconfigApplicationRead(d, meta) + return resourceAwsAppconfigConfigurationProfileRead(d, meta) } func resourceAwsAppconfigConfigurationProfileDelete(d *schema.ResourceData, meta interface{}) error { - return fmt.Errorf("error deleting config profile") conn := meta.(*AWSClient).appconfigconn - input := &appconfig.DeleteApplicationInput{ - ApplicationId: aws.String(d.Id()), + input := &appconfig.DeleteConfigurationProfileInput{ + ApplicationId: aws.String(d.Get("application_id").(string)), + ConfigurationProfileId: aws.String(d.Id()), } - _, err := conn.DeleteApplication(input) + _, err := conn.DeleteConfigurationProfile(input) if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { return nil } if err != nil { - return fmt.Errorf("error deleting Appconfig Application (%s): %s", d.Id(), err) + return fmt.Errorf("error deleting Appconfig Configuration Profile (%s): %s", d.Id(), err) } return nil } + +func convertMapToValidators(validatorMap []interface{}) []*appconfig.Validator { + validatorList := make([]*appconfig.Validator, len(validatorMap)) + for i, v := range validatorMap { + vMap := v.(map[string]string) + validator := appconfig.Validator{ + Content: aws.String(vMap["type"]), + Type: aws.String(vMap["content"]), + } + validatorList[i] = &validator + } + return validatorList +} + +func convertValidatorsToMap(validatorList []*appconfig.Validator) []map[string]string { + validatorMap := make([]map[string]string, len(validatorList)) + for i, v := range validatorList { + validator := map[string]string{ + "content": aws.StringValue(v.Type), + "type": aws.StringValue(v.Content), + } + validatorMap[i] = validator + } + return validatorMap +} diff --git a/aws/resource_aws_appconfig_configuration_profile_test.go b/aws/resource_aws_appconfig_configuration_profile_test.go index 99706b89a1c..5d7b5244018 100644 --- a/aws/resource_aws_appconfig_configuration_profile_test.go +++ b/aws/resource_aws_appconfig_configuration_profile_test.go @@ -14,29 +14,29 @@ import ( func TestAccAwsAppConfigConfigurationProfile_basic(t *testing.T) { var profile appconfig.GetConfigurationProfileOutput + appName := acctest.RandomWithPrefix("tf-acc-test") rName := acctest.RandomWithPrefix("tf-acc-test") rDesc := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_configuration_profile.test" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testAccCheckAppConfigApplicationDestroy, + CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSAppConfigConfigurationProfileName(rName, rDesc), + Config: testAccAWSAppConfigConfigurationProfileName(appName, rName, rDesc), Check: resource.ComposeTestCheckFunc( testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "name", rName), - testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appconfig", fmt.Sprintf("application/%s", rName)), + testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), - resource.TestCheckResourceAttr(resourceName, "description", ""), + resource.TestCheckResourceAttr(resourceName, "description", rDesc), + resource.TestCheckResourceAttr(resourceName, "location_uri", "hosted"), + resource.TestCheckResourceAttr(resourceName, "retrieval_role_arn", ""), + resource.TestCheckResourceAttr(resourceName, "validator.%", "0"), + resource.TestCheckResourceAttrSet(resourceName, "application_id"), ), }, - { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, }, }) } @@ -44,6 +44,7 @@ func TestAccAwsAppConfigConfigurationProfile_basic(t *testing.T) { func TestAccAwsAppConfigConfigurationProfile_disappears(t *testing.T) { var profile appconfig.GetConfigurationProfileOutput + appName := acctest.RandomWithPrefix("tf-acc-test") rName := acctest.RandomWithPrefix("tf-acc-test") rDesc := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_configuration_profile.test" @@ -51,10 +52,10 @@ func TestAccAwsAppConfigConfigurationProfile_disappears(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testAccCheckAppConfigApplicationDestroy, + CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSAppConfigConfigurationProfileName(rName, rDesc), + Config: testAccAWSAppConfigConfigurationProfileName(appName, rName, rDesc), Check: resource.ComposeTestCheckFunc( testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), testAccCheckAwsAppConfigConfigurationProfileDisappears(&profile), @@ -64,20 +65,99 @@ func TestAccAwsAppConfigConfigurationProfile_disappears(t *testing.T) { }, }) } +func TestAccAWSAppConfigConfigurationProfile_LocationURIs(t *testing.T) { + var profile appconfig.GetConfigurationProfileOutput + appName := acctest.RandomWithPrefix("tf-acc-test") + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_configuration_profile.test" + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigConfigurationProfileLocationSSMParameter(appName, rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + resource.TestCheckResourceAttr(resourceName, "name", rName), + testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), + resource.TestCheckResourceAttrSet(resourceName, "location_uri"), + ), + }, + { + Config: testAccAWSAppConfigConfigurationProfileLocationSSMDocument(appName, rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + resource.TestCheckResourceAttr(resourceName, "name", rName), + testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), + resource.TestCheckResourceAttrSet(resourceName, "location_uri"), + ), + }, + }, + }) +} + +func TestAccAWSAppConfigConfigurationProfile_Validators(t *testing.T) { + var profile appconfig.GetConfigurationProfileOutput + appName := acctest.RandomWithPrefix("tf-acc-test") + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_configuration_profile.test" + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigConfigurationProfileValidator(appName, rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + resource.TestCheckResourceAttr(resourceName, "name", rName), + testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + ), + }, + }, + }) +} + +func TestAccAWSAppConfigConfigurationProfile_RetrievalARN(t *testing.T) { + var profile appconfig.GetConfigurationProfileOutput + appName := acctest.RandomWithPrefix("tf-acc-test") + rName := acctest.RandomWithPrefix("tf-acc-test") + + resourceName := "aws_appconfig_configuration_profile.test" + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigConfigurationProfileRetreivalARN(appName, rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + resource.TestCheckResourceAttr(resourceName, "name", rName), + testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + ), + }, + }, + }) +} func TestAccAwsAppConfigConfigurationProfile_Tags(t *testing.T) { var profile appconfig.GetConfigurationProfileOutput + appName := acctest.RandomWithPrefix("tf-acc-test") rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_configuration_profile.test" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, - CheckDestroy: testAccCheckAppConfigApplicationDestroy, + CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSAppConfigConfigurationProfileTags1(rName, "key1", "value1"), + Config: testAccAWSAppConfigConfigurationProfileTags1(appName, rName, "key1", "value1"), Check: resource.ComposeTestCheckFunc( testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), @@ -85,12 +165,7 @@ func TestAccAwsAppConfigConfigurationProfile_Tags(t *testing.T) { ), }, { - ResourceName: resourceName, - ImportState: true, - ImportStateVerify: true, - }, - { - Config: testAccAWSAppConfigConfigurationProfileTags2(rName, "key1", "value1updated", "key2", "value2"), + Config: testAccAWSAppConfigConfigurationProfileTags2(appName, rName, "key1", "value1updated", "key2", "value2"), Check: resource.ComposeTestCheckFunc( testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), @@ -99,7 +174,7 @@ func TestAccAwsAppConfigConfigurationProfile_Tags(t *testing.T) { ), }, { - Config: testAccAWSAppConfigConfigurationProfileTags1(rName, "key2", "value2"), + Config: testAccAWSAppConfigConfigurationProfileTags1(appName, rName, "key2", "value2"), Check: resource.ComposeTestCheckFunc( testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), @@ -110,6 +185,13 @@ func TestAccAwsAppConfigConfigurationProfile_Tags(t *testing.T) { }) } +func testAccCheckAWSAppConfigConfigurationProfileARN(resourceName string, config *appconfig.GetConfigurationProfileOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + resourceArn := fmt.Sprintf("application/%s/configurationprofile/%s", aws.StringValue(config.ApplicationId), aws.StringValue(config.Id)) + return testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appconfig", resourceArn)(s) + } +} + func testAccCheckAppConfigConfigurationProfileDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).appconfigconn @@ -187,36 +269,155 @@ func testAccCheckAwsAppConfigConfigurationProfileExists(resourceName string, pro } } -func testAccAWSAppConfigConfigurationProfileName(rName, rDesc string) string { +func testAccAWSAppConfigConfigurationProfileName(appName, rName, rDesc string) string { return fmt.Sprintf(` +resource "aws_appconfig_application" "app" { + name = %[1]q +} resource "aws_appconfig_configuration_profile" "test" { - name = %[1]q - description = %[2]q + name = %[2]q + description = %[3]q + application_id = aws_appconfig_application.app.id + location_uri = "hosted" } -`, rName, rDesc) +`, appName, rName, rDesc) } -func testAccAWSAppConfigConfigurationProfileTags1(rName, tagKey1, tagValue1 string) string { +func testAccAWSAppConfigConfigurationProfileLocationSSMParameter(appName, rName string) string { return fmt.Sprintf(` +resource "aws_appconfig_application" "app" { + name = %[1]q +} +resource "aws_ssm_parameter" "ssm_param" { + name = "foo" + type = "String" + value = "bar" + } resource "aws_appconfig_configuration_profile" "test" { - analyzer_name = %[1]q + name = %[2]q + application_id = aws_appconfig_application.app.id + location_uri = aws_ssm_parameter.ssm_param.arn +} +`, appName, rName) +} - tags = { - %[2]q = %[3]q +func testAccAWSAppConfigConfigurationProfileLocationSSMDocument(appName, rName string) string { + return fmt.Sprintf(` +resource "aws_appconfig_application" "app" { + name = %[1]q +} +resource "aws_ssm_document" "ssm_doc" { + name = "test_document" + document_type = "Command" + + content = < Date: Wed, 3 Mar 2021 16:44:05 -0500 Subject: [PATCH 07/25] Added initial settings pull from Appconfig --- ...ws_appconfig_configuration_profile_test.go | 46 +++++++++++++++++-- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/aws/resource_aws_appconfig_configuration_profile_test.go b/aws/resource_aws_appconfig_configuration_profile_test.go index 5d7b5244018..95f48706c83 100644 --- a/aws/resource_aws_appconfig_configuration_profile_test.go +++ b/aws/resource_aws_appconfig_configuration_profile_test.go @@ -70,7 +70,7 @@ func TestAccAWSAppConfigConfigurationProfile_LocationURIs(t *testing.T) { appName := acctest.RandomWithPrefix("tf-acc-test") rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_configuration_profile.test" - resource.ParallelTest(t, resource.TestCase{ + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, @@ -82,6 +82,7 @@ func TestAccAWSAppConfigConfigurationProfile_LocationURIs(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "name", rName), testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), resource.TestCheckResourceAttrSet(resourceName, "location_uri"), + resource.TestCheckResourceAttrSet(resourceName, "retrieval_role_arn"), ), }, { @@ -91,6 +92,7 @@ func TestAccAWSAppConfigConfigurationProfile_LocationURIs(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "name", rName), testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), resource.TestCheckResourceAttrSet(resourceName, "location_uri"), + resource.TestCheckResourceAttrSet(resourceName, "retrieval_role_arn"), ), }, }, @@ -102,7 +104,7 @@ func TestAccAWSAppConfigConfigurationProfile_Validators(t *testing.T) { appName := acctest.RandomWithPrefix("tf-acc-test") rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_configuration_profile.test" - resource.ParallelTest(t, resource.TestCase{ + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, @@ -126,7 +128,7 @@ func TestAccAWSAppConfigConfigurationProfile_RetrievalARN(t *testing.T) { rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_configuration_profile.test" - resource.ParallelTest(t, resource.TestCase{ + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, @@ -137,7 +139,7 @@ func TestAccAWSAppConfigConfigurationProfile_RetrievalARN(t *testing.T) { testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "name", rName), testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttrSet(resourceName, "retrieval_role_arn"), ), }, }, @@ -288,6 +290,23 @@ func testAccAWSAppConfigConfigurationProfileLocationSSMParameter(appName, rName resource "aws_appconfig_application" "app" { name = %[1]q } +resource "aws_iam_role" "test_role" { + name = "test_role" + + assume_role_policy = jsonencode({ + Version = "2012-10-17" + Statement = [ + { + Action = "sts:AssumeRole" + Effect = "Allow" + Sid = "" + Principal = { + Service = "ec2.amazonaws.com" + } + }, + ] + }) +} resource "aws_ssm_parameter" "ssm_param" { name = "foo" type = "String" @@ -297,6 +316,7 @@ resource "aws_appconfig_configuration_profile" "test" { name = %[2]q application_id = aws_appconfig_application.app.id location_uri = aws_ssm_parameter.ssm_param.arn + retrieval_role_arn = aws_iam_role.test_role.arn } `, appName, rName) } @@ -306,6 +326,23 @@ func testAccAWSAppConfigConfigurationProfileLocationSSMDocument(appName, rName s resource "aws_appconfig_application" "app" { name = %[1]q } +resource "aws_iam_role" "test_role" { + name = "test_role" + + assume_role_policy = jsonencode({ + Version = "2012-10-17" + Statement = [ + { + Action = "sts:AssumeRole" + Effect = "Allow" + Sid = "" + Principal = { + Service = "ec2.amazonaws.com" + } + }, + ] + }) +} resource "aws_ssm_document" "ssm_doc" { name = "test_document" document_type = "Command" @@ -334,6 +371,7 @@ resource "aws_appconfig_configuration_profile" "test" { name = %[2]q application_id = aws_appconfig_application.app.id location_uri = aws_ssm_document.ssm_doc.arn + retrieval_role_arn = aws_iam_role.test_role.arn } `, appName, rName) } From 3a8913aa64cbb9a96bfef2946e663d69a3918a47 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Thu, 4 Mar 2021 14:50:19 -0500 Subject: [PATCH 08/25] Fixed functionality and improved test cases --- ...rce_aws_appconfig_configuration_profile.go | 69 ++++++-- ...ws_appconfig_configuration_profile_test.go | 166 ++++++++++-------- 2 files changed, 140 insertions(+), 95 deletions(-) diff --git a/aws/resource_aws_appconfig_configuration_profile.go b/aws/resource_aws_appconfig_configuration_profile.go index 5b8d6100f8c..f14f37cdeb7 100644 --- a/aws/resource_aws_appconfig_configuration_profile.go +++ b/aws/resource_aws_appconfig_configuration_profile.go @@ -3,10 +3,12 @@ package aws import ( "fmt" "log" + "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" @@ -50,18 +52,18 @@ func resourceAwsAppconfigConfigurationProfile() *schema.Resource { Optional: true, ValidateFunc: validateArn, }, - "validators": { + "validator": { Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "type": { - Type: schema.TypeInt, + Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{"JSON_SCHEMA", "LAMBDA"}, false), + ValidateFunc: validation.StringInSlice([]string{appconfig.ValidatorTypeJsonSchema, appconfig.ValidatorTypeLambda}, false), }, "content": { - Type: schema.TypeInt, + Type: schema.TypeString, Required: true, }, }, @@ -91,9 +93,8 @@ func resourceAwsAppconfigConfigurationProfileCreate(d *schema.ResourceData, meta retreivalRoleArn = nil } - log.Printf("[INFO] on create, validators %#v", d.Get("validators").(*schema.Set).List()) var validatorList []*appconfig.Validator - if validators := d.Get("validators").(*schema.Set).List(); len(validators) > 0 { + if validators := d.Get("validator").(*schema.Set).List(); len(validators) > 0 { validatorList = convertMapToValidators(validators) } @@ -107,10 +108,27 @@ func resourceAwsAppconfigConfigurationProfileCreate(d *schema.ResourceData, meta Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppconfigTags(), } - config, err := conn.CreateConfigurationProfile(input) + expectedErrMsg := fmt.Sprintf("Error trying to assume role %s", d.Get("retrieval_role_arn").(string)) + var config *appconfig.CreateConfigurationProfileOutput + var err error + err = resource.Retry(2*time.Minute, func() *resource.RetryError { + config, err = conn.CreateConfigurationProfile(input) + if err != nil { + if isAWSErr(err, "BadRequestException", expectedErrMsg) { + log.Printf("[DEBUG] Retrying AppConfig Configuration Profile creation: %s", err) + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + if isResourceTimeoutError(err) { + config, err = conn.CreateConfigurationProfile(input) + } if err != nil { - return fmt.Errorf("Error creating AppConfig configuration profile: %s", err) + return fmt.Errorf("Creating AppConfig Configuration Profile failed: %s", err) } + log.Printf("[DEBUG] AppConfig Configuration Profile created: %s", config) d.SetId(aws.StringValue(config.Id)) @@ -155,9 +173,7 @@ func resourceAwsAppconfigConfigurationProfileRead(d *schema.ResourceData, meta i d.Set("description", output.Description) d.Set("location_uri", output.LocationUri) d.Set("retrieval_role_arn", output.RetrievalRoleArn) - log.Printf("[INFO] on set, validators from output %#v", output.Validators) - log.Printf("[INFO] on set, validators map %#v", convertValidatorsToMap(output.Validators)) - d.Set("validators", convertValidatorsToMap(output.Validators)) + d.Set("validator", convertValidatorsToMap(output.Validators)) tags, err := keyvaluetags.AppconfigListTags(conn, appARN) if err != nil { @@ -190,7 +206,7 @@ func resourceAwsAppconfigConfigurationProfileUpdate(d *schema.ResourceData, meta retreivalRoleArn = nil } var validatorList []*appconfig.Validator - if validators := d.Get("validators").(*schema.Set).List(); len(validators) > 0 { + if validators := d.Get("validator").(*schema.Set).List(); len(validators) > 0 { validatorList = convertMapToValidators(validators) } @@ -213,9 +229,24 @@ func resourceAwsAppconfigConfigurationProfileUpdate(d *schema.ResourceData, meta updateInput.Name = aws.String(n.(string)) } - _, err := conn.UpdateConfigurationProfile(updateInput) + expectedErrMsg := fmt.Sprintf("Error trying to assume role %s", d.Get("retrieval_role_arn").(string)) + var err error + err = resource.Retry(2*time.Minute, func() *resource.RetryError { + _, err = conn.UpdateConfigurationProfile(updateInput) + if err != nil { + if isAWSErr(err, "BadRequestException", expectedErrMsg) { + log.Printf("[DEBUG] Retrying AppConfig Configuration Profile update: %s", err) + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + if isResourceTimeoutError(err) { + _, err = conn.UpdateConfigurationProfile(updateInput) + } if err != nil { - return fmt.Errorf("error updating AppConfig Configuration Profile (%s): %s", d.Id(), err) + return fmt.Errorf("Updating AppConfig Configuration Profile failed: %s", err) } return resourceAwsAppconfigConfigurationProfileRead(d, meta) @@ -245,10 +276,10 @@ func resourceAwsAppconfigConfigurationProfileDelete(d *schema.ResourceData, meta func convertMapToValidators(validatorMap []interface{}) []*appconfig.Validator { validatorList := make([]*appconfig.Validator, len(validatorMap)) for i, v := range validatorMap { - vMap := v.(map[string]string) + vMap := v.(map[string]interface{}) validator := appconfig.Validator{ - Content: aws.String(vMap["type"]), - Type: aws.String(vMap["content"]), + Type: aws.String(vMap["type"].(string)), + Content: aws.String(vMap["content"].(string)), } validatorList[i] = &validator } @@ -259,8 +290,8 @@ func convertValidatorsToMap(validatorList []*appconfig.Validator) []map[string]s validatorMap := make([]map[string]string, len(validatorList)) for i, v := range validatorList { validator := map[string]string{ - "content": aws.StringValue(v.Type), - "type": aws.StringValue(v.Content), + "type": aws.StringValue(v.Type), + "content": aws.StringValue(v.Content), } validatorMap[i] = validator } diff --git a/aws/resource_aws_appconfig_configuration_profile_test.go b/aws/resource_aws_appconfig_configuration_profile_test.go index 95f48706c83..76370b2f361 100644 --- a/aws/resource_aws_appconfig_configuration_profile_test.go +++ b/aws/resource_aws_appconfig_configuration_profile_test.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -func TestAccAwsAppConfigConfigurationProfile_basic(t *testing.T) { +func TestAccAWSAppConfigConfigurationProfile_basic(t *testing.T) { var profile appconfig.GetConfigurationProfileOutput appName := acctest.RandomWithPrefix("tf-acc-test") @@ -41,7 +41,7 @@ func TestAccAwsAppConfigConfigurationProfile_basic(t *testing.T) { }) } -func TestAccAwsAppConfigConfigurationProfile_disappears(t *testing.T) { +func TestAccAWSAppConfigConfigurationProfile_disappears(t *testing.T) { var profile appconfig.GetConfigurationProfileOutput appName := acctest.RandomWithPrefix("tf-acc-test") @@ -65,7 +65,7 @@ func TestAccAwsAppConfigConfigurationProfile_disappears(t *testing.T) { }, }) } -func TestAccAWSAppConfigConfigurationProfile_LocationURIs(t *testing.T) { +func TestAccAWSAppConfigConfigurationProfile_LocationURI_SSMParameter(t *testing.T) { var profile appconfig.GetConfigurationProfileOutput appName := acctest.RandomWithPrefix("tf-acc-test") rName := acctest.RandomWithPrefix("tf-acc-test") @@ -85,21 +85,10 @@ func TestAccAWSAppConfigConfigurationProfile_LocationURIs(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "retrieval_role_arn"), ), }, - { - Config: testAccAWSAppConfigConfigurationProfileLocationSSMDocument(appName, rName), - Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), - resource.TestCheckResourceAttr(resourceName, "name", rName), - testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), - resource.TestCheckResourceAttrSet(resourceName, "location_uri"), - resource.TestCheckResourceAttrSet(resourceName, "retrieval_role_arn"), - ), - }, }, }) } - -func TestAccAWSAppConfigConfigurationProfile_Validators(t *testing.T) { +func TestAccAWSAppConfigConfigurationProfile_LocationURI_SSMDocument(t *testing.T) { var profile appconfig.GetConfigurationProfileOutput appName := acctest.RandomWithPrefix("tf-acc-test") rName := acctest.RandomWithPrefix("tf-acc-test") @@ -110,23 +99,23 @@ func TestAccAWSAppConfigConfigurationProfile_Validators(t *testing.T) { CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSAppConfigConfigurationProfileValidator(appName, rName), + Config: testAccAWSAppConfigConfigurationProfileLocationSSMDocument(appName, rName), Check: resource.ComposeTestCheckFunc( testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "name", rName), testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttrSet(resourceName, "location_uri"), + resource.TestCheckResourceAttrSet(resourceName, "retrieval_role_arn"), ), }, }, }) } -func TestAccAWSAppConfigConfigurationProfile_RetrievalARN(t *testing.T) { +func TestAccAWSAppConfigConfigurationProfile_Validators(t *testing.T) { var profile appconfig.GetConfigurationProfileOutput appName := acctest.RandomWithPrefix("tf-acc-test") rName := acctest.RandomWithPrefix("tf-acc-test") - resourceName := "aws_appconfig_configuration_profile.test" resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -134,19 +123,18 @@ func TestAccAWSAppConfigConfigurationProfile_RetrievalARN(t *testing.T) { CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSAppConfigConfigurationProfileRetreivalARN(appName, rName), + Config: testAccAWSAppConfigConfigurationProfileValidator(appName, rName), Check: resource.ComposeTestCheckFunc( testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "name", rName), testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), - resource.TestCheckResourceAttrSet(resourceName, "retrieval_role_arn"), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), }, }, }) } - -func TestAccAwsAppConfigConfigurationProfile_Tags(t *testing.T) { +func TestAccAWSAppConfigConfigurationProfile_Tags(t *testing.T) { var profile appconfig.GetConfigurationProfileOutput appName := acctest.RandomWithPrefix("tf-acc-test") @@ -285,13 +273,14 @@ resource "aws_appconfig_configuration_profile" "test" { `, appName, rName, rDesc) } -func testAccAWSAppConfigConfigurationProfileLocationSSMParameter(appName, rName string) string { +func testAccAWSAppConfigConfigurationProfileIAMRole() string { + roleName := acctest.RandomWithPrefix("test-role") + attatchmentName := acctest.RandomWithPrefix("test-attatchment") + policyName := acctest.RandomWithPrefix("test-policy") + return fmt.Sprintf(` -resource "aws_appconfig_application" "app" { - name = %[1]q -} resource "aws_iam_role" "test_role" { - name = "test_role" + name = %[1]q assume_role_policy = jsonencode({ Version = "2012-10-17" @@ -301,24 +290,57 @@ resource "aws_iam_role" "test_role" { Effect = "Allow" Sid = "" Principal = { - Service = "ec2.amazonaws.com" + Service = "ssm.amazonaws.com" } }, ] - }) + }) + } + resource "aws_iam_policy_attachment" "test_attach" { + name = %[2]q + roles = [aws_iam_role.test_role.name] + policy_arn = aws_iam_policy.test_policy.arn + } + resource "aws_iam_policy" "test_policy" { + name = %[3]q + + policy = jsonencode({ + Version = "2012-10-17" + Statement = [ + { + Action = [ + "ssm:GetParameter*", + "ssm:DescribeParameters", + "ssm:PutParameter", + "ssm:GetDocument" + ] + Effect = "Allow" + Resource = "*" + }, + ] + }) + } +`, roleName, attatchmentName, policyName) +} + +func testAccAWSAppConfigConfigurationProfileLocationSSMParameter(appName, rName string) string { + return fmt.Sprintf(` +resource "aws_appconfig_application" "app" { + name = %[1]q } resource "aws_ssm_parameter" "ssm_param" { name = "foo" type = "String" value = "bar" - } +} resource "aws_appconfig_configuration_profile" "test" { name = %[2]q application_id = aws_appconfig_application.app.id location_uri = aws_ssm_parameter.ssm_param.arn retrieval_role_arn = aws_iam_role.test_role.arn } -`, appName, rName) +%[3]s +`, appName, rName, testAccAWSAppConfigConfigurationProfileIAMRole()) } func testAccAWSAppConfigConfigurationProfileLocationSSMDocument(appName, rName string) string { @@ -326,23 +348,6 @@ func testAccAWSAppConfigConfigurationProfileLocationSSMDocument(appName, rName s resource "aws_appconfig_application" "app" { name = %[1]q } -resource "aws_iam_role" "test_role" { - name = "test_role" - - assume_role_policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Action = "sts:AssumeRole" - Effect = "Allow" - Sid = "" - Principal = { - Service = "ec2.amazonaws.com" - } - }, - ] - }) -} resource "aws_ssm_document" "ssm_doc" { name = "test_document" document_type = "Command" @@ -373,7 +378,8 @@ resource "aws_appconfig_configuration_profile" "test" { location_uri = aws_ssm_document.ssm_doc.arn retrieval_role_arn = aws_iam_role.test_role.arn } -`, appName, rName) +%[3]s +`, appName, rName, testAccAWSAppConfigConfigurationProfileIAMRole()) } func testAccAWSAppConfigConfigurationProfileValidator(appName, rName string) string { @@ -381,29 +387,15 @@ func testAccAWSAppConfigConfigurationProfileValidator(appName, rName string) str resource "aws_appconfig_application" "app" { name = %[1]q } -resource "aws_appconfig_configuration_profile" "test" { - name = %[2]q - application_id = aws_appconfig_application.app.id - location_uri = "hosted" - validator { - type = "JSON_SCHEMA" - content = "JSON Schema content or AWS Lambda function name" - } - validator { - type = "LAMBDA" - content = "JSON Schema content or AWS Lambda function name" - } +resource "aws_lambda_function" "test_lambda" { + function_name = "lambda_function_name" + role = aws_iam_role.test_role_lambda.arn + filename = "test-fixtures/lambdatest.zip" + handler = "exports.test" + runtime = "nodejs12.x" } -`, appName, rName) -} - -func testAccAWSAppConfigConfigurationProfileRetreivalARN(appName, rName string) string { - return fmt.Sprintf(` -resource "aws_appconfig_application" "app" { - name = %[1]q -} -resource "aws_iam_role" "test_role" { - name = "test_role" +resource "aws_iam_role" "test_role_lambda" { + name = "test_role_lambda" assume_role_policy = jsonencode({ Version = "2012-10-17" @@ -413,20 +405,42 @@ resource "aws_iam_role" "test_role" { Effect = "Allow" Sid = "" Principal = { - Service = "ec2.amazonaws.com" + Service = "lambda.amazonaws.com" } }, ] - }) -} + }) + } resource "aws_appconfig_configuration_profile" "test" { name = %[2]q application_id = aws_appconfig_application.app.id location_uri = "hosted" - retrieval_role_arn = aws_iam_role.test_role.arn + validator { + type = "JSON_SCHEMA" + content = < Date: Fri, 5 Mar 2021 19:44:28 -0500 Subject: [PATCH 09/25] Added deployment stragegy resource and tests --- aws/provider.go | 1 + aws/resource_aws_appconfig_application.go | 2 +- ...resource_aws_appconfig_application_test.go | 16 +- ...ws_appconfig_configuration_profile_test.go | 22 +- ...ource_aws_appconfig_deployment_strategy.go | 226 +++++++++++ ..._aws_appconfig_deployment_strategy_test.go | 351 ++++++++++++++++++ 6 files changed, 598 insertions(+), 20 deletions(-) create mode 100644 aws/resource_aws_appconfig_deployment_strategy.go create mode 100644 aws/resource_aws_appconfig_deployment_strategy_test.go diff --git a/aws/provider.go b/aws/provider.go index c9be7da5db5..63e33b070a9 100644 --- a/aws/provider.go +++ b/aws/provider.go @@ -451,6 +451,7 @@ func Provider() *schema.Provider { "aws_appautoscaling_scheduled_action": resourceAwsAppautoscalingScheduledAction(), "aws_appconfig_application": resourceAwsAppconfigApplication(), "aws_appconfig_configuration_profile": resourceAwsAppconfigConfigurationProfile(), + "aws_appconfig_deployment_strategy": resourceAwsAppconfigDeploymentStrategy(), "aws_appmesh_gateway_route": resourceAwsAppmeshGatewayRoute(), "aws_appmesh_mesh": resourceAwsAppmeshMesh(), "aws_appmesh_route": resourceAwsAppmeshRoute(), diff --git a/aws/resource_aws_appconfig_application.go b/aws/resource_aws_appconfig_application.go index 5e273747f81..743b609df61 100644 --- a/aws/resource_aws_appconfig_application.go +++ b/aws/resource_aws_appconfig_application.go @@ -150,7 +150,7 @@ func resourceAwsAppconfigApplicationUpdate(d *schema.ResourceData, meta interfac _, err := conn.UpdateApplication(updateInput) if err != nil { - return fmt.Errorf("error updating AppConfig (%s): %s", d.Id(), err) + return fmt.Errorf("error updating AppConfig Application(%s): %s", d.Id(), err) } return resourceAwsAppconfigApplicationRead(d, meta) diff --git a/aws/resource_aws_appconfig_application_test.go b/aws/resource_aws_appconfig_application_test.go index 7dee88e1368..a405fdd57ee 100644 --- a/aws/resource_aws_appconfig_application_test.go +++ b/aws/resource_aws_appconfig_application_test.go @@ -24,7 +24,7 @@ func TestAccAWSAppConfigApplication_basic(t *testing.T) { { Config: testAccAWSAppConfigApplicationName(rName, rDesc), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigApplicationExists(resourceName, &application), + testAccCheckAWSAppConfigApplicationExists(resourceName, &application), resource.TestCheckResourceAttr(resourceName, "name", rName), testAccCheckAWSAppConfigApplicationARN(resourceName, &application), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -55,8 +55,8 @@ func TestAccAWSAppConfigApplication_disappears(t *testing.T) { { Config: testAccAWSAppConfigApplicationName(rName, rDesc), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigApplicationExists(resourceName, &application), - testAccCheckAwsAppConfigApplicationDisappears(&application), + testAccCheckAWSAppConfigApplicationExists(resourceName, &application), + testAccCheckAWSAppConfigApplicationDisappears(&application), ), ExpectNonEmptyPlan: true, }, @@ -78,7 +78,7 @@ func TestAccAWSAppConfigApplication_Tags(t *testing.T) { { Config: testAccAWSAppConfigApplicationTags1(rName, "key1", "value1"), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigApplicationExists(resourceName, &application), + testAccCheckAWSAppConfigApplicationExists(resourceName, &application), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), ), @@ -91,7 +91,7 @@ func TestAccAWSAppConfigApplication_Tags(t *testing.T) { { Config: testAccAWSAppConfigApplicationTags2(rName, "key1", "value1updated", "key2", "value2"), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigApplicationExists(resourceName, &application), + testAccCheckAWSAppConfigApplicationExists(resourceName, &application), resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"), resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), @@ -100,7 +100,7 @@ func TestAccAWSAppConfigApplication_Tags(t *testing.T) { { Config: testAccAWSAppConfigApplicationTags1(rName, "key2", "value2"), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigApplicationExists(resourceName, &application), + testAccCheckAWSAppConfigApplicationExists(resourceName, &application), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), ), @@ -140,7 +140,7 @@ func testAccCheckAppConfigApplicationDestroy(s *terraform.State) error { } -func testAccCheckAwsAppConfigApplicationDisappears(application *appconfig.GetApplicationOutput) resource.TestCheckFunc { +func testAccCheckAWSAppConfigApplicationDisappears(application *appconfig.GetApplicationOutput) resource.TestCheckFunc { return func(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).appconfigconn @@ -154,7 +154,7 @@ func testAccCheckAwsAppConfigApplicationDisappears(application *appconfig.GetApp } } -func testAccCheckAwsAppConfigApplicationExists(resourceName string, application *appconfig.GetApplicationOutput) resource.TestCheckFunc { +func testAccCheckAWSAppConfigApplicationExists(resourceName string, application *appconfig.GetApplicationOutput) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[resourceName] if !ok { diff --git a/aws/resource_aws_appconfig_configuration_profile_test.go b/aws/resource_aws_appconfig_configuration_profile_test.go index 76370b2f361..215aed840be 100644 --- a/aws/resource_aws_appconfig_configuration_profile_test.go +++ b/aws/resource_aws_appconfig_configuration_profile_test.go @@ -26,7 +26,7 @@ func TestAccAWSAppConfigConfigurationProfile_basic(t *testing.T) { { Config: testAccAWSAppConfigConfigurationProfileName(appName, rName, rDesc), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + testAccCheckAWSAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "name", rName), testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -57,8 +57,8 @@ func TestAccAWSAppConfigConfigurationProfile_disappears(t *testing.T) { { Config: testAccAWSAppConfigConfigurationProfileName(appName, rName, rDesc), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), - testAccCheckAwsAppConfigConfigurationProfileDisappears(&profile), + testAccCheckAWSAppConfigConfigurationProfileExists(resourceName, &profile), + testAccCheckAWSAppConfigConfigurationProfileDisappears(&profile), ), ExpectNonEmptyPlan: true, }, @@ -78,7 +78,7 @@ func TestAccAWSAppConfigConfigurationProfile_LocationURI_SSMParameter(t *testing { Config: testAccAWSAppConfigConfigurationProfileLocationSSMParameter(appName, rName), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + testAccCheckAWSAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "name", rName), testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), resource.TestCheckResourceAttrSet(resourceName, "location_uri"), @@ -101,7 +101,7 @@ func TestAccAWSAppConfigConfigurationProfile_LocationURI_SSMDocument(t *testing. { Config: testAccAWSAppConfigConfigurationProfileLocationSSMDocument(appName, rName), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + testAccCheckAWSAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "name", rName), testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), resource.TestCheckResourceAttrSet(resourceName, "location_uri"), @@ -125,7 +125,7 @@ func TestAccAWSAppConfigConfigurationProfile_Validators(t *testing.T) { { Config: testAccAWSAppConfigConfigurationProfileValidator(appName, rName), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + testAccCheckAWSAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "name", rName), testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -149,7 +149,7 @@ func TestAccAWSAppConfigConfigurationProfile_Tags(t *testing.T) { { Config: testAccAWSAppConfigConfigurationProfileTags1(appName, rName, "key1", "value1"), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + testAccCheckAWSAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), ), @@ -157,7 +157,7 @@ func TestAccAWSAppConfigConfigurationProfile_Tags(t *testing.T) { { Config: testAccAWSAppConfigConfigurationProfileTags2(appName, rName, "key1", "value1updated", "key2", "value2"), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + testAccCheckAWSAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"), resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), @@ -166,7 +166,7 @@ func TestAccAWSAppConfigConfigurationProfile_Tags(t *testing.T) { { Config: testAccAWSAppConfigConfigurationProfileTags1(appName, rName, "key2", "value2"), Check: resource.ComposeTestCheckFunc( - testAccCheckAwsAppConfigConfigurationProfileExists(resourceName, &profile), + testAccCheckAWSAppConfigConfigurationProfileExists(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), ), @@ -214,7 +214,7 @@ func testAccCheckAppConfigConfigurationProfileDestroy(s *terraform.State) error } -func testAccCheckAwsAppConfigConfigurationProfileDisappears(profile *appconfig.GetConfigurationProfileOutput) resource.TestCheckFunc { +func testAccCheckAWSAppConfigConfigurationProfileDisappears(profile *appconfig.GetConfigurationProfileOutput) resource.TestCheckFunc { return func(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).appconfigconn @@ -229,7 +229,7 @@ func testAccCheckAwsAppConfigConfigurationProfileDisappears(profile *appconfig.G } } -func testAccCheckAwsAppConfigConfigurationProfileExists(resourceName string, profile *appconfig.GetConfigurationProfileOutput) resource.TestCheckFunc { +func testAccCheckAWSAppConfigConfigurationProfileExists(resourceName string, profile *appconfig.GetConfigurationProfileOutput) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[resourceName] if !ok { diff --git a/aws/resource_aws_appconfig_deployment_strategy.go b/aws/resource_aws_appconfig_deployment_strategy.go new file mode 100644 index 00000000000..8d7138c5101 --- /dev/null +++ b/aws/resource_aws_appconfig_deployment_strategy.go @@ -0,0 +1,226 @@ +package aws + +import ( + "fmt" + "log" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/arn" + "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" +) + +func resourceAwsAppconfigDeploymentStrategy() *schema.Resource { + return &schema.Resource{ + Create: resourceAwsAppconfigDeploymentStrategyCreate, + Read: resourceAwsAppconfigDeploymentStrategyRead, + Update: resourceAwsAppconfigDeploymentStrategyUpdate, + Delete: resourceAwsAppconfigDeploymentStrategyDelete, + Importer: &schema.ResourceImporter{ + State: schema.ImportStatePassthrough, + }, + + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 64), + ), + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.All( + validation.StringLenBetween(0, 1024), + ), + }, + "deployment_duration_in_minutes": { + Type: schema.TypeInt, + Required: true, + ValidateFunc: validation.All( + validation.IntBetween(0, 1440), + ), + }, + "final_bake_time_in_minutes": { + Type: schema.TypeInt, + Optional: true, + ValidateFunc: validation.All( + validation.IntBetween(0, 1440), + ), + }, + "growth_factor": { + Type: schema.TypeFloat, + Optional: true, + Default: 1, + ValidateFunc: validation.All( + validation.FloatBetween(1.0, 100.0), + ), + }, + "growth_type": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringInSlice([]string{appconfig.GrowthTypeLinear, appconfig.GrowthTypeExponential}, false), + ), + }, + "replicate_to": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringInSlice([]string{appconfig.ReplicateToNone, appconfig.ReplicateToSsmDocument}, false), + ), + }, + "tags": tagsSchema(), + "id": { + Type: schema.TypeString, + Computed: true, + }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func resourceAwsAppconfigDeploymentStrategyCreate(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + + deploymentStrategyName := aws.String(d.Get("name").(string)) + deploymentStrategyDescription := aws.String(d.Get("description").(string)) + deployDuration := aws.Int64(int64(d.Get("deployment_duration_in_minutes").(int))) + bakeTime := aws.Int64(int64(d.Get("final_bake_time_in_minutes").(int))) + growthFactor := aws.Float64(d.Get("growth_factor").(float64)) + growthType := aws.String(d.Get("growth_type").(string)) + replicateTo := aws.String(d.Get("replicate_to").(string)) + + input := &appconfig.CreateDeploymentStrategyInput{ + Name: deploymentStrategyName, + Description: deploymentStrategyDescription, + DeploymentDurationInMinutes: deployDuration, + FinalBakeTimeInMinutes: bakeTime, + GrowthFactor: growthFactor, + GrowthType: growthType, + ReplicateTo: replicateTo, + Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppconfigTags(), + } + + deploymentStrategy, err := conn.CreateDeploymentStrategy(input) + if err != nil { + return fmt.Errorf("Error creating AppConfig DeploymentStrategy: %s", err) + } + + d.SetId(aws.StringValue(deploymentStrategy.Id)) + + return resourceAwsAppconfigDeploymentStrategyRead(d, meta) +} + +func resourceAwsAppconfigDeploymentStrategyRead(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig + + input := &appconfig.GetDeploymentStrategyInput{ + DeploymentStrategyId: aws.String(d.Id()), + } + + output, err := conn.GetDeploymentStrategy(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + log.Printf("[WARN] Appconfig DeploymentStrategy (%s) not found, removing from state", d.Id()) + d.SetId("") + return nil + } + + if err != nil { + return fmt.Errorf("error getting AppConfig DeploymentStrategy (%s): %s", d.Id(), err) + } + + if output == nil { + return fmt.Errorf("error getting AppConfig DeploymentStrategy (%s): empty response", d.Id()) + } + + appARN := arn.ARN{ + AccountID: meta.(*AWSClient).accountid, + Partition: meta.(*AWSClient).partition, + Region: meta.(*AWSClient).region, + Resource: fmt.Sprintf("deploymentstrategy/%s", aws.StringValue(output.Id)), + Service: "appconfig", + }.String() + + d.Set("arn", appARN) + d.Set("name", output.Name) + d.Set("description", output.Description) + + d.Set("deployment_duration_in_minutes", output.DeploymentDurationInMinutes) + d.Set("final_bake_time_in_minutes", output.FinalBakeTimeInMinutes) + d.Set("growth_factor", output.GrowthFactor) + d.Set("growth_type", output.GrowthType) + d.Set("replicate_to", output.ReplicateTo) + + tags, err := keyvaluetags.AppconfigListTags(conn, appARN) + if err != nil { + return fmt.Errorf("error getting tags for AppConfig DeploymentStrategy (%s): %s", d.Id(), err) + } + + if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %s", err) + } + + return nil +} + +func resourceAwsAppconfigDeploymentStrategyUpdate(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + + if d.HasChange("tags") { + o, n := d.GetChange("tags") + if err := keyvaluetags.AppconfigUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { + return fmt.Errorf("error updating AppConfig (%s) tags: %s", d.Id(), err) + } + } + + deploymentStrategyDescription := aws.String(d.Get("description").(string)) + deployDuration := aws.Int64(int64(d.Get("deployment_duration_in_minutes").(int))) + bakeTime := aws.Int64(int64(d.Get("final_bake_time_in_minutes").(int))) + growthFactor := aws.Float64(d.Get("growth_factor").(float64)) + growthType := aws.String(d.Get("growth_type").(string)) + + updateInput := &appconfig.UpdateDeploymentStrategyInput{ + DeploymentStrategyId: aws.String(d.Id()), + Description: deploymentStrategyDescription, + DeploymentDurationInMinutes: deployDuration, + FinalBakeTimeInMinutes: bakeTime, + GrowthFactor: growthFactor, + GrowthType: growthType, + } + + _, err := conn.UpdateDeploymentStrategy(updateInput) + if err != nil { + return fmt.Errorf("error updating AppConfig DeploymentStrategy(%s): %s", d.Id(), err) + } + + return resourceAwsAppconfigDeploymentStrategyRead(d, meta) +} + +func resourceAwsAppconfigDeploymentStrategyDelete(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + + input := &appconfig.DeleteDeploymentStrategyInput{ + DeploymentStrategyId: aws.String(d.Id()), + } + + _, err := conn.DeleteDeploymentStrategy(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + return nil + } + + if err != nil { + return fmt.Errorf("error deleting Appconfig DeploymentStrategy (%s): %s", d.Id(), err) + } + + return nil +} diff --git a/aws/resource_aws_appconfig_deployment_strategy_test.go b/aws/resource_aws_appconfig_deployment_strategy_test.go new file mode 100644 index 00000000000..e24b0ad63b1 --- /dev/null +++ b/aws/resource_aws_appconfig_deployment_strategy_test.go @@ -0,0 +1,351 @@ +package aws + +import ( + "fmt" + "testing" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/appconfig" + "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" +) + +func TestAccAWSAppConfigDeploymentStrategy_basic(t *testing.T) { + var deploymentStrategy appconfig.GetDeploymentStrategyOutput + rName := acctest.RandomWithPrefix("tf-acc-test") + rDesc := acctest.RandomWithPrefix("desc") + resourceName := "aws_appconfig_deployment_strategy.test" + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigDeploymentStrategyDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigDeploymentStrategyName(rName, rDesc), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentStrategyExists(resourceName, &deploymentStrategy), + resource.TestCheckResourceAttr(resourceName, "name", rName), + testAccCheckAWSAppConfigDeploymentStrategyARN(resourceName, &deploymentStrategy), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "description", rDesc), + resource.TestCheckResourceAttr(resourceName, "growth_factor", "1"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccAWSAppConfigDeploymentStrategy_disappears(t *testing.T) { + var deploymentStrategy appconfig.GetDeploymentStrategyOutput + + rName := acctest.RandomWithPrefix("tf-acc-test") + rDesc := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_deployment_strategy.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigDeploymentStrategyDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigDeploymentStrategyName(rName, rDesc), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentStrategyExists(resourceName, &deploymentStrategy), + testAccCheckAWSAppConfigDeploymentStrategyDisappears(&deploymentStrategy), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + +func TestAccAWSAppConfigDeploymentStrategy_Tags(t *testing.T) { + var deploymentStrategy appconfig.GetDeploymentStrategyOutput + + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_deployment_strategy.test" + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigDeploymentStrategyDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigDeploymentStrategyTags1(rName, "key1", "value1"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentStrategyExists(resourceName, &deploymentStrategy), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccAWSAppConfigDeploymentStrategyTags2(rName, "key1", "value1updated", "key2", "value2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentStrategyExists(resourceName, &deploymentStrategy), + resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"), + resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), + ), + }, + { + Config: testAccAWSAppConfigDeploymentStrategyTags1(rName, "key2", "value2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentStrategyExists(resourceName, &deploymentStrategy), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), + ), + }, + }, + }) +} + +func TestAccAWSAppConfigDeploymentStrategy_Growth(t *testing.T) { + var deploymentStrategy appconfig.GetDeploymentStrategyOutput + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_deployment_strategy.test" + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigDeploymentStrategyDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigDeploymentStrategyGrowth(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentStrategyExists(resourceName, &deploymentStrategy), + resource.TestCheckResourceAttr(resourceName, "name", rName), + testAccCheckAWSAppConfigDeploymentStrategyARN(resourceName, &deploymentStrategy), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "growth_factor", "24.5"), + resource.TestCheckResourceAttr(resourceName, "growth_type", "EXPONENTIAL"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} +func TestAccAWSAppConfigDeploymentStrategy_ReplicateTo(t *testing.T) { + var deploymentStrategy appconfig.GetDeploymentStrategyOutput + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_deployment_strategy.test" + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigDeploymentStrategyDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigDeploymentStrategyReplicateTo(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentStrategyExists(resourceName, &deploymentStrategy), + resource.TestCheckResourceAttr(resourceName, "name", rName), + testAccCheckAWSAppConfigDeploymentStrategyARN(resourceName, &deploymentStrategy), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "replicate_to", "SSM_DOCUMENT"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} +func TestAccAWSAppConfigDeploymentStrategy_BakeTime(t *testing.T) { + var deploymentStrategy appconfig.GetDeploymentStrategyOutput + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_deployment_strategy.test" + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigDeploymentStrategyDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigDeploymentStrategyBakeTime(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentStrategyExists(resourceName, &deploymentStrategy), + resource.TestCheckResourceAttr(resourceName, "name", rName), + testAccCheckAWSAppConfigDeploymentStrategyARN(resourceName, &deploymentStrategy), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "final_bake_time_in_minutes", "45"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func testAccCheckAppConfigDeploymentStrategyDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + for _, rs := range s.RootModule().Resources { + if rs.Type != "aws_appconfig_deployment_strategy" { + continue + } + + input := &appconfig.GetDeploymentStrategyInput{ + DeploymentStrategyId: aws.String(rs.Primary.ID), + } + + output, err := conn.GetDeploymentStrategy(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + continue + } + + if err != nil { + return err + } + + if output != nil { + return fmt.Errorf("AppConfig DeploymentStrategy (%s) still exists", rs.Primary.ID) + } + } + + return nil + +} + +func testAccCheckAWSAppConfigDeploymentStrategyDisappears(deploymentStrategy *appconfig.GetDeploymentStrategyOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + input := &appconfig.DeleteDeploymentStrategyInput{ + DeploymentStrategyId: aws.String(*deploymentStrategy.Id), + } + + _, err := conn.DeleteDeploymentStrategy(input) + + return err + } +} + +func testAccCheckAWSAppConfigDeploymentStrategyExists(resourceName string, deploymentStrategy *appconfig.GetDeploymentStrategyOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Resource not found: %s", resourceName) + } + + if rs.Primary.ID == "" { + return fmt.Errorf("Resource (%s) ID not set", resourceName) + } + + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + input := &appconfig.GetDeploymentStrategyInput{ + DeploymentStrategyId: aws.String(rs.Primary.ID), + } + + output, err := conn.GetDeploymentStrategy(input) + if err != nil { + return err + } + + *deploymentStrategy = *output + + return nil + } +} + +func testAccCheckAWSAppConfigDeploymentStrategyARN(resourceName string, deploymentStrategy *appconfig.GetDeploymentStrategyOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + return testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appconfig", fmt.Sprintf("deploymentstrategy/%s", aws.StringValue(deploymentStrategy.Id)))(s) + } +} + +func testAccAWSAppConfigDeploymentStrategyName(rName, rDesc string) string { + return fmt.Sprintf(` +resource "aws_appconfig_deployment_strategy" "test" { + name = %[1]q + description = %[2]q + deployment_duration_in_minutes = 10 + growth_type = "LINEAR" + replicate_to = "NONE" +} +`, rName, rDesc) +} + +func testAccAWSAppConfigDeploymentStrategyGrowth(rName string) string { + return fmt.Sprintf(` +resource "aws_appconfig_deployment_strategy" "test" { + name = %[1]q + deployment_duration_in_minutes = 10 + growth_factor = 24.5 + growth_type = "EXPONENTIAL" + replicate_to = "NONE" +} +`, rName) +} + +func testAccAWSAppConfigDeploymentStrategyReplicateTo(rName string) string { + return fmt.Sprintf(` +resource "aws_appconfig_deployment_strategy" "test" { + name = %[1]q + deployment_duration_in_minutes = 10 + growth_type = "LINEAR" + replicate_to = "SSM_DOCUMENT" +} +`, rName) +} + +func testAccAWSAppConfigDeploymentStrategyBakeTime(rName string) string { + return fmt.Sprintf(` +resource "aws_appconfig_deployment_strategy" "test" { + name = %[1]q + deployment_duration_in_minutes = 10 + final_bake_time_in_minutes = 45 + growth_type = "LINEAR" + replicate_to = "NONE" +} +`, rName) +} + +func testAccAWSAppConfigDeploymentStrategyTags1(rName, tagKey1, tagValue1 string) string { + return fmt.Sprintf(` +resource "aws_appconfig_deployment_strategy" "test" { + name = %[1]q + deployment_duration_in_minutes = 10 + growth_type = "LINEAR" + replicate_to = "NONE" + + tags = { + %[2]q = %[3]q + } +} +`, rName, tagKey1, tagValue1) +} + +func testAccAWSAppConfigDeploymentStrategyTags2(rName, tagKey1, tagValue1, tagKey2, tagValue2 string) string { + return fmt.Sprintf(` +resource "aws_appconfig_deployment_strategy" "test" { + name = %[1]q + deployment_duration_in_minutes = 10 + growth_type = "LINEAR" + replicate_to = "NONE" + + tags = { + %[2]q = %[3]q + %[4]q = %[5]q + } +} +`, rName, tagKey1, tagValue1, tagKey2, tagValue2) +} From 027f6aae6b3d5e35027bb75b9fe5c0d00de60ec9 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Mon, 8 Mar 2021 15:17:43 -0500 Subject: [PATCH 10/25] Added validator count check to tests --- aws/resource_aws_appconfig_configuration_profile_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aws/resource_aws_appconfig_configuration_profile_test.go b/aws/resource_aws_appconfig_configuration_profile_test.go index 215aed840be..0399a43cfc3 100644 --- a/aws/resource_aws_appconfig_configuration_profile_test.go +++ b/aws/resource_aws_appconfig_configuration_profile_test.go @@ -33,7 +33,7 @@ func TestAccAWSAppConfigConfigurationProfile_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "description", rDesc), resource.TestCheckResourceAttr(resourceName, "location_uri", "hosted"), resource.TestCheckResourceAttr(resourceName, "retrieval_role_arn", ""), - resource.TestCheckResourceAttr(resourceName, "validator.%", "0"), + resource.TestCheckResourceAttr(resourceName, "validator.#", "0"), resource.TestCheckResourceAttrSet(resourceName, "application_id"), ), }, @@ -129,6 +129,7 @@ func TestAccAWSAppConfigConfigurationProfile_Validators(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "name", rName), testAccCheckAWSAppConfigConfigurationProfileARN(resourceName, &profile), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "validator.#", "2"), ), }, }, From 2b76f5c1d85c51113e9128a778de72f23ff67e09 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Mon, 8 Mar 2021 15:18:00 -0500 Subject: [PATCH 11/25] Added appconfig environment and tests --- aws/provider.go | 1 + aws/resource_aws_appconfig_environment.go | 240 ++++++++++++++ ...resource_aws_appconfig_environment_test.go | 294 ++++++++++++++++++ 3 files changed, 535 insertions(+) create mode 100644 aws/resource_aws_appconfig_environment.go create mode 100644 aws/resource_aws_appconfig_environment_test.go diff --git a/aws/provider.go b/aws/provider.go index 63e33b070a9..d53cba079ab 100644 --- a/aws/provider.go +++ b/aws/provider.go @@ -452,6 +452,7 @@ func Provider() *schema.Provider { "aws_appconfig_application": resourceAwsAppconfigApplication(), "aws_appconfig_configuration_profile": resourceAwsAppconfigConfigurationProfile(), "aws_appconfig_deployment_strategy": resourceAwsAppconfigDeploymentStrategy(), + "aws_appconfig_environment": resourceAwsAppconfigEnvironment(), "aws_appmesh_gateway_route": resourceAwsAppmeshGatewayRoute(), "aws_appmesh_mesh": resourceAwsAppmeshMesh(), "aws_appmesh_route": resourceAwsAppmeshRoute(), diff --git a/aws/resource_aws_appconfig_environment.go b/aws/resource_aws_appconfig_environment.go new file mode 100644 index 00000000000..e424e45fce1 --- /dev/null +++ b/aws/resource_aws_appconfig_environment.go @@ -0,0 +1,240 @@ +package aws + +import ( + "fmt" + "log" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/arn" + "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" +) + +func resourceAwsAppconfigEnvironment() *schema.Resource { + return &schema.Resource{ + Create: resourceAwsAppconfigEnvironmentCreate, + Read: resourceAwsAppconfigEnvironmentRead, + Update: resourceAwsAppconfigEnvironmentUpdate, + Delete: resourceAwsAppconfigEnvironmentDelete, + + Schema: map[string]*schema.Schema{ + "application_id": { + Type: schema.TypeString, + Required: true, + }, + "name": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 64), + ), + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.All( + validation.StringLenBetween(0, 1024), + ), + }, + "monitor": { + Type: schema.TypeSet, + Optional: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "alarm_arn": { + Type: schema.TypeString, + Required: true, + }, + "alarm_role_arn": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + "tags": tagsSchema(), + "id": { + Type: schema.TypeString, + Computed: true, + }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func resourceAwsAppconfigEnvironmentCreate(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + applicationID := aws.String(d.Get("application_id").(string)) + environmentName := aws.String(d.Get("name").(string)) + environmentDescription := aws.String(d.Get("description").(string)) + + var monitorList []*appconfig.Monitor + if monitors := d.Get("monitor").(*schema.Set).List(); len(monitors) > 0 { + monitorList = convertMapToMonitors(monitors) + } + + input := &appconfig.CreateEnvironmentInput{ + ApplicationId: applicationID, + Name: environmentName, + Description: environmentDescription, + Monitors: monitorList, + Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppconfigTags(), + } + + env, err := conn.CreateEnvironment(input) + if err != nil { + return fmt.Errorf("Creating AppConfig Environment failed: %s", err) + } + log.Printf("[DEBUG] AppConfig Environment created: %s", env) + + d.SetId(aws.StringValue(env.Id)) + + return resourceAwsAppconfigEnvironmentRead(d, meta) +} + +func resourceAwsAppconfigEnvironmentRead(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig + + input := &appconfig.GetEnvironmentInput{ + ApplicationId: aws.String(d.Get("application_id").(string)), + EnvironmentId: aws.String(d.Id()), + } + + output, err := conn.GetEnvironment(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + log.Printf("[WARN] Appconfig Environment (%s) not found, removing from state", d.Id()) + d.SetId("") + return nil + } + + if err != nil { + return fmt.Errorf("error getting AppConfig Environment (%s): %s", d.Id(), err) + } + + if output == nil { + return fmt.Errorf("error getting AppConfig Environment (%s): empty response", d.Id()) + } + + appARN := arn.ARN{ + AccountID: meta.(*AWSClient).accountid, + Partition: meta.(*AWSClient).partition, + Region: meta.(*AWSClient).region, + Resource: fmt.Sprintf("application/%s/environment/%s", aws.StringValue(output.ApplicationId), aws.StringValue(output.Id)), + Service: "appconfig", + }.String() + + d.Set("arn", appARN) + d.Set("name", output.Name) + d.Set("description", output.Description) + d.Set("monitor", convertMonitorsToMap(output.Monitors)) + + tags, err := keyvaluetags.AppconfigListTags(conn, appARN) + if err != nil { + return fmt.Errorf("error getting tags for AppConfig Environment (%s): %s", d.Id(), err) + } + + if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %s", err) + } + + return nil +} + +func resourceAwsAppconfigEnvironmentUpdate(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + + if d.HasChange("tags") { + o, n := d.GetChange("tags") + if err := keyvaluetags.AppconfigUpdateTags(conn, d.Get("arn").(string), o, n); err != nil { + return fmt.Errorf("error updating AppConfig (%s) tags: %s", d.Id(), err) + } + } + + applicationID := aws.String(d.Get("application_id").(string)) + environmentID := aws.String(d.Id()) + environmentName := aws.String(d.Get("name").(string)) + environmentDescription := aws.String(d.Get("description").(string)) + + var monitorList []*appconfig.Monitor + if monitors := d.Get("monitor").(*schema.Set).List(); len(monitors) > 0 { + monitorList = convertMapToMonitors(monitors) + } + + updateInput := &appconfig.UpdateEnvironmentInput{ + ApplicationId: applicationID, + EnvironmentId: environmentID, + Description: environmentDescription, + Name: environmentName, + Monitors: monitorList, + } + + if d.HasChange("description") { + _, n := d.GetChange("description") + updateInput.Description = aws.String(n.(string)) + } + + if d.HasChange("name") { + _, n := d.GetChange("name") + updateInput.Name = aws.String(n.(string)) + } + + _, err := conn.UpdateEnvironment(updateInput) + if err != nil { + return fmt.Errorf("Updating AppConfig Environment failed: %s", err) + } + + return resourceAwsAppconfigEnvironmentRead(d, meta) +} + +func resourceAwsAppconfigEnvironmentDelete(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + + input := &appconfig.DeleteEnvironmentInput{ + ApplicationId: aws.String(d.Get("application_id").(string)), + EnvironmentId: aws.String(d.Id()), + } + + _, err := conn.DeleteEnvironment(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + return nil + } + + if err != nil { + return fmt.Errorf("error deleting Appconfig Environment (%s): %s", d.Id(), err) + } + + return nil +} + +func convertMapToMonitors(monitorMap []interface{}) []*appconfig.Monitor { + monitorList := make([]*appconfig.Monitor, len(monitorMap)) + for i, v := range monitorMap { + vMap := v.(map[string]interface{}) + monitor := appconfig.Monitor{ + AlarmArn: aws.String(vMap["alarm_arn"].(string)), + AlarmRoleArn: aws.String(vMap["alarm_role_arn"].(string)), + } + monitorList[i] = &monitor + } + return monitorList +} + +func convertMonitorsToMap(monitorList []*appconfig.Monitor) []map[string]string { + monitorMap := make([]map[string]string, len(monitorList)) + for i, v := range monitorList { + monitor := map[string]string{ + "alarm_arn": aws.StringValue(v.AlarmArn), + "alarm_role_arn": aws.StringValue(v.AlarmRoleArn), + } + monitorMap[i] = monitor + } + return monitorMap +} diff --git a/aws/resource_aws_appconfig_environment_test.go b/aws/resource_aws_appconfig_environment_test.go new file mode 100644 index 00000000000..0c3e09375b9 --- /dev/null +++ b/aws/resource_aws_appconfig_environment_test.go @@ -0,0 +1,294 @@ +package aws + +import ( + "fmt" + "testing" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/appconfig" + "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" +) + +func TestAccAWSAppConfigEnvironment_basic(t *testing.T) { + var environment appconfig.GetEnvironmentOutput + rName := acctest.RandomWithPrefix("tf-acc-test") + rDesc := acctest.RandomWithPrefix("desc") + resourceName := "aws_appconfig_environment.test" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigEnvironmentDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigEnvironmentName(rName, rDesc), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigEnvironmentExists(resourceName, &environment), + resource.TestCheckResourceAttr(resourceName, "name", rName), + testAccCheckAWSAppConfigEnvironmentARN(resourceName, &environment), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "monitor.#", "0"), + resource.TestCheckResourceAttr(resourceName, "description", rDesc), + ), + }, + }, + }) +} + +func TestAccAWSAppConfigEnvironment_disappears(t *testing.T) { + var environment appconfig.GetEnvironmentOutput + + rName := acctest.RandomWithPrefix("tf-acc-test") + rDesc := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_environment.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigEnvironmentDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigEnvironmentName(rName, rDesc), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigEnvironmentExists(resourceName, &environment), + testAccCheckAWSAppConfigEnvironmentDisappears(&environment), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + +func TestAccAWSAppConfigEnvironment_Monitors(t *testing.T) { + var environment appconfig.GetEnvironmentOutput + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_environment.test" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigEnvironmentDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigEnvironmentMonitors(rName), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigEnvironmentExists(resourceName, &environment), + resource.TestCheckResourceAttr(resourceName, "name", rName), + testAccCheckAWSAppConfigEnvironmentARN(resourceName, &environment), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "monitor.#", "1"), + ), + }, + }, + }) +} + +func TestAccAWSAppConfigEnvironment_Tags(t *testing.T) { + var environment appconfig.GetEnvironmentOutput + + rName := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_environment.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigEnvironmentDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigEnvironmentTags1(rName, "key1", "value1"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigEnvironmentExists(resourceName, &environment), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), + ), + }, + { + Config: testAccAWSAppConfigEnvironmentTags2(rName, "key1", "value1updated", "key2", "value2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigEnvironmentExists(resourceName, &environment), + resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"), + resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), + ), + }, + }, + }) +} + +func testAccCheckAppConfigEnvironmentDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + for _, rs := range s.RootModule().Resources { + if rs.Type != "aws_appconfig_environment" { + continue + } + + input := &appconfig.GetEnvironmentInput{ + ApplicationId: aws.String(rs.Primary.Attributes["application_id"]), + EnvironmentId: aws.String(rs.Primary.ID), + } + + output, err := conn.GetEnvironment(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + continue + } + + if err != nil { + return err + } + + if output != nil { + return fmt.Errorf("AppConfig Environment (%s) still exists", rs.Primary.ID) + } + } + + return nil + +} + +func testAccCheckAWSAppConfigEnvironmentDisappears(environment *appconfig.GetEnvironmentOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + input := &appconfig.DeleteEnvironmentInput{ + ApplicationId: aws.String(*environment.ApplicationId), + EnvironmentId: aws.String(*environment.Id), + } + + _, err := conn.DeleteEnvironment(input) + + return err + } +} + +func testAccCheckAWSAppConfigEnvironmentExists(resourceName string, environment *appconfig.GetEnvironmentOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Resource not found: %s", resourceName) + } + + if rs.Primary.ID == "" { + return fmt.Errorf("Resource (%s) ID not set", resourceName) + } + + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + input := &appconfig.GetEnvironmentInput{ + ApplicationId: aws.String(rs.Primary.Attributes["application_id"]), + EnvironmentId: aws.String(rs.Primary.ID), + } + + output, err := conn.GetEnvironment(input) + if err != nil { + return err + } + + *environment = *output + + return nil + } +} + +func testAccCheckAWSAppConfigEnvironmentARN(resourceName string, environment *appconfig.GetEnvironmentOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + arnResource := fmt.Sprintf("application/%s/environment/%s", aws.StringValue(environment.ApplicationId), aws.StringValue(environment.Id)) + return testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appconfig", arnResource)(s) + } +} + +func testAccAWSAppConfigEnvironmentName(rName, rDesc string) string { + appName := fmt.Sprintf("%s-app", rName) + return fmt.Sprintf(` +resource "aws_appconfig_application" "app" { + name = %[1]q +} +resource "aws_appconfig_environment" "test" { + name = %[2]q + application_id = aws_appconfig_application.app.id + description = %[3]q +} +`, appName, rName, rDesc) +} + +func testAccAWSAppConfigEnvironmentMonitors(rName string) string { + alarmName := acctest.RandomWithPrefix("test-alarm") + roleName := acctest.RandomWithPrefix("test-role") + appName := fmt.Sprintf("%s-app", rName) + return fmt.Sprintf(` +resource "aws_appconfig_application" "app" { + name = %[1]q +} +resource "aws_appconfig_environment" "test" { + name = %[2]q + application_id = aws_appconfig_application.app.id + monitor { + alarm_arn = aws_cloudwatch_metric_alarm.test_alarm.arn + alarm_role_arn = aws_iam_role.test_role.arn + } +} +resource "aws_cloudwatch_metric_alarm" "test_alarm" { + alarm_name = %[3]q + comparison_operator = "GreaterThanOrEqualToThreshold" + evaluation_periods = "2" + metric_name = "CPUUtilization" + namespace = "AWS/EC2" + period = "120" + statistic = "Average" + threshold = "80" + alarm_description = "This metric monitors ec2 cpu utilization" + insufficient_data_actions = [] + } +resource "aws_iam_role" "test_role" { + name = %[4]q + + assume_role_policy = jsonencode({ + Version = "2012-10-17" + Statement = [ + { + Action = "sts:AssumeRole" + Effect = "Allow" + Sid = "" + Principal = { + Service = "ssm.amazonaws.com" + } + }, + ] + }) + } +`, appName, rName, alarmName, roleName) +} + +func testAccAWSAppConfigEnvironmentTags1(rName, tagKey1, tagValue1 string) string { + appName := fmt.Sprintf("%s-app", rName) + return fmt.Sprintf(` +resource "aws_appconfig_application" "app" { + name = %[1]q +} +resource "aws_appconfig_environment" "test" { + name = %[2]q + application_id = aws_appconfig_application.app.id + tags = { + %[3]q = %[4]q + } +} +`, appName, rName, tagKey1, tagValue1) +} + +func testAccAWSAppConfigEnvironmentTags2(rName, tagKey1, tagValue1, tagKey2, tagValue2 string) string { + appName := fmt.Sprintf("%s-app", rName) + return fmt.Sprintf(` +resource "aws_appconfig_application" "app" { + name = %[1]q +} +resource "aws_appconfig_environment" "test" { + name = %[2]q + application_id = aws_appconfig_application.app.id + tags = { + %[3]q = %[4]q + %[5]q = %[6]q + } +} +`, appName, rName, tagKey1, tagValue1, tagKey2, tagValue2) +} From 501adda4544b3c06afcdb930ceac1f1bbabf70cd Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Mon, 8 Mar 2021 17:26:43 -0500 Subject: [PATCH 12/25] Added deployment and tests --- aws/provider.go | 1 + aws/resource_aws_appconfig_deployment.go | 184 ++++++++++++ aws/resource_aws_appconfig_deployment_test.go | 263 ++++++++++++++++++ 3 files changed, 448 insertions(+) create mode 100644 aws/resource_aws_appconfig_deployment.go create mode 100644 aws/resource_aws_appconfig_deployment_test.go diff --git a/aws/provider.go b/aws/provider.go index d53cba079ab..033a3e1a0d8 100644 --- a/aws/provider.go +++ b/aws/provider.go @@ -451,6 +451,7 @@ func Provider() *schema.Provider { "aws_appautoscaling_scheduled_action": resourceAwsAppautoscalingScheduledAction(), "aws_appconfig_application": resourceAwsAppconfigApplication(), "aws_appconfig_configuration_profile": resourceAwsAppconfigConfigurationProfile(), + "aws_appconfig_deployment": resourceAwsAppconfigDeployment(), "aws_appconfig_deployment_strategy": resourceAwsAppconfigDeploymentStrategy(), "aws_appconfig_environment": resourceAwsAppconfigEnvironment(), "aws_appmesh_gateway_route": resourceAwsAppmeshGatewayRoute(), diff --git a/aws/resource_aws_appconfig_deployment.go b/aws/resource_aws_appconfig_deployment.go new file mode 100644 index 00000000000..cacb1eb965b --- /dev/null +++ b/aws/resource_aws_appconfig_deployment.go @@ -0,0 +1,184 @@ +package aws + +import ( + "fmt" + "log" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/arn" + "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" +) + +func resourceAwsAppconfigDeployment() *schema.Resource { + return &schema.Resource{ + Create: resourceAwsAppconfigDeploymentCreate, + Read: resourceAwsAppconfigDeploymentRead, + Update: resourceAwsAppconfigDeploymentUpdate, + Delete: resourceAwsAppconfigDeploymentDelete, + + Schema: map[string]*schema.Schema{ + "application_id": { + Type: schema.TypeString, + Required: true, + }, + "environment_id": { + Type: schema.TypeString, + Required: true, + }, + "deployment_strategy_id": { + Type: schema.TypeString, + Required: true, + }, + "configuration_profile_id": { + Type: schema.TypeString, + Required: true, + }, + "configuration_version": { + Type: schema.TypeString, + Required: true, + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.All( + validation.StringLenBetween(0, 1024), + ), + }, + "tags": tagsSchema(), + "id": { + Type: schema.TypeString, + Computed: true, + }, + "deployment_number": { + Type: schema.TypeInt, + Computed: true, + }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, + }, + } +} + +func resourceAwsAppconfigDeploymentCreate(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + applicationID := aws.String(d.Get("application_id").(string)) + environmentID := aws.String(d.Get("environment_id").(string)) + deploymentStrategyID := aws.String(d.Get("deployment_strategy_id").(string)) + configProfileID := aws.String(d.Get("configuration_profile_id").(string)) + deploymentDescription := aws.String(d.Get("description").(string)) + configVersion := aws.String(d.Get("configuration_version").(string)) + + input := &appconfig.StartDeploymentInput{ + ApplicationId: applicationID, + EnvironmentId: environmentID, + DeploymentStrategyId: deploymentStrategyID, + ConfigurationProfileId: configProfileID, + ConfigurationVersion: configVersion, + Description: deploymentDescription, + Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppconfigTags(), + } + + deploy, err := conn.StartDeployment(input) + if err != nil { + return fmt.Errorf("Creating AppConfig Deployment failed: %s", err) + } + log.Printf("[DEBUG] AppConfig Deployment created: %s", deploy) + + d.SetId(fmt.Sprintf("%s-%s-%d", aws.StringValue(applicationID), aws.StringValue(environmentID), aws.Int64Value(deploy.DeploymentNumber))) + + return resourceAwsAppconfigDeploymentRead(d, meta) +} + +func resourceAwsAppconfigDeploymentRead(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + ignoreTagsConfig := meta.(*AWSClient).IgnoreTagsConfig + + applicationID := aws.String(d.Get("application_id").(string)) + environmentID := aws.String(d.Get("environment_id").(string)) + + input := &appconfig.GetDeploymentInput{ + ApplicationId: applicationID, + EnvironmentId: environmentID, + DeploymentNumber: aws.Int64(d.Get("deployment_number").(int64)), + } + + output, err := conn.GetDeployment(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + log.Printf("[WARN] Appconfig Deployment (%s) not found, removing from state", d.Id()) + d.SetId("") + return nil + } + + if err != nil { + return fmt.Errorf("error getting AppConfig Deployment (%s): %s", d.Id(), err) + } + + if output == nil { + return fmt.Errorf("error getting AppConfig Deployment (%s): empty response", d.Id()) + } + + appID := aws.StringValue(output.ApplicationId) + envID := aws.StringValue(output.EnvironmentId) + deployNum := fmt.Sprintf("%d", aws.Int64Value(output.DeploymentNumber)) + arnResource := fmt.Sprintf("application/%s/environment/%s/deployment/%s", appID, envID, deployNum) + appARN := arn.ARN{ + AccountID: meta.(*AWSClient).accountid, + Partition: meta.(*AWSClient).partition, + Region: meta.(*AWSClient).region, + Resource: arnResource, + Service: "appconfig", + }.String() + + d.Set("arn", appARN) + d.Set("description", output.Description) + + tags, err := keyvaluetags.AppconfigListTags(conn, appARN) + if err != nil { + return fmt.Errorf("error getting tags for AppConfig Deployment (%s): %s", d.Id(), err) + } + + if err := d.Set("tags", tags.IgnoreAws().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { + return fmt.Errorf("error setting tags: %s", err) + } + + return nil +} + +func resourceAwsAppconfigDeploymentUpdate(d *schema.ResourceData, meta interface{}) error { + if err := resourceAwsAppconfigDeploymentDelete(d, meta); err != nil { + return fmt.Errorf("error rolling back existing deployment during update: %s", err) + } + + if err := resourceAwsAppconfigDeploymentCreate(d, meta); err != nil { + return fmt.Errorf("error starting new deployment during update: %s", err) + } + + return resourceAwsAppconfigDeploymentRead(d, meta) +} + +func resourceAwsAppconfigDeploymentDelete(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + + input := &appconfig.StopDeploymentInput{ + ApplicationId: aws.String(d.Get("application_id").(string)), + DeploymentNumber: aws.Int64(d.Get("deployment_number").(int64)), + } + + _, err := conn.StopDeployment(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + return nil + } + + if err != nil { + return fmt.Errorf("error stopping Appconfig Deployment (%s): %s", d.Id(), err) + } + + return nil +} diff --git a/aws/resource_aws_appconfig_deployment_test.go b/aws/resource_aws_appconfig_deployment_test.go new file mode 100644 index 00000000000..d99d01d8a29 --- /dev/null +++ b/aws/resource_aws_appconfig_deployment_test.go @@ -0,0 +1,263 @@ +package aws + +import ( + "fmt" + "strconv" + "testing" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/appconfig" + "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" +) + +func TestAccAWSAppConfigDeployment_basic(t *testing.T) { + var deployment appconfig.GetDeploymentOutput + rDesc := acctest.RandomWithPrefix("desc") + resourceName := "aws_appconfig_deployment.test" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigDeploymentDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigDeploymentName(rDesc), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentExists(resourceName, &deployment), + testAccCheckAWSAppConfigDeploymentARN(resourceName, &deployment), + resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), + resource.TestCheckResourceAttr(resourceName, "description", rDesc), + resource.TestCheckResourceAttr(resourceName, "configuration_version", "1"), + ), + }, + }, + }) +} + +func TestAccAWSAppConfigDeployment_disappears(t *testing.T) { + var deployment appconfig.GetDeploymentOutput + + rDesc := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_deployment.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigDeploymentDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigDeploymentName(rDesc), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentExists(resourceName, &deployment), + testAccCheckAWSAppConfigDeploymentDisappears(&deployment), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + +func TestAccAWSAppConfigDeployment_Tags(t *testing.T) { + var deployment appconfig.GetDeploymentOutput + + resourceName := "aws_appconfig_deployment.test" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigDeploymentDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigDeploymentTags1("key1", "value1"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentExists(resourceName, &deployment), + resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), + resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), + ), + }, + { + Config: testAccAWSAppConfigDeploymentTags2("key1", "value1updated", "key2", "value2"), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigDeploymentExists(resourceName, &deployment), + resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), + resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"), + resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), + ), + }, + }, + }) +} + +func testAccCheckAppConfigDeploymentDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + for _, rs := range s.RootModule().Resources { + if rs.Type != "aws_appconfig_deployment" { + continue + } + + deploymentNumber, err := strconv.ParseInt(rs.Primary.Attributes["deployment_number"], 10, 64) + if err != nil { + return err + } + + input := &appconfig.GetDeploymentInput{ + ApplicationId: aws.String(rs.Primary.Attributes["application_id"]), + EnvironmentId: aws.String(rs.Primary.Attributes["environment_id"]), + DeploymentNumber: aws.Int64(deploymentNumber), + } + + output, err := conn.GetDeployment(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + continue + } + + if err != nil { + return err + } + + if output != nil { + return fmt.Errorf("AppConfig Deployment (%s) still exists", rs.Primary.ID) + } + } + + return nil + +} + +func testAccCheckAWSAppConfigDeploymentDisappears(deployment *appconfig.GetDeploymentOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + input := &appconfig.StopDeploymentInput{ + ApplicationId: deployment.ApplicationId, + EnvironmentId: deployment.EnvironmentId, + DeploymentNumber: deployment.DeploymentNumber, + } + + _, err := conn.StopDeployment(input) + + return err + } +} + +func testAccCheckAWSAppConfigDeploymentExists(resourceName string, deployment *appconfig.GetDeploymentOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Resource not found: %s", resourceName) + } + + if rs.Primary.ID == "" { + return fmt.Errorf("Resource (%s) ID not set", resourceName) + } + + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + deploymentNumber, err := strconv.ParseInt(rs.Primary.Attributes["deployment_number"], 10, 64) + if err != nil { + return err + } + + input := &appconfig.GetDeploymentInput{ + ApplicationId: aws.String(rs.Primary.Attributes["application_id"]), + EnvironmentId: aws.String(rs.Primary.Attributes["environment_id"]), + DeploymentNumber: aws.Int64(deploymentNumber), + } + + output, err := conn.GetDeployment(input) + if err != nil { + return err + } + + *deployment = *output + + return nil + } +} + +func testAccCheckAWSAppConfigDeploymentARN(resourceName string, deployment *appconfig.GetDeploymentOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + appID := aws.StringValue(deployment.ApplicationId) + envID := aws.StringValue(deployment.EnvironmentId) + deployNum := fmt.Sprintf("%d", aws.Int64Value(deployment.DeploymentNumber)) + arnResource := fmt.Sprintf("application/%s/environment/%s/deployment/%s", appID, envID, deployNum) + return testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appconfig", arnResource)(s) + } +} + +func testAccAWSAppConfigDeploymentSetup() string { + baseName := acctest.RandomWithPrefix("tf-acc-test") + appName := fmt.Sprintf("%s-app", baseName) + envName := fmt.Sprintf("%s-env", baseName) + stratName := fmt.Sprintf("%s-strat", baseName) + configName := fmt.Sprintf("%s-config", baseName) + return fmt.Sprintf(` +resource "aws_appconfig_application" "app" { + name = %[1]q +} +resource "aws_appconfig_environment" "env" { + application_id = aws_appconfig_application.app.id + name = %[2]q +} +resource "aws_appconfig_deployment_strategy" "strategy" { + name = %[3]q + deployment_duration_in_minutes = 10 + growth_type = "LINEAR" + replicate_to = "NONE" +} +resource "aws_appconfig_configuration_profile" "config" { + application_id = aws_appconfig_application.app.id + location_uri = "hosted" + name = %[4]q +} +`, appName, envName, stratName, configName) +} + +func testAccAWSAppConfigDeploymentName(rDesc string) string { + return fmt.Sprintf(` +%[1]s +resource "aws_appconfig_deployment" "test" { + application_id = aws_appconfig_application.app.id + environment_id = aws_appconfig_environment.env.id + deployment_strategy_id = aws_appconfig_deployment_strategy.strategy.id + configuration_profile_id = aws_appconfig_configuration_profile.config.id + configuration_version = "1" + description = %[2]q +} +`, testAccAWSAppConfigDeploymentSetup(), rDesc) +} + +func testAccAWSAppConfigDeploymentTags1(tagKey1, tagValue1 string) string { + return fmt.Sprintf(` +%[1]s +resource "aws_appconfig_deployment" "test" { + application_id = aws_appconfig_application.app.id + environment_id = aws_appconfig_environment.env.id + deployment_strategy_id = aws_appconfig_deployment_strategy.strategy.id + configuration_profile_id = aws_appconfig_configuration_profile.config.id + configuration_version = "1" + tags = { + %[2]q = %[3]q + } +} +`, testAccAWSAppConfigDeploymentSetup(), tagKey1, tagValue1) +} + +func testAccAWSAppConfigDeploymentTags2(tagKey1, tagValue1, tagKey2, tagValue2 string) string { + return fmt.Sprintf(` +%[1]s +resource "aws_appconfig_deployment" "test" { + application_id = aws_appconfig_application.app.id + environment_id = aws_appconfig_environment.env.id + deployment_strategy_id = aws_appconfig_deployment_strategy.strategy.id + configuration_profile_id = aws_appconfig_configuration_profile.config.id + configuration_version = "1" + tags = { + %[2]q = %[3]q + %[4]q = %[5]q + } +} +`, testAccAWSAppConfigDeploymentSetup(), tagKey1, tagValue1, tagKey2, tagValue2) +} From 9799992707c626493dc6fc69ecaa578346356579 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Mon, 8 Mar 2021 19:31:42 -0500 Subject: [PATCH 13/25] Added hosted configuration version and tests --- aws/provider.go | 1 + 1 file changed, 1 insertion(+) diff --git a/aws/provider.go b/aws/provider.go index 033a3e1a0d8..35e17eb0ee6 100644 --- a/aws/provider.go +++ b/aws/provider.go @@ -454,6 +454,7 @@ func Provider() *schema.Provider { "aws_appconfig_deployment": resourceAwsAppconfigDeployment(), "aws_appconfig_deployment_strategy": resourceAwsAppconfigDeploymentStrategy(), "aws_appconfig_environment": resourceAwsAppconfigEnvironment(), + "aws_appconfig_hosted_configuration_version": resourceAwsAppconfigHostedConfigurationVersion(), "aws_appmesh_gateway_route": resourceAwsAppmeshGatewayRoute(), "aws_appmesh_mesh": resourceAwsAppmeshMesh(), "aws_appmesh_route": resourceAwsAppmeshRoute(), From e43539595f450ff80cab92db2d2af988b22650c9 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Mon, 8 Mar 2021 21:40:18 -0500 Subject: [PATCH 14/25] Added hosted configuration version resource and tests --- ..._appconfig_hosted_configuration_version.go | 173 ++++++++++ ...onfig_hosted_configuration_version_test.go | 295 ++++++++++++++++++ 2 files changed, 468 insertions(+) create mode 100644 aws/resource_aws_appconfig_hosted_configuration_version.go create mode 100644 aws/resource_aws_appconfig_hosted_configuration_version_test.go diff --git a/aws/resource_aws_appconfig_hosted_configuration_version.go b/aws/resource_aws_appconfig_hosted_configuration_version.go new file mode 100644 index 00000000000..7e6cf0cd513 --- /dev/null +++ b/aws/resource_aws_appconfig_hosted_configuration_version.go @@ -0,0 +1,173 @@ +package aws + +import ( + "fmt" + "log" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/arn" + "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func resourceAwsAppconfigHostedConfigurationVersion() *schema.Resource { + return &schema.Resource{ + Create: resourceAwsAppconfigHostedConfigurationVersionCreate, + Read: resourceAwsAppconfigHostedConfigurationVersionRead, + Update: resourceAwsAppconfigHostedConfigurationVersionUpdate, + Delete: resourceAwsAppconfigHostedConfigurationVersionDelete, + + Schema: map[string]*schema.Schema{ + "application_id": { + Type: schema.TypeString, + Required: true, + }, + "configuration_profile_id": { + Type: schema.TypeString, + Required: true, + }, + "content": { + Type: schema.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + "content_type": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + "application/json", + "application/x-yaml", + "text/plain", + }, false), + }, + "description": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.All( + validation.StringLenBetween(1, 2048), + ), + }, + "id": { + Type: schema.TypeString, + Computed: true, + }, + "arn": { + Type: schema.TypeString, + Computed: true, + }, + "version_number": { + Type: schema.TypeInt, + Computed: true, + }, + }, + } +} + +func resourceAwsAppconfigHostedConfigurationVersionCreate(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + applicationID := aws.String(d.Get("application_id").(string)) + configProfileID := aws.String(d.Get("configuration_profile_id").(string)) + content := []byte(d.Get("content").(string)) + contentType := aws.String(d.Get("content_type").(string)) + configVersionDescription := aws.String(d.Get("description").(string)) + + input := &appconfig.CreateHostedConfigurationVersionInput{ + ApplicationId: aws.String(d.Get("application_id").(string)), + ConfigurationProfileId: configProfileID, + Content: content, + ContentType: contentType, + Description: configVersionDescription, + } + + hostedConfig, err := conn.CreateHostedConfigurationVersion(input) + if err != nil { + return fmt.Errorf("Creating AppConfig Hosted Configuration Version failed: %s", err) + } + log.Printf("[DEBUG] AppConfig Hosted Configuration Version created: %s", hostedConfig) + + d.SetId(fmt.Sprintf("%s-%s-%d", aws.StringValue(applicationID), aws.StringValue(configProfileID), aws.Int64Value(hostedConfig.VersionNumber))) + d.Set("version_number", aws.Int64Value(hostedConfig.VersionNumber)) + + return resourceAwsAppconfigHostedConfigurationVersionRead(d, meta) +} + +func resourceAwsAppconfigHostedConfigurationVersionRead(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + + input := &appconfig.GetHostedConfigurationVersionInput{ + ApplicationId: aws.String(d.Get("application_id").(string)), + ConfigurationProfileId: aws.String(d.Get("configuration_profile_id").(string)), + VersionNumber: aws.Int64(int64(d.Get("version_number").(int))), + } + + output, err := conn.GetHostedConfigurationVersion(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + log.Printf("[WARN] Appconfig Hosted Configuration Version (%s) not found, removing from state", d.Id()) + d.SetId("") + return nil + } + + if err != nil { + return fmt.Errorf("error getting AppConfig Hosted Configuration Version (%s): %s", d.Id(), err) + } + + if output == nil { + return fmt.Errorf("error getting AppConfig Hosted Configuration Version (%s): empty response", d.Id()) + } + + appID := aws.StringValue(output.ApplicationId) + profileID := aws.StringValue(output.ConfigurationProfileId) + versionNum := fmt.Sprintf("%d", aws.Int64Value(output.VersionNumber)) + arnResource := fmt.Sprintf("application/%s/configurationprofile/%s/hostedconfigurationversion/%s", appID, profileID, versionNum) + appARN := arn.ARN{ + AccountID: meta.(*AWSClient).accountid, + Partition: meta.(*AWSClient).partition, + Region: meta.(*AWSClient).region, + Resource: arnResource, + Service: "appconfig", + }.String() + + d.Set("arn", appARN) + d.Set("description", output.Description) + d.Set("version_number", aws.Int64Value(output.VersionNumber)) + d.Set("content", string(output.Content)) + d.Set("content_type", output.ContentType) + + return nil +} + +func resourceAwsAppconfigHostedConfigurationVersionUpdate(d *schema.ResourceData, meta interface{}) error { + if err := resourceAwsAppconfigHostedConfigurationVersionDelete(d, meta); err != nil { + return fmt.Errorf("error rolling back existing deployment during update: %s", err) + } + + if err := resourceAwsAppconfigHostedConfigurationVersionCreate(d, meta); err != nil { + return fmt.Errorf("error starting new deployment during update: %s", err) + } + + return resourceAwsAppconfigHostedConfigurationVersionRead(d, meta) +} + +func resourceAwsAppconfigHostedConfigurationVersionDelete(d *schema.ResourceData, meta interface{}) error { + conn := meta.(*AWSClient).appconfigconn + + input := &appconfig.DeleteHostedConfigurationVersionInput{ + ApplicationId: aws.String(d.Get("application_id").(string)), + ConfigurationProfileId: aws.String(d.Get("configuration_profile_id").(string)), + VersionNumber: aws.Int64(int64(d.Get("version_number").(int))), + } + + _, err := conn.DeleteHostedConfigurationVersion(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + return nil + } + + if err != nil { + return fmt.Errorf("error deleting Appconfig Hosted Configuration Version (%s): %s", d.Id(), err) + } + + return nil +} diff --git a/aws/resource_aws_appconfig_hosted_configuration_version_test.go b/aws/resource_aws_appconfig_hosted_configuration_version_test.go new file mode 100644 index 00000000000..8fc167ed26d --- /dev/null +++ b/aws/resource_aws_appconfig_hosted_configuration_version_test.go @@ -0,0 +1,295 @@ +package aws + +import ( + "fmt" + "strconv" + "testing" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/appconfig" + "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" +) + +func TestAccAWSAppConfigHostedConfigurationVersion_basic(t *testing.T) { + var hostedConfigurationVersion appconfig.GetHostedConfigurationVersionOutput + rDesc := acctest.RandomWithPrefix("desc") + resourceName := "aws_appconfig_hosted_configuration_version.test" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigHostedConfigurationVersionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigHostedConfigurationVersionName(rDesc), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigHostedConfigurationVersionExists(resourceName, &hostedConfigurationVersion), + testAccCheckAWSAppConfigHostedConfigurationVersionARN(resourceName, &hostedConfigurationVersion), + resource.TestCheckResourceAttr(resourceName, "description", rDesc), + resource.TestCheckResourceAttr(resourceName, "version_number", "1"), + resource.TestCheckResourceAttr(resourceName, "content", "Settings"), + resource.TestCheckResourceAttr(resourceName, "content_type", "text/plain"), + ), + }, + }, + }) +} + +func TestAccAWSAppConfigHostedConfigurationVersion_disappears(t *testing.T) { + var hostedConfigurationVersion appconfig.GetHostedConfigurationVersionOutput + + rDesc := acctest.RandomWithPrefix("tf-acc-test") + resourceName := "aws_appconfig_hosted_configuration_version.test" + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigHostedConfigurationVersionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigHostedConfigurationVersionName(rDesc), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigHostedConfigurationVersionExists(resourceName, &hostedConfigurationVersion), + testAccCheckAWSAppConfigHostedConfigurationVersionDisappears(&hostedConfigurationVersion), + ), + ExpectNonEmptyPlan: true, + }, + }, + }) +} + +func TestAccAWSAppConfigHostedConfigurationVersion_Plain(t *testing.T) { + var hostedConfigurationVersion appconfig.GetHostedConfigurationVersionOutput + resourceName := "aws_appconfig_hosted_configuration_version.test" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigHostedConfigurationVersionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigHostedConfigurationVersionPlainText(), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigHostedConfigurationVersionExists(resourceName, &hostedConfigurationVersion), + testAccCheckAWSAppConfigHostedConfigurationVersionARN(resourceName, &hostedConfigurationVersion), + resource.TestCheckResourceAttr(resourceName, "version_number", "1"), + resource.TestCheckResourceAttr(resourceName, "content", "This is a list of the new settings! \n1. A \n2. B \n3. C\n"), + resource.TestCheckResourceAttr(resourceName, "content_type", "text/plain"), + ), + }, + }, + }) +} + +func TestAccAWSAppConfigHostedConfigurationVersion_JSON(t *testing.T) { + var hostedConfigurationVersion appconfig.GetHostedConfigurationVersionOutput + resourceName := "aws_appconfig_hosted_configuration_version.test" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigHostedConfigurationVersionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigHostedConfigurationVersionJSON(), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigHostedConfigurationVersionExists(resourceName, &hostedConfigurationVersion), + testAccCheckAWSAppConfigHostedConfigurationVersionARN(resourceName, &hostedConfigurationVersion), + resource.TestCheckResourceAttr(resourceName, "version_number", "1"), + resource.TestCheckResourceAttr(resourceName, "content", `{"hello":"world"}`), + resource.TestCheckResourceAttr(resourceName, "content_type", "application/json"), + ), + }, + }, + }) +} + +func TestAccAWSAppConfigHostedConfigurationVersion_YAML(t *testing.T) { + var hostedConfigurationVersion appconfig.GetHostedConfigurationVersionOutput + resourceName := "aws_appconfig_hosted_configuration_version.test" + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckAppConfigHostedConfigurationVersionDestroy, + Steps: []resource.TestStep{ + { + Config: testAccAWSAppConfigHostedConfigurationVersionYAML(), + Check: resource.ComposeTestCheckFunc( + testAccCheckAWSAppConfigHostedConfigurationVersionExists(resourceName, &hostedConfigurationVersion), + testAccCheckAWSAppConfigHostedConfigurationVersionARN(resourceName, &hostedConfigurationVersion), + resource.TestCheckResourceAttr(resourceName, "version_number", "1"), + resource.TestCheckResourceAttr(resourceName, "content", "\"a\": \"b\"\n\"c\": \"d\"\n"), + resource.TestCheckResourceAttr(resourceName, "content_type", "application/x-yaml"), + ), + }, + }, + }) +} + +func testAccCheckAppConfigHostedConfigurationVersionDestroy(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + for _, rs := range s.RootModule().Resources { + if rs.Type != "aws_appconfig_hosted_configuration_version" { + continue + } + + versionNumber, err := strconv.ParseInt(rs.Primary.Attributes["version_number"], 10, 64) + if err != nil { + return err + } + + input := &appconfig.GetHostedConfigurationVersionInput{ + ApplicationId: aws.String(rs.Primary.Attributes["application_id"]), + ConfigurationProfileId: aws.String(rs.Primary.Attributes["configuration_profile_id"]), + VersionNumber: aws.Int64(versionNumber), + } + + output, err := conn.GetHostedConfigurationVersion(input) + + if isAWSErr(err, appconfig.ErrCodeResourceNotFoundException, "") { + continue + } + + if err != nil { + return err + } + + if output != nil { + return fmt.Errorf("AppConfig HostedConfigurationVersion (%s) still exists", rs.Primary.ID) + } + } + + return nil + +} + +func testAccCheckAWSAppConfigHostedConfigurationVersionDisappears(hostedConfigurationVersion *appconfig.GetHostedConfigurationVersionOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + input := &appconfig.DeleteHostedConfigurationVersionInput{ + ApplicationId: hostedConfigurationVersion.ApplicationId, + ConfigurationProfileId: hostedConfigurationVersion.ConfigurationProfileId, + VersionNumber: hostedConfigurationVersion.VersionNumber, + } + + _, err := conn.DeleteHostedConfigurationVersion(input) + + return err + } +} + +func testAccCheckAWSAppConfigHostedConfigurationVersionExists(resourceName string, hostedConfigurationVersion *appconfig.GetHostedConfigurationVersionOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + rs, ok := s.RootModule().Resources[resourceName] + if !ok { + return fmt.Errorf("Resource not found: %s", resourceName) + } + + if rs.Primary.ID == "" { + return fmt.Errorf("Resource (%s) ID not set", resourceName) + } + + conn := testAccProvider.Meta().(*AWSClient).appconfigconn + + versionNumber, err := strconv.ParseInt(rs.Primary.Attributes["version_number"], 10, 64) + if err != nil { + return err + } + + input := &appconfig.GetHostedConfigurationVersionInput{ + ApplicationId: aws.String(rs.Primary.Attributes["application_id"]), + ConfigurationProfileId: aws.String(rs.Primary.Attributes["configuration_profile_id"]), + VersionNumber: aws.Int64(versionNumber), + } + + output, err := conn.GetHostedConfigurationVersion(input) + if err != nil { + return err + } + + *hostedConfigurationVersion = *output + + return nil + } +} + +func testAccCheckAWSAppConfigHostedConfigurationVersionARN(resourceName string, hostedConfigurationVersion *appconfig.GetHostedConfigurationVersionOutput) resource.TestCheckFunc { + return func(s *terraform.State) error { + appID := aws.StringValue(hostedConfigurationVersion.ApplicationId) + profileID := aws.StringValue(hostedConfigurationVersion.ConfigurationProfileId) + versionNum := fmt.Sprintf("%d", aws.Int64Value(hostedConfigurationVersion.VersionNumber)) + arnResource := fmt.Sprintf("application/%s/configurationprofile/%s/hostedconfigurationversion/%s", appID, profileID, versionNum) + return testAccCheckResourceAttrRegionalARN(resourceName, "arn", "appconfig", arnResource)(s) + } +} + +func testAccAWSAppConfigHostedConfigurationVersionSetup() string { + baseName := acctest.RandomWithPrefix("tf-acc-test") + appName := fmt.Sprintf("%s-app", baseName) + configName := fmt.Sprintf("%s-config", baseName) + return fmt.Sprintf(` +resource "aws_appconfig_application" "app" { + name = %[1]q +} +resource "aws_appconfig_configuration_profile" "config" { + application_id = aws_appconfig_application.app.id + location_uri = "hosted" + name = %[2]q +} +`, appName, configName) +} + +func testAccAWSAppConfigHostedConfigurationVersionName(rDesc string) string { + return fmt.Sprintf(` +%[1]s +resource "aws_appconfig_hosted_configuration_version" "test" { + application_id = aws_appconfig_application.app.id + configuration_profile_id = aws_appconfig_configuration_profile.config.id + content = "Settings" + content_type = "text/plain" + description = %[2]q +} +`, testAccAWSAppConfigHostedConfigurationVersionSetup(), rDesc) +} + +func testAccAWSAppConfigHostedConfigurationVersionPlainText() string { + return fmt.Sprintf(` +%[1]s +resource "aws_appconfig_hosted_configuration_version" "test" { + application_id = aws_appconfig_application.app.id + configuration_profile_id = aws_appconfig_configuration_profile.config.id + content = <<-EOF + This is a list of the new settings! + 1. A + 2. B + 3. C + EOF + content_type = "text/plain" +} +`, testAccAWSAppConfigHostedConfigurationVersionSetup()) +} + +func testAccAWSAppConfigHostedConfigurationVersionJSON() string { + return fmt.Sprintf(` +%[1]s +resource "aws_appconfig_hosted_configuration_version" "test" { + application_id = aws_appconfig_application.app.id + configuration_profile_id = aws_appconfig_configuration_profile.config.id + content = jsonencode({"hello"="world"}) + content_type = "application/json" +} +`, testAccAWSAppConfigHostedConfigurationVersionSetup()) +} + +func testAccAWSAppConfigHostedConfigurationVersionYAML() string { + return fmt.Sprintf(` +%[1]s +resource "aws_appconfig_hosted_configuration_version" "test" { + application_id = aws_appconfig_application.app.id + configuration_profile_id = aws_appconfig_configuration_profile.config.id + content = yamlencode({"a":"b", "c":"d"}) + content_type = "application/x-yaml" +} +`, testAccAWSAppConfigHostedConfigurationVersionSetup()) +} From e6d1d9c6af0706e443bb7060920161f05844fca2 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Mon, 8 Mar 2021 21:40:45 -0500 Subject: [PATCH 15/25] Fixed extra parentheses --- aws/resource_aws_appconfig_configuration_profile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/resource_aws_appconfig_configuration_profile.go b/aws/resource_aws_appconfig_configuration_profile.go index f14f37cdeb7..d2ae450a699 100644 --- a/aws/resource_aws_appconfig_configuration_profile.go +++ b/aws/resource_aws_appconfig_configuration_profile.go @@ -99,7 +99,7 @@ func resourceAwsAppconfigConfigurationProfileCreate(d *schema.ResourceData, meta } input := &appconfig.CreateConfigurationProfileInput{ - ApplicationId: (applicationID), + ApplicationId: applicationID, Name: configProfileName, Description: configProfileDescription, LocationUri: locationURI, From e2a2168014bd87eb77c31b836e9a00e61d77f3ce Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Mon, 8 Mar 2021 21:41:08 -0500 Subject: [PATCH 16/25] Fixed deployment state and failing tests --- aws/resource_aws_appconfig_deployment.go | 40 ++++++++++++++-- aws/resource_aws_appconfig_deployment_test.go | 46 +++++++++++++------ 2 files changed, 67 insertions(+), 19 deletions(-) diff --git a/aws/resource_aws_appconfig_deployment.go b/aws/resource_aws_appconfig_deployment.go index cacb1eb965b..02ebadf42d3 100644 --- a/aws/resource_aws_appconfig_deployment.go +++ b/aws/resource_aws_appconfig_deployment.go @@ -3,10 +3,12 @@ package aws import ( "fmt" "log" + "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/arn" "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" @@ -83,13 +85,30 @@ func resourceAwsAppconfigDeploymentCreate(d *schema.ResourceData, meta interface Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppconfigTags(), } - deploy, err := conn.StartDeployment(input) + var deploy *appconfig.StartDeploymentOutput + var err error + err = resource.Retry(2*time.Minute, func() *resource.RetryError { + deploy, err = conn.StartDeployment(input) + if err != nil { + if isAWSErr(err, appconfig.ErrCodeConflictException, "") { + log.Printf("[DEBUG] Retrying AppConfig Deployment creation: %s", err) + return resource.RetryableError(err) + } + return resource.NonRetryableError(err) + } + return nil + }) + + if isResourceTimeoutError(err) { + deploy, err = conn.StartDeployment(input) + } + if err != nil { return fmt.Errorf("Creating AppConfig Deployment failed: %s", err) } - log.Printf("[DEBUG] AppConfig Deployment created: %s", deploy) d.SetId(fmt.Sprintf("%s-%s-%d", aws.StringValue(applicationID), aws.StringValue(environmentID), aws.Int64Value(deploy.DeploymentNumber))) + d.Set("deployment_number", aws.Int64Value(deploy.DeploymentNumber)) return resourceAwsAppconfigDeploymentRead(d, meta) } @@ -104,7 +123,7 @@ func resourceAwsAppconfigDeploymentRead(d *schema.ResourceData, meta interface{} input := &appconfig.GetDeploymentInput{ ApplicationId: applicationID, EnvironmentId: environmentID, - DeploymentNumber: aws.Int64(d.Get("deployment_number").(int64)), + DeploymentNumber: aws.Int64(int64(d.Get("deployment_number").(int))), } output, err := conn.GetDeployment(input) @@ -123,6 +142,13 @@ func resourceAwsAppconfigDeploymentRead(d *schema.ResourceData, meta interface{} return fmt.Errorf("error getting AppConfig Deployment (%s): empty response", d.Id()) } + currentState := aws.StringValue(output.State) + if currentState == appconfig.DeploymentStateRolledBack || currentState == appconfig.DeploymentStateRollingBack { + log.Printf("[WARN] Appconfig Deployment (%s) rolled back, removing from state", d.Id()) + d.SetId("") + return nil + } + appID := aws.StringValue(output.ApplicationId) envID := aws.StringValue(output.EnvironmentId) deployNum := fmt.Sprintf("%d", aws.Int64Value(output.DeploymentNumber)) @@ -137,6 +163,7 @@ func resourceAwsAppconfigDeploymentRead(d *schema.ResourceData, meta interface{} d.Set("arn", appARN) d.Set("description", output.Description) + d.Set("deployment_number", aws.Int64Value(output.DeploymentNumber)) tags, err := keyvaluetags.AppconfigListTags(conn, appARN) if err != nil { @@ -167,7 +194,8 @@ func resourceAwsAppconfigDeploymentDelete(d *schema.ResourceData, meta interface input := &appconfig.StopDeploymentInput{ ApplicationId: aws.String(d.Get("application_id").(string)), - DeploymentNumber: aws.Int64(d.Get("deployment_number").(int64)), + EnvironmentId: aws.String(d.Get("environment_id").(string)), + DeploymentNumber: aws.Int64(int64(d.Get("deployment_number").(int))), } _, err := conn.StopDeployment(input) @@ -176,6 +204,10 @@ func resourceAwsAppconfigDeploymentDelete(d *schema.ResourceData, meta interface return nil } + if isAWSErr(err, appconfig.ErrCodeBadRequestException, "it has a status of ROLLED_BACK") { + return nil + } + if err != nil { return fmt.Errorf("error stopping Appconfig Deployment (%s): %s", d.Id(), err) } diff --git a/aws/resource_aws_appconfig_deployment_test.go b/aws/resource_aws_appconfig_deployment_test.go index d99d01d8a29..bcbd105d76e 100644 --- a/aws/resource_aws_appconfig_deployment_test.go +++ b/aws/resource_aws_appconfig_deployment_test.go @@ -14,15 +14,18 @@ import ( func TestAccAWSAppConfigDeployment_basic(t *testing.T) { var deployment appconfig.GetDeploymentOutput + + baseName := acctest.RandomWithPrefix("tf-acc-test") rDesc := acctest.RandomWithPrefix("desc") resourceName := "aws_appconfig_deployment.test" + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigDeploymentDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSAppConfigDeploymentName(rDesc), + Config: testAccAWSAppConfigDeploymentName(baseName, rDesc), Check: resource.ComposeTestCheckFunc( testAccCheckAWSAppConfigDeploymentExists(resourceName, &deployment), testAccCheckAWSAppConfigDeploymentARN(resourceName, &deployment), @@ -38,6 +41,7 @@ func TestAccAWSAppConfigDeployment_basic(t *testing.T) { func TestAccAWSAppConfigDeployment_disappears(t *testing.T) { var deployment appconfig.GetDeploymentOutput + baseName := acctest.RandomWithPrefix("tf-acc-test") rDesc := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_deployment.test" @@ -47,7 +51,7 @@ func TestAccAWSAppConfigDeployment_disappears(t *testing.T) { CheckDestroy: testAccCheckAppConfigDeploymentDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSAppConfigDeploymentName(rDesc), + Config: testAccAWSAppConfigDeploymentName(baseName, rDesc), Check: resource.ComposeTestCheckFunc( testAccCheckAWSAppConfigDeploymentExists(resourceName, &deployment), testAccCheckAWSAppConfigDeploymentDisappears(&deployment), @@ -61,14 +65,16 @@ func TestAccAWSAppConfigDeployment_disappears(t *testing.T) { func TestAccAWSAppConfigDeployment_Tags(t *testing.T) { var deployment appconfig.GetDeploymentOutput + baseName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_deployment.test" + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigDeploymentDestroy, Steps: []resource.TestStep{ { - Config: testAccAWSAppConfigDeploymentTags1("key1", "value1"), + Config: testAccAWSAppConfigDeploymentTags1(baseName, "key1", "value1"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSAppConfigDeploymentExists(resourceName, &deployment), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), @@ -76,7 +82,7 @@ func TestAccAWSAppConfigDeployment_Tags(t *testing.T) { ), }, { - Config: testAccAWSAppConfigDeploymentTags2("key1", "value1updated", "key2", "value2"), + Config: testAccAWSAppConfigDeploymentTags2(baseName, "key1", "value1updated", "key2", "value2"), Check: resource.ComposeTestCheckFunc( testAccCheckAWSAppConfigDeploymentExists(resourceName, &deployment), resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), @@ -117,6 +123,11 @@ func testAccCheckAppConfigDeploymentDestroy(s *terraform.State) error { return err } + currentState := aws.StringValue(output.State) + if currentState == appconfig.DeploymentStateRolledBack || currentState == appconfig.DeploymentStateRollingBack { + return nil + } + if output != nil { return fmt.Errorf("AppConfig Deployment (%s) still exists", rs.Primary.ID) } @@ -187,8 +198,7 @@ func testAccCheckAWSAppConfigDeploymentARN(resourceName string, deployment *appc } } -func testAccAWSAppConfigDeploymentSetup() string { - baseName := acctest.RandomWithPrefix("tf-acc-test") +func testAccAWSAppConfigDeploymentSetup(baseName string) string { appName := fmt.Sprintf("%s-app", baseName) envName := fmt.Sprintf("%s-env", baseName) stratName := fmt.Sprintf("%s-strat", baseName) @@ -212,10 +222,16 @@ resource "aws_appconfig_configuration_profile" "config" { location_uri = "hosted" name = %[4]q } +resource "aws_appconfig_hosted_configuration_version" "hosted" { + application_id = aws_appconfig_application.app.id + configuration_profile_id = aws_appconfig_configuration_profile.config.id + content = "Settings" + content_type = "text/plain" +} `, appName, envName, stratName, configName) } -func testAccAWSAppConfigDeploymentName(rDesc string) string { +func testAccAWSAppConfigDeploymentName(baseName, rDesc string) string { return fmt.Sprintf(` %[1]s resource "aws_appconfig_deployment" "test" { @@ -223,13 +239,13 @@ resource "aws_appconfig_deployment" "test" { environment_id = aws_appconfig_environment.env.id deployment_strategy_id = aws_appconfig_deployment_strategy.strategy.id configuration_profile_id = aws_appconfig_configuration_profile.config.id - configuration_version = "1" + configuration_version = aws_appconfig_hosted_configuration_version.hosted.version_number description = %[2]q } -`, testAccAWSAppConfigDeploymentSetup(), rDesc) +`, testAccAWSAppConfigDeploymentSetup(baseName), rDesc) } -func testAccAWSAppConfigDeploymentTags1(tagKey1, tagValue1 string) string { +func testAccAWSAppConfigDeploymentTags1(baseName, tagKey1, tagValue1 string) string { return fmt.Sprintf(` %[1]s resource "aws_appconfig_deployment" "test" { @@ -237,15 +253,15 @@ resource "aws_appconfig_deployment" "test" { environment_id = aws_appconfig_environment.env.id deployment_strategy_id = aws_appconfig_deployment_strategy.strategy.id configuration_profile_id = aws_appconfig_configuration_profile.config.id - configuration_version = "1" + configuration_version = aws_appconfig_hosted_configuration_version.hosted.version_number tags = { %[2]q = %[3]q } } -`, testAccAWSAppConfigDeploymentSetup(), tagKey1, tagValue1) +`, testAccAWSAppConfigDeploymentSetup(baseName), tagKey1, tagValue1) } -func testAccAWSAppConfigDeploymentTags2(tagKey1, tagValue1, tagKey2, tagValue2 string) string { +func testAccAWSAppConfigDeploymentTags2(baseName, tagKey1, tagValue1, tagKey2, tagValue2 string) string { return fmt.Sprintf(` %[1]s resource "aws_appconfig_deployment" "test" { @@ -253,11 +269,11 @@ resource "aws_appconfig_deployment" "test" { environment_id = aws_appconfig_environment.env.id deployment_strategy_id = aws_appconfig_deployment_strategy.strategy.id configuration_profile_id = aws_appconfig_configuration_profile.config.id - configuration_version = "1" + configuration_version = aws_appconfig_hosted_configuration_version.hosted.version_number tags = { %[2]q = %[3]q %[4]q = %[5]q } } -`, testAccAWSAppConfigDeploymentSetup(), tagKey1, tagValue1, tagKey2, tagValue2) +`, testAccAWSAppConfigDeploymentSetup(baseName), tagKey1, tagValue1, tagKey2, tagValue2) } From ee30db32205314eba7d6198f1115876adfe89e8a Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Tue, 9 Mar 2021 13:16:08 -0500 Subject: [PATCH 17/25] Fixed broken tests and changed tests to run in parallel --- aws/resource_aws_appconfig_configuration_profile.go | 12 +++++++----- ...ource_aws_appconfig_configuration_profile_test.go | 12 ++++++------ aws/resource_aws_appconfig_deployment_test.go | 6 +++--- aws/resource_aws_appconfig_environment_test.go | 8 ++++---- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/aws/resource_aws_appconfig_configuration_profile.go b/aws/resource_aws_appconfig_configuration_profile.go index d2ae450a699..49e3edad534 100644 --- a/aws/resource_aws_appconfig_configuration_profile.go +++ b/aws/resource_aws_appconfig_configuration_profile.go @@ -3,7 +3,6 @@ package aws import ( "fmt" "log" - "time" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/arn" @@ -12,6 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/terraform-providers/terraform-provider-aws/aws/internal/keyvaluetags" + iamwaiter "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/iam/waiter" ) func resourceAwsAppconfigConfigurationProfile() *schema.Resource { @@ -109,12 +109,13 @@ func resourceAwsAppconfigConfigurationProfileCreate(d *schema.ResourceData, meta } expectedErrMsg := fmt.Sprintf("Error trying to assume role %s", d.Get("retrieval_role_arn").(string)) + expectedErrMsg2 := "is not authorized to perform the operation" var config *appconfig.CreateConfigurationProfileOutput var err error - err = resource.Retry(2*time.Minute, func() *resource.RetryError { + err = resource.Retry(iamwaiter.PropagationTimeout, func() *resource.RetryError { config, err = conn.CreateConfigurationProfile(input) if err != nil { - if isAWSErr(err, "BadRequestException", expectedErrMsg) { + if isAWSErr(err, "BadRequestException", expectedErrMsg) || isAWSErr(err, "BadRequestException", expectedErrMsg2) { log.Printf("[DEBUG] Retrying AppConfig Configuration Profile creation: %s", err) return resource.RetryableError(err) } @@ -230,11 +231,12 @@ func resourceAwsAppconfigConfigurationProfileUpdate(d *schema.ResourceData, meta } expectedErrMsg := fmt.Sprintf("Error trying to assume role %s", d.Get("retrieval_role_arn").(string)) + expectedErrMsg2 := "is not authorized to perform the operation" var err error - err = resource.Retry(2*time.Minute, func() *resource.RetryError { + err = resource.Retry(iamwaiter.PropagationTimeout, func() *resource.RetryError { _, err = conn.UpdateConfigurationProfile(updateInput) if err != nil { - if isAWSErr(err, "BadRequestException", expectedErrMsg) { + if isAWSErr(err, "BadRequestException", expectedErrMsg) || isAWSErr(err, "BadRequestException", expectedErrMsg2) te{ log.Printf("[DEBUG] Retrying AppConfig Configuration Profile update: %s", err) return resource.RetryableError(err) } diff --git a/aws/resource_aws_appconfig_configuration_profile_test.go b/aws/resource_aws_appconfig_configuration_profile_test.go index 0399a43cfc3..83800e98824 100644 --- a/aws/resource_aws_appconfig_configuration_profile_test.go +++ b/aws/resource_aws_appconfig_configuration_profile_test.go @@ -18,7 +18,7 @@ func TestAccAWSAppConfigConfigurationProfile_basic(t *testing.T) { rName := acctest.RandomWithPrefix("tf-acc-test") rDesc := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_configuration_profile.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, @@ -49,7 +49,7 @@ func TestAccAWSAppConfigConfigurationProfile_disappears(t *testing.T) { rDesc := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_configuration_profile.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, @@ -70,7 +70,7 @@ func TestAccAWSAppConfigConfigurationProfile_LocationURI_SSMParameter(t *testing appName := acctest.RandomWithPrefix("tf-acc-test") rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_configuration_profile.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, @@ -93,7 +93,7 @@ func TestAccAWSAppConfigConfigurationProfile_LocationURI_SSMDocument(t *testing. appName := acctest.RandomWithPrefix("tf-acc-test") rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_configuration_profile.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, @@ -117,7 +117,7 @@ func TestAccAWSAppConfigConfigurationProfile_Validators(t *testing.T) { appName := acctest.RandomWithPrefix("tf-acc-test") rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_configuration_profile.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, @@ -142,7 +142,7 @@ func TestAccAWSAppConfigConfigurationProfile_Tags(t *testing.T) { rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_configuration_profile.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigConfigurationProfileDestroy, diff --git a/aws/resource_aws_appconfig_deployment_test.go b/aws/resource_aws_appconfig_deployment_test.go index bcbd105d76e..c8639542e2a 100644 --- a/aws/resource_aws_appconfig_deployment_test.go +++ b/aws/resource_aws_appconfig_deployment_test.go @@ -19,7 +19,7 @@ func TestAccAWSAppConfigDeployment_basic(t *testing.T) { rDesc := acctest.RandomWithPrefix("desc") resourceName := "aws_appconfig_deployment.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigDeploymentDestroy, @@ -45,7 +45,7 @@ func TestAccAWSAppConfigDeployment_disappears(t *testing.T) { rDesc := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_deployment.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigDeploymentDestroy, @@ -68,7 +68,7 @@ func TestAccAWSAppConfigDeployment_Tags(t *testing.T) { baseName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_deployment.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigDeploymentDestroy, diff --git a/aws/resource_aws_appconfig_environment_test.go b/aws/resource_aws_appconfig_environment_test.go index 0c3e09375b9..8f621ce7dc7 100644 --- a/aws/resource_aws_appconfig_environment_test.go +++ b/aws/resource_aws_appconfig_environment_test.go @@ -16,7 +16,7 @@ func TestAccAWSAppConfigEnvironment_basic(t *testing.T) { rName := acctest.RandomWithPrefix("tf-acc-test") rDesc := acctest.RandomWithPrefix("desc") resourceName := "aws_appconfig_environment.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigEnvironmentDestroy, @@ -43,7 +43,7 @@ func TestAccAWSAppConfigEnvironment_disappears(t *testing.T) { rDesc := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_environment.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigEnvironmentDestroy, @@ -64,7 +64,7 @@ func TestAccAWSAppConfigEnvironment_Monitors(t *testing.T) { var environment appconfig.GetEnvironmentOutput rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_environment.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigEnvironmentDestroy, @@ -89,7 +89,7 @@ func TestAccAWSAppConfigEnvironment_Tags(t *testing.T) { rName := acctest.RandomWithPrefix("tf-acc-test") resourceName := "aws_appconfig_environment.test" - resource.Test(t, resource.TestCase{ + resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckAppConfigEnvironmentDestroy, From f7edb12cc2d419206ed7a51a827c32936331fbc3 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Tue, 9 Mar 2021 17:07:19 -0500 Subject: [PATCH 18/25] Removed extra characters --- aws/resource_aws_appconfig_configuration_profile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/resource_aws_appconfig_configuration_profile.go b/aws/resource_aws_appconfig_configuration_profile.go index 49e3edad534..8470aae2525 100644 --- a/aws/resource_aws_appconfig_configuration_profile.go +++ b/aws/resource_aws_appconfig_configuration_profile.go @@ -236,7 +236,7 @@ func resourceAwsAppconfigConfigurationProfileUpdate(d *schema.ResourceData, meta err = resource.Retry(iamwaiter.PropagationTimeout, func() *resource.RetryError { _, err = conn.UpdateConfigurationProfile(updateInput) if err != nil { - if isAWSErr(err, "BadRequestException", expectedErrMsg) || isAWSErr(err, "BadRequestException", expectedErrMsg2) te{ + if isAWSErr(err, "BadRequestException", expectedErrMsg) || isAWSErr(err, "BadRequestException", expectedErrMsg2) { log.Printf("[DEBUG] Retrying AppConfig Configuration Profile update: %s", err) return resource.RetryableError(err) } From b04721b4c266495f9005f8487932c6b3cfcf374b Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Mon, 15 Mar 2021 18:37:47 -0400 Subject: [PATCH 19/25] Fixed update method and spelling --- aws/resource_aws_appconfig_application.go | 34 +++++-------- ...rce_aws_appconfig_configuration_profile.go | 16 +++--- ...ource_aws_appconfig_deployment_strategy.go | 36 ++++++------- aws/resource_aws_appconfig_environment.go | 50 ++++++++----------- ..._appconfig_hosted_configuration_version.go | 4 +- 5 files changed, 63 insertions(+), 77 deletions(-) diff --git a/aws/resource_aws_appconfig_application.go b/aws/resource_aws_appconfig_application.go index 743b609df61..c7dd46c3e74 100644 --- a/aws/resource_aws_appconfig_application.go +++ b/aws/resource_aws_appconfig_application.go @@ -129,28 +129,20 @@ func resourceAwsAppconfigApplicationUpdate(d *schema.ResourceData, meta interfac } } - appDesc := d.Get("description").(string) - appName := d.Get("name").(string) - - updateInput := &appconfig.UpdateApplicationInput{ - ApplicationId: aws.String(d.Id()), - Description: aws.String(appDesc), - Name: aws.String(appName), - } - - if d.HasChange("description") { - _, n := d.GetChange("description") - updateInput.Description = aws.String(n.(string)) - } - - if d.HasChange("name") { - _, n := d.GetChange("name") - updateInput.Name = aws.String(n.(string)) - } + if d.HasChanges("description", "name") { + appDesc := d.Get("description").(string) + appName := d.Get("name").(string) + + updateInput := &appconfig.UpdateApplicationInput{ + ApplicationId: aws.String(d.Id()), + Description: aws.String(appDesc), + Name: aws.String(appName), + } - _, err := conn.UpdateApplication(updateInput) - if err != nil { - return fmt.Errorf("error updating AppConfig Application(%s): %s", d.Id(), err) + _, err := conn.UpdateApplication(updateInput) + if err != nil { + return fmt.Errorf("error updating AppConfig Application(%s): %s", d.Id(), err) + } } return resourceAwsAppconfigApplicationRead(d, meta) diff --git a/aws/resource_aws_appconfig_configuration_profile.go b/aws/resource_aws_appconfig_configuration_profile.go index 8470aae2525..0f7e13163d2 100644 --- a/aws/resource_aws_appconfig_configuration_profile.go +++ b/aws/resource_aws_appconfig_configuration_profile.go @@ -88,9 +88,9 @@ func resourceAwsAppconfigConfigurationProfileCreate(d *schema.ResourceData, meta configProfileName := aws.String(d.Get("name").(string)) configProfileDescription := aws.String(d.Get("description").(string)) locationURI := aws.String(d.Get("location_uri").(string)) - retreivalRoleArn := aws.String(d.Get("retrieval_role_arn").(string)) - if *retreivalRoleArn == "" { - retreivalRoleArn = nil + retrievalRoleArn := aws.String(d.Get("retrieval_role_arn").(string)) + if *retrievalRoleArn == "" { + retrievalRoleArn = nil } var validatorList []*appconfig.Validator @@ -103,7 +103,7 @@ func resourceAwsAppconfigConfigurationProfileCreate(d *schema.ResourceData, meta Name: configProfileName, Description: configProfileDescription, LocationUri: locationURI, - RetrievalRoleArn: retreivalRoleArn, + RetrievalRoleArn: retrievalRoleArn, Validators: validatorList, Tags: keyvaluetags.New(d.Get("tags").(map[string]interface{})).IgnoreAws().AppconfigTags(), } @@ -202,9 +202,9 @@ func resourceAwsAppconfigConfigurationProfileUpdate(d *schema.ResourceData, meta configProfileID := aws.String(d.Id()) configProfileName := aws.String(d.Get("name").(string)) configProfileDescription := aws.String(d.Get("description").(string)) - retreivalRoleArn := aws.String(d.Get("retrieval_role_arn").(string)) - if *retreivalRoleArn == "" { - retreivalRoleArn = nil + retrievalRoleArn := aws.String(d.Get("retrieval_role_arn").(string)) + if *retrievalRoleArn == "" { + retrievalRoleArn = nil } var validatorList []*appconfig.Validator if validators := d.Get("validator").(*schema.Set).List(); len(validators) > 0 { @@ -216,7 +216,7 @@ func resourceAwsAppconfigConfigurationProfileUpdate(d *schema.ResourceData, meta ConfigurationProfileId: configProfileID, Description: configProfileDescription, Name: configProfileName, - RetrievalRoleArn: retreivalRoleArn, + RetrievalRoleArn: retrievalRoleArn, Validators: validatorList, } diff --git a/aws/resource_aws_appconfig_deployment_strategy.go b/aws/resource_aws_appconfig_deployment_strategy.go index 8d7138c5101..58137dad8ca 100644 --- a/aws/resource_aws_appconfig_deployment_strategy.go +++ b/aws/resource_aws_appconfig_deployment_strategy.go @@ -182,24 +182,26 @@ func resourceAwsAppconfigDeploymentStrategyUpdate(d *schema.ResourceData, meta i } } - deploymentStrategyDescription := aws.String(d.Get("description").(string)) - deployDuration := aws.Int64(int64(d.Get("deployment_duration_in_minutes").(int))) - bakeTime := aws.Int64(int64(d.Get("final_bake_time_in_minutes").(int))) - growthFactor := aws.Float64(d.Get("growth_factor").(float64)) - growthType := aws.String(d.Get("growth_type").(string)) - - updateInput := &appconfig.UpdateDeploymentStrategyInput{ - DeploymentStrategyId: aws.String(d.Id()), - Description: deploymentStrategyDescription, - DeploymentDurationInMinutes: deployDuration, - FinalBakeTimeInMinutes: bakeTime, - GrowthFactor: growthFactor, - GrowthType: growthType, - } + if d.HasChanges("deployment_duration_in_minutes", "description", "final_bake_time_in_minutes", "growth_factor", "growth_type") { + deploymentStrategyDescription := aws.String(d.Get("description").(string)) + deployDuration := aws.Int64(int64(d.Get("deployment_duration_in_minutes").(int))) + bakeTime := aws.Int64(int64(d.Get("final_bake_time_in_minutes").(int))) + growthFactor := aws.Float64(d.Get("growth_factor").(float64)) + growthType := aws.String(d.Get("growth_type").(string)) + + updateInput := &appconfig.UpdateDeploymentStrategyInput{ + DeploymentStrategyId: aws.String(d.Id()), + Description: deploymentStrategyDescription, + DeploymentDurationInMinutes: deployDuration, + FinalBakeTimeInMinutes: bakeTime, + GrowthFactor: growthFactor, + GrowthType: growthType, + } - _, err := conn.UpdateDeploymentStrategy(updateInput) - if err != nil { - return fmt.Errorf("error updating AppConfig DeploymentStrategy(%s): %s", d.Id(), err) + _, err := conn.UpdateDeploymentStrategy(updateInput) + if err != nil { + return fmt.Errorf("error updating AppConfig DeploymentStrategy(%s): %s", d.Id(), err) + } } return resourceAwsAppconfigDeploymentStrategyRead(d, meta) diff --git a/aws/resource_aws_appconfig_environment.go b/aws/resource_aws_appconfig_environment.go index e424e45fce1..f7bec6721c4 100644 --- a/aws/resource_aws_appconfig_environment.go +++ b/aws/resource_aws_appconfig_environment.go @@ -157,37 +157,29 @@ func resourceAwsAppconfigEnvironmentUpdate(d *schema.ResourceData, meta interfac } } - applicationID := aws.String(d.Get("application_id").(string)) - environmentID := aws.String(d.Id()) - environmentName := aws.String(d.Get("name").(string)) - environmentDescription := aws.String(d.Get("description").(string)) - - var monitorList []*appconfig.Monitor - if monitors := d.Get("monitor").(*schema.Set).List(); len(monitors) > 0 { - monitorList = convertMapToMonitors(monitors) - } - - updateInput := &appconfig.UpdateEnvironmentInput{ - ApplicationId: applicationID, - EnvironmentId: environmentID, - Description: environmentDescription, - Name: environmentName, - Monitors: monitorList, - } - - if d.HasChange("description") { - _, n := d.GetChange("description") - updateInput.Description = aws.String(n.(string)) - } + if d.HasChanges("name", "description", "monitors") { + applicationID := aws.String(d.Get("application_id").(string)) + environmentID := aws.String(d.Id()) + environmentName := aws.String(d.Get("name").(string)) + environmentDescription := aws.String(d.Get("description").(string)) + + var monitorList []*appconfig.Monitor + if monitors := d.Get("monitor").(*schema.Set).List(); len(monitors) > 0 { + monitorList = convertMapToMonitors(monitors) + } - if d.HasChange("name") { - _, n := d.GetChange("name") - updateInput.Name = aws.String(n.(string)) - } + updateInput := &appconfig.UpdateEnvironmentInput{ + ApplicationId: applicationID, + EnvironmentId: environmentID, + Description: environmentDescription, + Name: environmentName, + Monitors: monitorList, + } - _, err := conn.UpdateEnvironment(updateInput) - if err != nil { - return fmt.Errorf("Updating AppConfig Environment failed: %s", err) + _, err := conn.UpdateEnvironment(updateInput) + if err != nil { + return fmt.Errorf("Updating AppConfig Environment failed: %s", err) + } } return resourceAwsAppconfigEnvironmentRead(d, meta) diff --git a/aws/resource_aws_appconfig_hosted_configuration_version.go b/aws/resource_aws_appconfig_hosted_configuration_version.go index 7e6cf0cd513..f818a06eeb7 100644 --- a/aws/resource_aws_appconfig_hosted_configuration_version.go +++ b/aws/resource_aws_appconfig_hosted_configuration_version.go @@ -140,11 +140,11 @@ func resourceAwsAppconfigHostedConfigurationVersionRead(d *schema.ResourceData, func resourceAwsAppconfigHostedConfigurationVersionUpdate(d *schema.ResourceData, meta interface{}) error { if err := resourceAwsAppconfigHostedConfigurationVersionDelete(d, meta); err != nil { - return fmt.Errorf("error rolling back existing deployment during update: %s", err) + return fmt.Errorf("error deleting hosted configuration version during update: %s", err) } if err := resourceAwsAppconfigHostedConfigurationVersionCreate(d, meta); err != nil { - return fmt.Errorf("error starting new deployment during update: %s", err) + return fmt.Errorf("error creating hosted configuration version during update: %s", err) } return resourceAwsAppconfigHostedConfigurationVersionRead(d, meta) From 6b6447972813c6ded882c67daacd419808868b19 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Mon, 15 Mar 2021 19:53:39 -0400 Subject: [PATCH 20/25] Formatted all terraform blocks --- ...resource_aws_appconfig_application_test.go | 2 +- ...ws_appconfig_configuration_profile_test.go | 220 +++++++++--------- ..._aws_appconfig_deployment_strategy_test.go | 42 ++-- aws/resource_aws_appconfig_deployment_test.go | 74 +++--- ...resource_aws_appconfig_environment_test.go | 78 +++---- ...onfig_hosted_configuration_version_test.go | 42 ++-- 6 files changed, 229 insertions(+), 229 deletions(-) diff --git a/aws/resource_aws_appconfig_application_test.go b/aws/resource_aws_appconfig_application_test.go index a405fdd57ee..1721363742a 100644 --- a/aws/resource_aws_appconfig_application_test.go +++ b/aws/resource_aws_appconfig_application_test.go @@ -191,7 +191,7 @@ func testAccCheckAWSAppConfigApplicationARN(resourceName string, application *ap func testAccAWSAppConfigApplicationName(rName, rDesc string) string { return fmt.Sprintf(` resource "aws_appconfig_application" "test" { - name = %[1]q + name = %[1]q description = %[2]q } `, rName, rDesc) diff --git a/aws/resource_aws_appconfig_configuration_profile_test.go b/aws/resource_aws_appconfig_configuration_profile_test.go index 83800e98824..7a4aaa6c0ff 100644 --- a/aws/resource_aws_appconfig_configuration_profile_test.go +++ b/aws/resource_aws_appconfig_configuration_profile_test.go @@ -263,13 +263,13 @@ func testAccCheckAWSAppConfigConfigurationProfileExists(resourceName string, pro func testAccAWSAppConfigConfigurationProfileName(appName, rName, rDesc string) string { return fmt.Sprintf(` resource "aws_appconfig_application" "app" { - name = %[1]q + name = %[1]q } resource "aws_appconfig_configuration_profile" "test" { - name = %[2]q - description = %[3]q + name = %[2]q + description = %[3]q application_id = aws_appconfig_application.app.id - location_uri = "hosted" + location_uri = "hosted" } `, appName, rName, rDesc) } @@ -281,63 +281,63 @@ func testAccAWSAppConfigConfigurationProfileIAMRole() string { return fmt.Sprintf(` resource "aws_iam_role" "test_role" { - name = %[1]q - - assume_role_policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Action = "sts:AssumeRole" - Effect = "Allow" - Sid = "" - Principal = { - Service = "ssm.amazonaws.com" - } - }, - ] - }) - } - resource "aws_iam_policy_attachment" "test_attach" { - name = %[2]q - roles = [aws_iam_role.test_role.name] - policy_arn = aws_iam_policy.test_policy.arn - } - resource "aws_iam_policy" "test_policy" { - name = %[3]q - - policy = jsonencode({ - Version = "2012-10-17" - Statement = [ - { - Action = [ - "ssm:GetParameter*", - "ssm:DescribeParameters", - "ssm:PutParameter", - "ssm:GetDocument" - ] - Effect = "Allow" - Resource = "*" - }, - ] - }) - } + name = %[1]q + + assume_role_policy = jsonencode({ + Version = "2012-10-17" + Statement = [ + { + Action = "sts:AssumeRole" + Effect = "Allow" + Sid = "" + Principal = { + Service = "ssm.amazonaws.com" + } + }, + ] + }) +} +resource "aws_iam_policy_attachment" "test_attach" { + name = %[2]q + roles = [aws_iam_role.test_role.name] + policy_arn = aws_iam_policy.test_policy.arn +} +resource "aws_iam_policy" "test_policy" { + name = %[3]q + + policy = jsonencode({ + Version = "2012-10-17" + Statement = [ + { + Action = [ + "ssm:GetParameter*", + "ssm:DescribeParameters", + "ssm:PutParameter", + "ssm:GetDocument" + ] + Effect = "Allow" + Resource = "*" + }, + ] + }) +} `, roleName, attatchmentName, policyName) } func testAccAWSAppConfigConfigurationProfileLocationSSMParameter(appName, rName string) string { return fmt.Sprintf(` resource "aws_appconfig_application" "app" { - name = %[1]q + name = %[1]q } resource "aws_ssm_parameter" "ssm_param" { - name = "foo" - type = "String" - value = "bar" + name = "foo" + type = "String" + value = "bar" } resource "aws_appconfig_configuration_profile" "test" { - name = %[2]q - application_id = aws_appconfig_application.app.id - location_uri = aws_ssm_parameter.ssm_param.arn + name = %[2]q + application_id = aws_appconfig_application.app.id + location_uri = aws_ssm_parameter.ssm_param.arn retrieval_role_arn = aws_iam_role.test_role.arn } %[3]s @@ -347,13 +347,13 @@ resource "aws_appconfig_configuration_profile" "test" { func testAccAWSAppConfigConfigurationProfileLocationSSMDocument(appName, rName string) string { return fmt.Sprintf(` resource "aws_appconfig_application" "app" { - name = %[1]q + name = %[1]q } resource "aws_ssm_document" "ssm_doc" { - name = "test_document" - document_type = "Command" - - content = < Date: Tue, 16 Mar 2021 14:39:06 -0400 Subject: [PATCH 21/25] Fixed formatting for acceptance tests --- aws/resource_aws_ecs_task_set_test.go | 72 +++++++++++++-------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/aws/resource_aws_ecs_task_set_test.go b/aws/resource_aws_ecs_task_set_test.go index 671a09e0e57..fe56e0ac5c1 100644 --- a/aws/resource_aws_ecs_task_set_test.go +++ b/aws/resource_aws_ecs_task_set_test.go @@ -348,7 +348,7 @@ resource "aws_ecs_cluster" "default" { name = "%s" } resource "aws_ecs_task_definition" "mongo" { - family = "%s" + family = "%s" container_definitions = < Date: Tue, 16 Mar 2021 15:39:39 -0400 Subject: [PATCH 22/25] improved tf formatting --- aws/resource_aws_ecs_task_set_test.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/aws/resource_aws_ecs_task_set_test.go b/aws/resource_aws_ecs_task_set_test.go index fe56e0ac5c1..09326f61354 100644 --- a/aws/resource_aws_ecs_task_set_test.go +++ b/aws/resource_aws_ecs_task_set_test.go @@ -428,7 +428,7 @@ resource "aws_ecs_cluster" "default" { name = "%s" } resource "aws_ecs_task_definition" "mongo" { - family = "%s" + family = "%s" container_definitions = < Date: Tue, 16 Mar 2021 15:47:09 -0400 Subject: [PATCH 23/25] improved web documentation formatting --- website/docs/guides/custom-service-endpoints.html.md | 4 ++-- website/docs/r/ecs_task_set.html.markdown | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/website/docs/guides/custom-service-endpoints.html.md b/website/docs/guides/custom-service-endpoints.html.md index 5e03e5aafb1..0f79081b12a 100644 --- a/website/docs/guides/custom-service-endpoints.html.md +++ b/website/docs/guides/custom-service-endpoints.html.md @@ -19,8 +19,8 @@ This guide outlines how to get started with customizing endpoints, the available - [Getting Started with Custom Endpoints](#getting-started-with-custom-endpoints) - [Available Endpoint Customizations](#available-endpoint-customizations) - [Connecting to Local AWS Compatible Solutions](#connecting-to-local-aws-compatible-solutions) - - [DynamoDB Local](#dynamodb-local) - - [LocalStack](#localstack) + - [DynamoDB Local](#dynamodb-local) + - [LocalStack](#localstack) diff --git a/website/docs/r/ecs_task_set.html.markdown b/website/docs/r/ecs_task_set.html.markdown index 5969b0f86a2..a02cfeff5e4 100644 --- a/website/docs/r/ecs_task_set.html.markdown +++ b/website/docs/r/ecs_task_set.html.markdown @@ -16,12 +16,12 @@ See [ECS Task Set section in AWS developer guide](https://docs.amazonaws.cn/en_u ```hcl resource "aws_ecs_task_set" "mongo" { - service = "${aws_ecs_service.foo.id}" - cluster = "${aws_ecs_cluster.foo.id}" - task_definition = "${aws_ecs_task_definition.mongo.arn}" + service = aws_ecs_service.foo.id + cluster = aws_ecs_cluster.foo.id + task_definition = aws_ecs_task_definition.mongo.arn load_balancer { - target_group_arn = "${aws_lb_target_group.foo.arn}" + target_group_arn = aws_lb_target_group.foo.arn container_name = "mongo" container_port = 8080 } From 83a44d6aaafa66bfed81e9870cc5ea914cb872b3 Mon Sep 17 00:00:00 2001 From: Isaiah-Turner <42742035+Isaiah-Turner@users.noreply.github.com> Date: Tue, 16 Mar 2021 19:53:47 -0400 Subject: [PATCH 24/25] Added documentation for new resources --- .../r/appconfig_application.html.markdown | 48 +++++++++++ ...config_configuration_profile.html.markdown | 74 ++++++++++++++++ .../docs/r/appconfig_deployment.html.markdown | 72 ++++++++++++++++ ...ppconfig_deployment_strategy.html.markdown | 58 +++++++++++++ .../r/appconfig_environment.html.markdown | 84 +++++++++++++++++++ ...hosted_configuration_version.html.markdown | 53 ++++++++++++ 6 files changed, 389 insertions(+) create mode 100644 website/docs/r/appconfig_application.html.markdown create mode 100644 website/docs/r/appconfig_configuration_profile.html.markdown create mode 100644 website/docs/r/appconfig_deployment.html.markdown create mode 100644 website/docs/r/appconfig_deployment_strategy.html.markdown create mode 100644 website/docs/r/appconfig_environment.html.markdown create mode 100644 website/docs/r/appconfig_hosted_configuration_version.html.markdown diff --git a/website/docs/r/appconfig_application.html.markdown b/website/docs/r/appconfig_application.html.markdown new file mode 100644 index 00000000000..05b43ca65ab --- /dev/null +++ b/website/docs/r/appconfig_application.html.markdown @@ -0,0 +1,48 @@ +--- +subcategory: "AppConfig" +layout: "aws" +page_title: "AWS: aws_appconfig_application" +description: |- + Provides an AppConfig Application resource. +--- + +# Resource: aws_appconfig_application + +Provides an AppConfig Application resource. + +## Example Usage + +### AppConfig Application + +```hcl +resource "aws_appconfig_application" "test" { + name = "test-application-tf" + description = "Test AppConfig Application" + tags = { + Type = "AppConfig Application" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) The name to use for the application. Must be between 1 and 64 characters in length. +* `description` - (Optional) The description of the application. Can be at most 1024 characters. +* `tags` - (Optional) A map of tags to assign to the resource. + +## Attributes Reference + +In addition to all arguments above, the following attributes are exported: + +* `arn` - The Amazon Resource Name (ARN) of the AppConfig Application. +* `id` - The AppConfig Application ID + +## Import + +Applications can be imported using their ID, e.g. + +``` +$ terraform import aws_appconfig_application.bar 71rxuzt +``` diff --git a/website/docs/r/appconfig_configuration_profile.html.markdown b/website/docs/r/appconfig_configuration_profile.html.markdown new file mode 100644 index 00000000000..a159494c374 --- /dev/null +++ b/website/docs/r/appconfig_configuration_profile.html.markdown @@ -0,0 +1,74 @@ +--- +subcategory: "AppConfig" +layout: "aws" +page_title: "AWS: aws_appconfig_configuration_profile" +description: |- + Provides an AppConfig Application resource. +--- + +# Resource: aws_appconfig_configuration_profile + +Provides an AppConfig Configuration Profile resource. + +## Example Usage + +### AppConfig Configuration Profile + +```hcl +resource "aws_appconfig_application" "this" { + name = "sample" +} + +resource "aws_appconfig_configuration_profile" "this" { + application_id = aws_appconfig_application.this.id + name = "sample" + description = "just a sample" + location_uri = "hosted" + retrieval_role_arn = aws_iam_role.retrieve_ssm.arn + validator { + type = "JSON_SCHEMA" + content = < Date: Tue, 16 Mar 2021 19:54:11 -0400 Subject: [PATCH 25/25] Fixed shortened name --- aws/resource_aws_appconfig_deployment_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aws/resource_aws_appconfig_deployment_test.go b/aws/resource_aws_appconfig_deployment_test.go index ae9391f75ea..f85be08c5b5 100644 --- a/aws/resource_aws_appconfig_deployment_test.go +++ b/aws/resource_aws_appconfig_deployment_test.go @@ -201,7 +201,7 @@ func testAccCheckAWSAppConfigDeploymentARN(resourceName string, deployment *appc func testAccAWSAppConfigDeploymentSetup(baseName string) string { appName := fmt.Sprintf("%s-app", baseName) envName := fmt.Sprintf("%s-env", baseName) - stratName := fmt.Sprintf("%s-strat", baseName) + strategyName := fmt.Sprintf("%s-strategy", baseName) configName := fmt.Sprintf("%s-config", baseName) return fmt.Sprintf(` resource "aws_appconfig_application" "app" { @@ -228,7 +228,7 @@ resource "aws_appconfig_hosted_configuration_version" "hosted" { content = "Settings" content_type = "text/plain" } -`, appName, envName, stratName, configName) +`, appName, envName, strategyName, configName) } func testAccAWSAppConfigDeploymentName(baseName, rDesc string) string {