Merge pull request #11530 from hashicorp/b-aws-test-fixes
provider/aws: Handful of Acc configuration tests
This commit is contained in:
commit
be9fc64967
|
@ -1,21 +1,24 @@
|
||||||
package aws
|
package aws
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/helper/acctest"
|
||||||
"github.com/hashicorp/terraform/helper/resource"
|
"github.com/hashicorp/terraform/helper/resource"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAWSDBSubnetGroup_importBasic(t *testing.T) {
|
func TestAccAWSDBSubnetGroup_importBasic(t *testing.T) {
|
||||||
resourceName := "aws_db_subnet_group.foo"
|
resourceName := "aws_db_subnet_group.foo"
|
||||||
|
|
||||||
|
rName := fmt.Sprintf("tf-test-%d", acctest.RandInt())
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckDBSubnetGroupDestroy,
|
CheckDestroy: testAccCheckDBSubnetGroupDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccDBSubnetGroupConfig,
|
Config: testAccDBSubnetGroupConfig(rName),
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
|
|
|
@ -110,18 +110,20 @@ func TestAccAWSDBInstance_subnetGroup(t *testing.T) {
|
||||||
func TestAccAWSDBInstance_optionGroup(t *testing.T) {
|
func TestAccAWSDBInstance_optionGroup(t *testing.T) {
|
||||||
var v rds.DBInstance
|
var v rds.DBInstance
|
||||||
|
|
||||||
|
rName := fmt.Sprintf("tf-option-test-%d", acctest.RandInt())
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
|
CheckDestroy: testAccCheckAWSDBInstanceDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccAWSDBInstanceConfigWithOptionGroup,
|
Config: testAccAWSDBInstanceConfigWithOptionGroup(rName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &v),
|
testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &v),
|
||||||
testAccCheckAWSDBInstanceAttributes(&v),
|
testAccCheckAWSDBInstanceAttributes(&v),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_db_instance.bar", "option_group_name", "option-group-test-terraform"),
|
"aws_db_instance.bar", "option_group_name", rName),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -642,10 +644,10 @@ resource "aws_db_instance" "bar" {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
var testAccAWSDBInstanceConfigWithOptionGroup = fmt.Sprintf(`
|
func testAccAWSDBInstanceConfigWithOptionGroup(rName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_db_option_group" "bar" {
|
resource "aws_db_option_group" "bar" {
|
||||||
name = "option-group-test-terraform"
|
name = "%s"
|
||||||
option_group_description = "Test option group for terraform"
|
option_group_description = "Test option group for terraform"
|
||||||
engine_name = "mysql"
|
engine_name = "mysql"
|
||||||
major_engine_version = "5.6"
|
major_engine_version = "5.6"
|
||||||
|
@ -665,7 +667,8 @@ resource "aws_db_instance" "bar" {
|
||||||
|
|
||||||
parameter_group_name = "default.mysql5.6"
|
parameter_group_name = "default.mysql5.6"
|
||||||
option_group_name = "${aws_db_option_group.bar.name}"
|
option_group_name = "${aws_db_option_group.bar.name}"
|
||||||
}`, acctest.RandInt())
|
}`, rName, acctest.RandInt())
|
||||||
|
}
|
||||||
|
|
||||||
func testAccReplicaInstanceConfig(val int) string {
|
func testAccReplicaInstanceConfig(val int) string {
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"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"
|
||||||
|
|
||||||
|
@ -19,18 +20,20 @@ func TestAccAWSDBSubnetGroup_basic(t *testing.T) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rName := fmt.Sprintf("tf-test-%d", acctest.RandInt())
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckDBSubnetGroupDestroy,
|
CheckDestroy: testAccCheckDBSubnetGroupDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccDBSubnetGroupConfig,
|
Config: testAccDBSubnetGroupConfig(rName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckDBSubnetGroupExists(
|
testAccCheckDBSubnetGroupExists(
|
||||||
"aws_db_subnet_group.foo", &v),
|
"aws_db_subnet_group.foo", &v),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_db_subnet_group.foo", "name", "foo"),
|
"aws_db_subnet_group.foo", "name", rName),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_db_subnet_group.foo", "description", "Managed by Terraform"),
|
"aws_db_subnet_group.foo", "description", "Managed by Terraform"),
|
||||||
testCheck,
|
testCheck,
|
||||||
|
@ -73,13 +76,14 @@ func TestAccAWSDBSubnetGroup_withUndocumentedCharacters(t *testing.T) {
|
||||||
func TestAccAWSDBSubnetGroup_updateDescription(t *testing.T) {
|
func TestAccAWSDBSubnetGroup_updateDescription(t *testing.T) {
|
||||||
var v rds.DBSubnetGroup
|
var v rds.DBSubnetGroup
|
||||||
|
|
||||||
|
rName := fmt.Sprintf("tf-test-%d", acctest.RandInt())
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckDBSubnetGroupDestroy,
|
CheckDestroy: testAccCheckDBSubnetGroupDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccDBSubnetGroupConfig,
|
Config: testAccDBSubnetGroupConfig(rName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckDBSubnetGroupExists(
|
testAccCheckDBSubnetGroupExists(
|
||||||
"aws_db_subnet_group.foo", &v),
|
"aws_db_subnet_group.foo", &v),
|
||||||
|
@ -89,7 +93,7 @@ func TestAccAWSDBSubnetGroup_updateDescription(t *testing.T) {
|
||||||
},
|
},
|
||||||
|
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccDBSubnetGroupConfig_updatedDescription,
|
Config: testAccDBSubnetGroupConfig_updatedDescription(rName),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckDBSubnetGroupExists(
|
testAccCheckDBSubnetGroupExists(
|
||||||
"aws_db_subnet_group.foo", &v),
|
"aws_db_subnet_group.foo", &v),
|
||||||
|
@ -192,7 +196,8 @@ func testAccCheckDBSubnetGroupExists(n string, v *rds.DBSubnetGroup) resource.Te
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccDBSubnetGroupConfig = `
|
func testAccDBSubnetGroupConfig(rName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_vpc" "foo" {
|
resource "aws_vpc" "foo" {
|
||||||
cidr_block = "10.1.0.0/16"
|
cidr_block = "10.1.0.0/16"
|
||||||
}
|
}
|
||||||
|
@ -216,15 +221,16 @@ resource "aws_subnet" "bar" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_db_subnet_group" "foo" {
|
resource "aws_db_subnet_group" "foo" {
|
||||||
name = "foo"
|
name = "%s"
|
||||||
subnet_ids = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"]
|
subnet_ids = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"]
|
||||||
tags {
|
tags {
|
||||||
Name = "tf-dbsubnet-group-test"
|
Name = "tf-dbsubnet-group-test"
|
||||||
}
|
}
|
||||||
|
}`, rName)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
const testAccDBSubnetGroupConfig_updatedDescription = `
|
func testAccDBSubnetGroupConfig_updatedDescription(rName string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_vpc" "foo" {
|
resource "aws_vpc" "foo" {
|
||||||
cidr_block = "10.1.0.0/16"
|
cidr_block = "10.1.0.0/16"
|
||||||
}
|
}
|
||||||
|
@ -248,14 +254,14 @@ resource "aws_subnet" "bar" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_db_subnet_group" "foo" {
|
resource "aws_db_subnet_group" "foo" {
|
||||||
name = "foo"
|
name = "%s"
|
||||||
description = "foo description updated"
|
description = "foo description updated"
|
||||||
subnet_ids = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"]
|
subnet_ids = ["${aws_subnet.foo.id}", "${aws_subnet.bar.id}"]
|
||||||
tags {
|
tags {
|
||||||
Name = "tf-dbsubnet-group-test"
|
Name = "tf-dbsubnet-group-test"
|
||||||
}
|
}
|
||||||
|
}`, rName)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
const testAccDBSubnetGroupConfig_withUnderscoresAndPeriodsAndSpaces = `
|
const testAccDBSubnetGroupConfig_withUnderscoresAndPeriodsAndSpaces = `
|
||||||
resource "aws_vpc" "main" {
|
resource "aws_vpc" "main" {
|
||||||
|
|
|
@ -21,7 +21,7 @@ func TestAccAWSBeanstalkConfigurationTemplate_basic(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckBeanstalkConfigurationTemplateDestroy,
|
CheckDestroy: testAccCheckBeanstalkConfigurationTemplateDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
resource.TestStep{
|
resource.TestStep{
|
||||||
Config: testAccBeanstalkConfigurationTemplateConfig,
|
Config: testAccBeanstalkConfigurationTemplateConfig(acctest.RandString(5)),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckBeanstalkConfigurationTemplateExists("aws_elastic_beanstalk_configuration_template.tf_template", &config),
|
testAccCheckBeanstalkConfigurationTemplateExists("aws_elastic_beanstalk_configuration_template.tf_template", &config),
|
||||||
),
|
),
|
||||||
|
@ -142,18 +142,19 @@ func testAccCheckBeanstalkConfigurationTemplateExists(n string, config *elasticb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccBeanstalkConfigurationTemplateConfig = `
|
func testAccBeanstalkConfigurationTemplateConfig(r string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_elastic_beanstalk_application" "tftest" {
|
resource "aws_elastic_beanstalk_application" "tftest" {
|
||||||
name = "tf-test-name"
|
name = "tf-test-%s"
|
||||||
description = "tf-test-desc"
|
description = "tf-test-desc-%s"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_elastic_beanstalk_configuration_template" "tf_template" {
|
resource "aws_elastic_beanstalk_configuration_template" "tf_template" {
|
||||||
name = "tf-test-template-config"
|
name = "tf-test-template-config"
|
||||||
application = "${aws_elastic_beanstalk_application.tftest.name}"
|
application = "${aws_elastic_beanstalk_application.tftest.name}"
|
||||||
solution_stack_name = "64bit Amazon Linux running Python"
|
solution_stack_name = "64bit Amazon Linux running Python"
|
||||||
|
}`, r, r)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
func testAccBeanstalkConfigurationTemplateConfig_VPC(name string) string {
|
func testAccBeanstalkConfigurationTemplateConfig_VPC(name string) string {
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
|
|
Loading…
Reference in New Issue