mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
provider/aws: Fix issue updating ElasticBeanstalk Environment templates (#7811)
* provider/aws: Fix issue removing templates from ElasticBeanstalk * regression test
This commit is contained in:
parent
da43730397
commit
ff9ad3cc40
@ -311,7 +311,9 @@ func resourceAwsElasticBeanstalkEnvironmentUpdate(d *schema.ResourceData, meta i
|
||||
|
||||
if d.HasChange("solution_stack_name") {
|
||||
hasChange = true
|
||||
updateOpts.SolutionStackName = aws.String(d.Get("solution_stack_name").(string))
|
||||
if v, ok := d.GetOk("solution_stack_name"); ok {
|
||||
updateOpts.SolutionStackName = aws.String(v.(string))
|
||||
}
|
||||
}
|
||||
|
||||
if d.HasChange("setting") {
|
||||
@ -332,7 +334,9 @@ func resourceAwsElasticBeanstalkEnvironmentUpdate(d *schema.ResourceData, meta i
|
||||
|
||||
if d.HasChange("template_name") {
|
||||
hasChange = true
|
||||
updateOpts.TemplateName = aws.String(d.Get("template_name").(string))
|
||||
if v, ok := d.GetOk("template_name"); ok {
|
||||
updateOpts.TemplateName = aws.String(v.(string))
|
||||
}
|
||||
}
|
||||
|
||||
if hasChange {
|
||||
|
@ -178,6 +178,40 @@ func TestAccAWSBeanstalkEnv_vpc(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAWSBeanstalkEnv_template_change(t *testing.T) {
|
||||
var app elasticbeanstalk.EnvironmentDescription
|
||||
|
||||
rInt := acctest.RandInt()
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() {
|
||||
testAccPreCheck(t)
|
||||
},
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckBeanstalkEnvDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccBeanstalkEnv_TemplateChange_stack(rInt),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckBeanstalkEnvExists("aws_elastic_beanstalk_environment.environment", &app),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccBeanstalkEnv_TemplateChange_temp(rInt),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckBeanstalkEnvExists("aws_elastic_beanstalk_environment.environment", &app),
|
||||
),
|
||||
},
|
||||
resource.TestStep{
|
||||
Config: testAccBeanstalkEnv_TemplateChange_stack(rInt),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckBeanstalkEnvExists("aws_elastic_beanstalk_environment.environment", &app),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testAccCheckBeanstalkEnvDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*AWSClient).elasticbeanstalkconn
|
||||
|
||||
@ -571,3 +605,63 @@ resource "aws_elastic_beanstalk_environment" "default" {
|
||||
}
|
||||
`, name)
|
||||
}
|
||||
|
||||
func testAccBeanstalkEnv_TemplateChange_stack(r int) string {
|
||||
return fmt.Sprintf(`
|
||||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
resource "aws_elastic_beanstalk_application" "app" {
|
||||
name = "beanstalk-app-%d"
|
||||
description = ""
|
||||
}
|
||||
|
||||
resource "aws_elastic_beanstalk_environment" "environment" {
|
||||
name = "beanstalk-env-%d"
|
||||
application = "${aws_elastic_beanstalk_application.app.name}"
|
||||
|
||||
# Go 1.4
|
||||
|
||||
solution_stack_name = "64bit Amazon Linux 2016.03 v2.1.0 running Go 1.4"
|
||||
}
|
||||
|
||||
resource "aws_elastic_beanstalk_configuration_template" "template" {
|
||||
name = "beanstalk-config-%d"
|
||||
application = "${aws_elastic_beanstalk_application.app.name}"
|
||||
|
||||
# Go 1.5
|
||||
solution_stack_name = "64bit Amazon Linux 2016.03 v2.1.3 running Go 1.5"
|
||||
}
|
||||
`, r, r, r)
|
||||
}
|
||||
|
||||
func testAccBeanstalkEnv_TemplateChange_temp(r int) string {
|
||||
return fmt.Sprintf(`
|
||||
provider "aws" {
|
||||
region = "us-east-1"
|
||||
}
|
||||
|
||||
resource "aws_elastic_beanstalk_application" "app" {
|
||||
name = "beanstalk-app-%d"
|
||||
description = ""
|
||||
}
|
||||
|
||||
resource "aws_elastic_beanstalk_environment" "environment" {
|
||||
name = "beanstalk-env-%d"
|
||||
application = "${aws_elastic_beanstalk_application.app.name}"
|
||||
|
||||
# Go 1.4
|
||||
|
||||
template_name = "${aws_elastic_beanstalk_configuration_template.template.name}"
|
||||
}
|
||||
|
||||
resource "aws_elastic_beanstalk_configuration_template" "template" {
|
||||
name = "beanstalk-config-%d"
|
||||
application = "${aws_elastic_beanstalk_application.app.name}"
|
||||
|
||||
# Go 1.5
|
||||
solution_stack_name = "64bit Amazon Linux 2016.03 v2.1.3 running Go 1.5"
|
||||
}
|
||||
`, r, r, r)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user