Skip to content

Commit

Permalink
provider/aws: Renaming option_settings attribute to setting. Adde…
Browse files Browse the repository at this point in the history
…d test to verify that settings are applied to template.

ref hashicorp#6035
  • Loading branch information
dharrisio committed Apr 6, 2016
1 parent 84b913b commit b1bdd1b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)),
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
}

0 comments on commit b1bdd1b

Please sign in to comment.