Merge pull request #11674 from hashicorp/b-aws-test-fixes
provider/aws: More test fixing
This commit is contained in:
commit
195e668865
|
@ -92,7 +92,7 @@ func TestAccAWSDBInstance_subnetGroup(t *testing.T) {
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &v),
|
testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &v),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_db_instance.bar", "db_subnet_group_name", "foo"),
|
"aws_db_instance.bar", "db_subnet_group_name", "foo-"+rName),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,7 @@ func TestAccAWSDBInstance_subnetGroup(t *testing.T) {
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &v),
|
testAccCheckAWSDBInstanceExists("aws_db_instance.bar", &v),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_db_instance.bar", "db_subnet_group_name", "bar"),
|
"aws_db_instance.bar", "db_subnet_group_name", "bar-"+rName),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -897,7 +897,7 @@ resource "aws_subnet" "bar" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_db_subnet_group" "foo" {
|
resource "aws_db_subnet_group" "foo" {
|
||||||
name = "foo"
|
name = "foo-%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"
|
||||||
|
@ -917,8 +917,9 @@ resource "aws_db_instance" "bar" {
|
||||||
port = 3305
|
port = 3305
|
||||||
allocated_storage = 10
|
allocated_storage = 10
|
||||||
|
|
||||||
|
backup_retention_period = 0
|
||||||
apply_immediately = true
|
apply_immediately = true
|
||||||
}`, rName)
|
}`, rName, rName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testAccAWSDBInstanceConfigWithSubnetGroupUpdated(rName string) string {
|
func testAccAWSDBInstanceConfigWithSubnetGroupUpdated(rName string) string {
|
||||||
|
@ -951,7 +952,7 @@ resource "aws_subnet" "bar" {
|
||||||
|
|
||||||
resource "aws_subnet" "test" {
|
resource "aws_subnet" "test" {
|
||||||
cidr_block = "10.10.3.0/24"
|
cidr_block = "10.10.3.0/24"
|
||||||
availability_zone = "us-west-2c"
|
availability_zone = "us-west-2b"
|
||||||
vpc_id = "${aws_vpc.bar.id}"
|
vpc_id = "${aws_vpc.bar.id}"
|
||||||
tags {
|
tags {
|
||||||
Name = "tf-dbsubnet-test-3"
|
Name = "tf-dbsubnet-test-3"
|
||||||
|
@ -968,7 +969,7 @@ resource "aws_subnet" "another_test" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_db_subnet_group" "foo" {
|
resource "aws_db_subnet_group" "foo" {
|
||||||
name = "foo"
|
name = "foo-%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"
|
||||||
|
@ -976,7 +977,7 @@ resource "aws_db_subnet_group" "foo" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_db_subnet_group" "bar" {
|
resource "aws_db_subnet_group" "bar" {
|
||||||
name = "bar"
|
name = "bar-%s"
|
||||||
subnet_ids = ["${aws_subnet.test.id}", "${aws_subnet.another_test.id}"]
|
subnet_ids = ["${aws_subnet.test.id}", "${aws_subnet.another_test.id}"]
|
||||||
tags {
|
tags {
|
||||||
Name = "tf-dbsubnet-group-test-updated"
|
Name = "tf-dbsubnet-group-test-updated"
|
||||||
|
@ -996,8 +997,10 @@ resource "aws_db_instance" "bar" {
|
||||||
port = 3305
|
port = 3305
|
||||||
allocated_storage = 10
|
allocated_storage = 10
|
||||||
|
|
||||||
|
backup_retention_period = 0
|
||||||
|
|
||||||
apply_immediately = true
|
apply_immediately = true
|
||||||
}`, rName)
|
}`, rName, rName, rName)
|
||||||
}
|
}
|
||||||
|
|
||||||
const testAccAWSDBMSSQL_timezone = `
|
const testAccAWSDBMSSQL_timezone = `
|
||||||
|
|
|
@ -6,13 +6,14 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"regexp"
|
||||||
|
|
||||||
"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/elastictranscoder"
|
"github.com/aws/aws-sdk-go/service/elastictranscoder"
|
||||||
"github.com/hashicorp/terraform/helper/acctest"
|
"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"
|
||||||
"regexp"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAWSElasticTranscoderPipeline_basic(t *testing.T) {
|
func TestAccAWSElasticTranscoderPipeline_basic(t *testing.T) {
|
||||||
|
@ -37,7 +38,7 @@ func TestAccAWSElasticTranscoderPipeline_basic(t *testing.T) {
|
||||||
func TestAccAWSElasticTranscoderPipeline_kmsKey(t *testing.T) {
|
func TestAccAWSElasticTranscoderPipeline_kmsKey(t *testing.T) {
|
||||||
pipeline := &elastictranscoder.Pipeline{}
|
pipeline := &elastictranscoder.Pipeline{}
|
||||||
ri := acctest.RandInt()
|
ri := acctest.RandInt()
|
||||||
config := fmt.Sprintf(awsElasticTranscoderPipelineConfigKmsKey, ri)
|
config := fmt.Sprintf(awsElasticTranscoderPipelineConfigKmsKey, ri, ri, ri)
|
||||||
keyRegex := regexp.MustCompile("^arn:aws:([a-zA-Z0-9\\-])+:([a-z]{2}-[a-z]+-\\d{1})?:(\\d{12})?:(.*)$")
|
keyRegex := regexp.MustCompile("^arn:aws:([a-zA-Z0-9\\-])+:([a-z]{2}-[a-z]+-\\d{1})?:(\\d{12})?:(.*)$")
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
|
@ -125,6 +126,8 @@ func testAccCheckAWSElasticTranscoderPipeline_notifications(
|
||||||
func TestAccAWSElasticTranscoderPipeline_withContentConfig(t *testing.T) {
|
func TestAccAWSElasticTranscoderPipeline_withContentConfig(t *testing.T) {
|
||||||
pipeline := &elastictranscoder.Pipeline{}
|
pipeline := &elastictranscoder.Pipeline{}
|
||||||
|
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
IDRefreshName: "aws_elastictranscoder_pipeline.bar",
|
IDRefreshName: "aws_elastictranscoder_pipeline.bar",
|
||||||
|
@ -132,13 +135,13 @@ func TestAccAWSElasticTranscoderPipeline_withContentConfig(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckElasticTranscoderPipelineDestroy,
|
CheckDestroy: testAccCheckElasticTranscoderPipelineDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: awsElasticTranscoderPipelineWithContentConfig,
|
Config: awsElasticTranscoderPipelineWithContentConfig(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.bar", pipeline),
|
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.bar", pipeline),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: awsElasticTranscoderPipelineWithContentConfigUpdate,
|
Config: awsElasticTranscoderPipelineWithContentConfigUpdate(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.bar", pipeline),
|
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.bar", pipeline),
|
||||||
),
|
),
|
||||||
|
@ -150,6 +153,8 @@ func TestAccAWSElasticTranscoderPipeline_withContentConfig(t *testing.T) {
|
||||||
func TestAccAWSElasticTranscoderPipeline_withPermissions(t *testing.T) {
|
func TestAccAWSElasticTranscoderPipeline_withPermissions(t *testing.T) {
|
||||||
pipeline := &elastictranscoder.Pipeline{}
|
pipeline := &elastictranscoder.Pipeline{}
|
||||||
|
|
||||||
|
rInt := acctest.RandInt()
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
IDRefreshName: "aws_elastictranscoder_pipeline.baz",
|
IDRefreshName: "aws_elastictranscoder_pipeline.baz",
|
||||||
|
@ -157,7 +162,7 @@ func TestAccAWSElasticTranscoderPipeline_withPermissions(t *testing.T) {
|
||||||
CheckDestroy: testAccCheckElasticTranscoderPipelineDestroy,
|
CheckDestroy: testAccCheckElasticTranscoderPipelineDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: awsElasticTranscoderPipelineWithPerms,
|
Config: awsElasticTranscoderPipelineWithPerms(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.baz", pipeline),
|
testAccCheckAWSElasticTranscoderPipelineExists("aws_elastictranscoder_pipeline.baz", pipeline),
|
||||||
),
|
),
|
||||||
|
@ -289,7 +294,7 @@ resource "aws_elastictranscoder_pipeline" "bar" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_iam_role" "test_role" {
|
resource "aws_iam_role" "test_role" {
|
||||||
name = "aws_elastictranscoder_pipeline_tf_test_role_"
|
name = "tf_test_elastictranscoder_pipeline_%d"
|
||||||
|
|
||||||
assume_role_policy = <<EOF
|
assume_role_policy = <<EOF
|
||||||
{
|
{
|
||||||
|
@ -309,15 +314,16 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_s3_bucket" "test_bucket" {
|
resource "aws_s3_bucket" "test_bucket" {
|
||||||
bucket = "aws-elasticencoder-pipeline-tf-test-bucket"
|
bucket = "tf-test-aws-elasticencoder-pipeline-%d"
|
||||||
acl = "private"
|
acl = "private"
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const awsElasticTranscoderPipelineWithContentConfig = `
|
func awsElasticTranscoderPipelineWithContentConfig(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_elastictranscoder_pipeline" "bar" {
|
resource "aws_elastictranscoder_pipeline" "bar" {
|
||||||
input_bucket = "${aws_s3_bucket.content_bucket.bucket}"
|
input_bucket = "${aws_s3_bucket.content_bucket.bucket}"
|
||||||
name = "aws_elastictranscoder_pipeline_tf_test_"
|
name = "tf_test_pipeline_%d"
|
||||||
role = "${aws_iam_role.test_role.arn}"
|
role = "${aws_iam_role.test_role.arn}"
|
||||||
|
|
||||||
content_config {
|
content_config {
|
||||||
|
@ -332,7 +338,7 @@ resource "aws_elastictranscoder_pipeline" "bar" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_iam_role" "test_role" {
|
resource "aws_iam_role" "test_role" {
|
||||||
name = "aws_elastictranscoder_pipeline_tf_test_role_"
|
name = "tf_pipeline_role_%d"
|
||||||
|
|
||||||
assume_role_policy = <<EOF
|
assume_role_policy = <<EOF
|
||||||
{
|
{
|
||||||
|
@ -352,25 +358,26 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_s3_bucket" "content_bucket" {
|
resource "aws_s3_bucket" "content_bucket" {
|
||||||
bucket = "aws-elasticencoder-pipeline-tf-content-bucket"
|
bucket = "tf-pipeline-content-%d"
|
||||||
acl = "private"
|
acl = "private"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_s3_bucket" "input_bucket" {
|
resource "aws_s3_bucket" "input_bucket" {
|
||||||
bucket = "aws-elasticencoder-pipeline-tf-input-bucket"
|
bucket = "tf-pipeline-input-%d"
|
||||||
acl = "private"
|
acl = "private"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_s3_bucket" "thumb_bucket" {
|
resource "aws_s3_bucket" "thumb_bucket" {
|
||||||
bucket = "aws-elasticencoder-pipeline-tf-thumb-bucket"
|
bucket = "tf-pipeline-thumb-%d"
|
||||||
acl = "private"
|
acl = "private"
|
||||||
|
}`, rInt, rInt, rInt, rInt, rInt)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
const awsElasticTranscoderPipelineWithContentConfigUpdate = `
|
func awsElasticTranscoderPipelineWithContentConfigUpdate(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_elastictranscoder_pipeline" "bar" {
|
resource "aws_elastictranscoder_pipeline" "bar" {
|
||||||
input_bucket = "${aws_s3_bucket.input_bucket.bucket}"
|
input_bucket = "${aws_s3_bucket.input_bucket.bucket}"
|
||||||
name = "aws_elastictranscoder_pipeline_tf_test_"
|
name = "tf_test_pipeline_%d"
|
||||||
role = "${aws_iam_role.test_role.arn}"
|
role = "${aws_iam_role.test_role.arn}"
|
||||||
|
|
||||||
content_config {
|
content_config {
|
||||||
|
@ -385,7 +392,7 @@ resource "aws_elastictranscoder_pipeline" "bar" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_iam_role" "test_role" {
|
resource "aws_iam_role" "test_role" {
|
||||||
name = "aws_elastictranscoder_pipeline_tf_test_role_"
|
name = "tf_pipeline_role_%d"
|
||||||
|
|
||||||
assume_role_policy = <<EOF
|
assume_role_policy = <<EOF
|
||||||
{
|
{
|
||||||
|
@ -405,25 +412,26 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_s3_bucket" "content_bucket" {
|
resource "aws_s3_bucket" "content_bucket" {
|
||||||
bucket = "aws-elasticencoder-pipeline-tf-content-bucket"
|
bucket = "tf-pipeline-content-%d"
|
||||||
acl = "private"
|
acl = "private"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_s3_bucket" "input_bucket" {
|
resource "aws_s3_bucket" "input_bucket" {
|
||||||
bucket = "aws-elasticencoder-pipeline-tf-input-bucket"
|
bucket = "tf-pipeline-input-%d"
|
||||||
acl = "private"
|
acl = "private"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_s3_bucket" "thumb_bucket" {
|
resource "aws_s3_bucket" "thumb_bucket" {
|
||||||
bucket = "aws-elasticencoder-pipeline-tf-thumb-bucket"
|
bucket = "tf-pipeline-thumb-%d"
|
||||||
acl = "private"
|
acl = "private"
|
||||||
|
}`, rInt, rInt, rInt, rInt, rInt)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
const awsElasticTranscoderPipelineWithPerms = `
|
func awsElasticTranscoderPipelineWithPerms(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_elastictranscoder_pipeline" "baz" {
|
resource "aws_elastictranscoder_pipeline" "baz" {
|
||||||
input_bucket = "${aws_s3_bucket.content_bucket.bucket}"
|
input_bucket = "${aws_s3_bucket.content_bucket.bucket}"
|
||||||
name = "aws_elastictranscoder_pipeline_tf_test_"
|
name = "tf_test_pipeline_%d"
|
||||||
role = "${aws_iam_role.test_role.arn}"
|
role = "${aws_iam_role.test_role.arn}"
|
||||||
|
|
||||||
content_config {
|
content_config {
|
||||||
|
@ -450,7 +458,7 @@ resource "aws_elastictranscoder_pipeline" "baz" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_iam_role" "test_role" {
|
resource "aws_iam_role" "test_role" {
|
||||||
name = "aws_elastictranscoder_pipeline_tf_test_role_"
|
name = "tf_pipeline_role_%d"
|
||||||
|
|
||||||
assume_role_policy = <<EOF
|
assume_role_policy = <<EOF
|
||||||
{
|
{
|
||||||
|
@ -470,10 +478,10 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_s3_bucket" "content_bucket" {
|
resource "aws_s3_bucket" "content_bucket" {
|
||||||
bucket = "aws-elasticencoder-pipeline-tf-content-bucket"
|
bucket = "tf-transcoding-pipe-%d"
|
||||||
acl = "private"
|
acl = "private"
|
||||||
|
}`, rInt, rInt, rInt)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
func awsElasticTranscoderNotifications(r int) string {
|
func awsElasticTranscoderNotifications(r int) string {
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
|
|
Loading…
Reference in New Issue