provider/aws: Fix crasher in Elastic Beanstalk Configuration with option settings
This commit is contained in:
parent
2b02d0bf1a
commit
9ae8e85640
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform/helper/hashcode"
|
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
|
@ -38,26 +37,12 @@ func resourceAwsElasticBeanstalkConfigurationTemplate() *schema.Resource {
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"option_settings": &schema.Schema{
|
"setting": &schema.Schema{
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
Elem: &schema.Resource{
|
Computed: true,
|
||||||
Schema: map[string]*schema.Schema{
|
Elem: resourceAwsElasticBeanstalkOptionSetting(),
|
||||||
"namespace": &schema.Schema{
|
Set: optionSettingValueHash,
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
},
|
|
||||||
"option_name": &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
},
|
|
||||||
"value": &schema.Schema{
|
|
||||||
Type: schema.TypeString,
|
|
||||||
Optional: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Set: optionSettingHash,
|
|
||||||
},
|
},
|
||||||
"solution_stack_name": &schema.Schema{
|
"solution_stack_name": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
@ -225,13 +210,6 @@ func resourceAwsElasticBeanstalkConfigurationTemplateDelete(d *schema.ResourceDa
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func optionSettingHash(v interface{}) int {
|
|
||||||
rd := v.(*schema.ResourceData)
|
|
||||||
namespace := rd.Get("namespace").(string)
|
|
||||||
optionName := rd.Get("option_name").(string)
|
|
||||||
return hashcode.String(fmt.Sprintf("%s.%s", namespace, optionName))
|
|
||||||
}
|
|
||||||
|
|
||||||
func gatherOptionSettings(d *schema.ResourceData) []*elasticbeanstalk.ConfigurationOptionSetting {
|
func gatherOptionSettings(d *schema.ResourceData) []*elasticbeanstalk.ConfigurationOptionSetting {
|
||||||
optionSettingsSet, ok := d.Get("option_settings").(*schema.Set)
|
optionSettingsSet, ok := d.Get("option_settings").(*schema.Set)
|
||||||
if !ok || optionSettingsSet == nil {
|
if !ok || optionSettingsSet == nil {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
|
"github.com/aws/aws-sdk-go/service/elasticbeanstalk"
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
)
|
)
|
||||||
|
@ -29,6 +30,24 @@ func TestAccAWSBeanstalkConfigurationTemplate_basic(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccAWSBeanstalkConfigurationTemplate_VPC(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_VPC(acctest.RandString(5)),
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckBeanstalkConfigurationTemplateExists("aws_elastic_beanstalk_configuration_template.tf_template", &config),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func testAccCheckBeanstalkConfigurationTemplateDestroy(s *terraform.State) error {
|
func testAccCheckBeanstalkConfigurationTemplateDestroy(s *terraform.State) error {
|
||||||
conn := testAccProvider.Meta().(*AWSClient).elasticbeanstalkconn
|
conn := testAccProvider.Meta().(*AWSClient).elasticbeanstalkconn
|
||||||
|
|
||||||
|
@ -119,3 +138,48 @@ resource "aws_elastic_beanstalk_configuration_template" "tf_template" {
|
||||||
solution_stack_name = "64bit Amazon Linux 2015.09 v2.0.8 running Go 1.4"
|
solution_stack_name = "64bit Amazon Linux 2015.09 v2.0.8 running Go 1.4"
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
func testAccBeanstalkConfigurationTemplateConfig_VPC(name string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "aws_vpc" "tf_b_test" {
|
||||||
|
cidr_block = "10.0.0.0/16"
|
||||||
|
|
||||||
|
tags {
|
||||||
|
Name = "beanstalk_crash"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_subnet" "main" {
|
||||||
|
vpc_id = "${aws_vpc.tf_b_test.id}"
|
||||||
|
cidr_block = "10.0.0.0/24"
|
||||||
|
|
||||||
|
tags {
|
||||||
|
Name = "subnet-count-test"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 2015.03 v2.0.3 running Go 1.4"
|
||||||
|
|
||||||
|
setting {
|
||||||
|
namespace = "aws:ec2:vpc"
|
||||||
|
name = "VPCId"
|
||||||
|
value = "${aws_vpc.tf_b_test.id}"
|
||||||
|
}
|
||||||
|
|
||||||
|
setting {
|
||||||
|
namespace = "aws:ec2:vpc"
|
||||||
|
name = "Subnets"
|
||||||
|
value = "${aws_subnet.main.id}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`, name, name)
|
||||||
|
}
|
||||||
|
|
|
@ -36,13 +36,23 @@ The following arguments are supported:
|
||||||
* `application` – (Required) name of the application to associate with this configuration template
|
* `application` – (Required) name of the application to associate with this configuration template
|
||||||
* `description` - (Optional) Short description of the Template
|
* `description` - (Optional) Short description of the Template
|
||||||
* `environment_id` – (Optional) The ID of the environment used with this configuration template
|
* `environment_id` – (Optional) The ID of the environment used with this configuration template
|
||||||
* `option_settings` – (Optional) Option settings to configure the new Environment. These
|
* `setting` – (Optional) Option settings to configure the new Environment. These
|
||||||
override specific values that are set as defaults. The format is detailed
|
override specific values that are set as defaults. The format is detailed
|
||||||
below in [Option Settings](#option-settings)
|
below in [Option Settings](#option-settings)
|
||||||
* `solution_stack_name` – (Optional) A solution stack to base your Template
|
* `solution_stack_name` – (Optional) A solution stack to base your Template
|
||||||
off of. Example stacks can be found in the [Amazon API documentation][1]
|
off of. Example stacks can be found in the [Amazon API documentation][1]
|
||||||
|
|
||||||
|
|
||||||
|
<a id="option-settings"></a>
|
||||||
|
## Option Settings
|
||||||
|
|
||||||
|
The `setting` field supports the following format:
|
||||||
|
|
||||||
|
* `namespace` - (Optional) unique namespace identifying the option's
|
||||||
|
associated AWS resource
|
||||||
|
* `name` - (Optional) name of the configuration option
|
||||||
|
* `value` - (Optional) value for the configuration option
|
||||||
|
|
||||||
## Attributes Reference
|
## Attributes Reference
|
||||||
|
|
||||||
The following attributes are exported:
|
The following attributes are exported:
|
||||||
|
|
Loading…
Reference in New Issue