From e698822be50c90b4ac9d20fd91791befdfcb9c7f Mon Sep 17 00:00:00 2001 From: David Harris Date: Wed, 6 Apr 2016 10:35:07 -0600 Subject: [PATCH] provider/aws: Renaming `option_settings` attribute to `setting`. Added test to verify that settings are applied to template. Fixes #6035 --- ...lastic_beanstalk_configuration_template.go | 8 ++-- ...c_beanstalk_configuration_template_test.go | 45 +++++++++++++++++++ 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template.go b/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template.go index 1f3f91e84..15cb8543a 100644 --- a/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template.go +++ b/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template.go @@ -132,7 +132,7 @@ func resourceAwsElasticBeanstalkConfigurationTemplateUpdate(d *schema.ResourceDa } } - if d.HasChange("option_settings") { + if d.HasChange("setting") { if err := resourceAwsElasticBeanstalkConfigurationTemplateOptionSettingsUpdate(conn, d); err != nil { return err } @@ -152,7 +152,7 @@ func resourceAwsElasticBeanstalkConfigurationTemplateDescriptionUpdate(conn *ela } func resourceAwsElasticBeanstalkConfigurationTemplateOptionSettingsUpdate(conn *elasticbeanstalk.ElasticBeanstalk, d *schema.ResourceData) error { - if d.HasChange("option_settings") { + if d.HasChange("setting") { _, err := conn.ValidateConfigurationSettings(&elasticbeanstalk.ValidateConfigurationSettingsInput{ ApplicationName: aws.String(d.Get("application").(string)), TemplateName: aws.String(d.Get("name").(string)), @@ -162,7 +162,7 @@ func resourceAwsElasticBeanstalkConfigurationTemplateOptionSettingsUpdate(conn * return err } - o, n := d.GetChange("option_settings") + o, n := d.GetChange("setting") if o == nil { o = new(schema.Set) } @@ -211,7 +211,7 @@ func resourceAwsElasticBeanstalkConfigurationTemplateDelete(d *schema.ResourceDa } func gatherOptionSettings(d *schema.ResourceData) []*elasticbeanstalk.ConfigurationOptionSetting { - optionSettingsSet, ok := d.Get("option_settings").(*schema.Set) + optionSettingsSet, ok := d.Get("setting").(*schema.Set) if !ok || optionSettingsSet == nil { optionSettingsSet = new(schema.Set) } diff --git a/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template_test.go b/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template_test.go index 17f1a6ca7..0a26242b7 100644 --- a/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template_test.go +++ b/builtin/providers/aws/resource_aws_elastic_beanstalk_configuration_template_test.go @@ -48,6 +48,28 @@ func TestAccAWSBeanstalkConfigurationTemplate_VPC(t *testing.T) { }) } +func TestAccAWSBeanstalkConfigurationTemplate_Setting(t *testing.T) { + var config elasticbeanstalk.ConfigurationSettingsDescription + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckBeanstalkConfigurationTemplateDestroy, + Steps: []resource.TestStep{ + resource.TestStep{ + Config: testAccBeanstalkConfigurationTemplateConfig_Setting(acctest.RandString(5)), + Check: resource.ComposeTestCheckFunc( + testAccCheckBeanstalkConfigurationTemplateExists("aws_elastic_beanstalk_configuration_template.tf_template", &config), + resource.TestCheckResourceAttr( + "aws_elastic_beanstalk_configuration_template.tf_template", "setting.#", "1"), + resource.TestCheckResourceAttr( + "aws_elastic_beanstalk_configuration_template.tf_template", "setting.4112217815.value", "m1.small"), + ), + }, + }, + }) +} + func testAccCheckBeanstalkConfigurationTemplateDestroy(s *terraform.State) error { conn := testAccProvider.Meta().(*AWSClient).elasticbeanstalkconn @@ -177,3 +199,26 @@ resource "aws_elastic_beanstalk_configuration_template" "tf_template" { } `, name, name) } + +func testAccBeanstalkConfigurationTemplateConfig_Setting(name string) string { + return fmt.Sprintf(` +resource "aws_elastic_beanstalk_application" "tftest" { + name = "tf-test-%s" + description = "tf-test-desc" +} + +resource "aws_elastic_beanstalk_configuration_template" "tf_template" { + name = "tf-test-%s" + application = "${aws_elastic_beanstalk_application.tftest.name}" + + solution_stack_name = "64bit Amazon Linux running Python" + + setting { + namespace = "aws:autoscaling:launchconfiguration" + name = "InstanceType" + value = "m1.small" + } + +} +`, name, name) +}