diff --git a/builtin/providers/aws/resource_aws_autoscaling_group_test.go b/builtin/providers/aws/resource_aws_autoscaling_group_test.go index bb23f570a..ed4d559ba 100644 --- a/builtin/providers/aws/resource_aws_autoscaling_group_test.go +++ b/builtin/providers/aws/resource_aws_autoscaling_group_test.go @@ -240,7 +240,7 @@ func TestAccAWSAutoScalingGroup_withPlacementGroup(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckAWSAutoScalingGroupExists("aws_autoscaling_group.bar", &group), resource.TestCheckResourceAttr( - "aws_autoscaling_group.bar", "placement_group", "test"), + "aws_autoscaling_group.bar", "placement_group", "tf_placement_test"), ), }, }, @@ -751,11 +751,11 @@ resource "aws_autoscaling_group" "bar" { const testAccAWSAutoScalingGroupConfig_withPlacementGroup = ` resource "aws_launch_configuration" "foobar" { image_id = "ami-21f78e11" - instance_type = "t2.micro" + instance_type = "c3.large" } resource "aws_placement_group" "test" { - name = "test" + name = "tf_placement_test" strategy = "cluster" } diff --git a/builtin/providers/aws/resource_aws_dynamodb_table_test.go b/builtin/providers/aws/resource_aws_dynamodb_table_test.go index 114837ce3..044497303 100644 --- a/builtin/providers/aws/resource_aws_dynamodb_table_test.go +++ b/builtin/providers/aws/resource_aws_dynamodb_table_test.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/dynamodb" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) @@ -19,7 +20,7 @@ func TestAccAWSDynamoDbTable_basic(t *testing.T) { CheckDestroy: testAccCheckAWSDynamoDbTableDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccAWSDynamoDbConfigInitialState, + Config: testAccAWSDynamoDbConfigInitialState(), Check: resource.ComposeTestCheckFunc( testAccCheckInitialAWSDynamoDbTableExists("aws_dynamodb_table.basic-dynamodb-table"), ), @@ -41,7 +42,7 @@ func TestAccAWSDynamoDbTable_streamSpecification(t *testing.T) { CheckDestroy: testAccCheckAWSDynamoDbTableDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccAWSDynamoDbConfigStreamSpecification, + Config: testAccAWSDynamoDbConfigStreamSpecification(), Check: resource.ComposeTestCheckFunc( testAccCheckInitialAWSDynamoDbTableExists("aws_dynamodb_table.basic-dynamodb-table"), resource.TestCheckResourceAttr( @@ -280,9 +281,10 @@ func dynamoDbAttributesToMap(attributes *[]*dynamodb.AttributeDefinition) map[st return attrmap } -const testAccAWSDynamoDbConfigInitialState = ` +func testAccAWSDynamoDbConfigInitialState() string { + return fmt.Sprintf(` resource "aws_dynamodb_table" "basic-dynamodb-table" { - name = "TerraformTestTable" + name = "TerraformTestTable-%d" read_capacity = 10 write_capacity = 20 hash_key = "TestTableHashKey" @@ -317,7 +319,8 @@ resource "aws_dynamodb_table" "basic-dynamodb-table" { projection_type = "KEYS_ONLY" } } -` +`, acctest.RandInt()) +} const testAccAWSDynamoDbConfigAddSecondaryGSI = ` resource "aws_dynamodb_table" "basic-dynamodb-table" { @@ -359,9 +362,10 @@ resource "aws_dynamodb_table" "basic-dynamodb-table" { } ` -const testAccAWSDynamoDbConfigStreamSpecification = ` +func testAccAWSDynamoDbConfigStreamSpecification() string { + return fmt.Sprintf(` resource "aws_dynamodb_table" "basic-dynamodb-table" { - name = "TerraformTestStreamTable" + name = "TerraformTestStreamTable-%d" read_capacity = 10 write_capacity = 20 hash_key = "TestTableHashKey" @@ -398,4 +402,5 @@ resource "aws_dynamodb_table" "basic-dynamodb-table" { stream_enabled = true stream_view_type = "KEYS_ONLY" } -` +`, acctest.RandInt()) +} diff --git a/builtin/providers/aws/resource_aws_elb_test.go b/builtin/providers/aws/resource_aws_elb_test.go index eae4138dd..c925388cb 100644 --- a/builtin/providers/aws/resource_aws_elb_test.go +++ b/builtin/providers/aws/resource_aws_elb_test.go @@ -1050,6 +1050,10 @@ resource "aws_security_group" "bar" { to_port = 80 cidr_blocks = ["0.0.0.0/0"] } + + tags { + Name = "tf_elb_sg_test" + } } ` diff --git a/builtin/providers/aws/resource_aws_iam_role_policy_test.go b/builtin/providers/aws/resource_aws_iam_role_policy_test.go index 3f3256435..da063673c 100644 --- a/builtin/providers/aws/resource_aws_iam_role_policy_test.go +++ b/builtin/providers/aws/resource_aws_iam_role_policy_test.go @@ -7,18 +7,23 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/iam" + "github.com/hashicorp/terraform/helper/acctest" "github.com/hashicorp/terraform/helper/resource" "github.com/hashicorp/terraform/terraform" ) func TestAccAWSIAMRolePolicy_basic(t *testing.T) { + role := acctest.RandString(10) + policy1 := acctest.RandString(10) + policy2 := acctest.RandString(10) + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckIAMRolePolicyDestroy, Steps: []resource.TestStep{ resource.TestStep{ - Config: testAccIAMRolePolicyConfig, + Config: testAccIAMRolePolicyConfig(role, policy1), Check: resource.ComposeTestCheckFunc( testAccCheckIAMRolePolicy( "aws_iam_role.role", @@ -27,7 +32,7 @@ func TestAccAWSIAMRolePolicy_basic(t *testing.T) { ), }, resource.TestStep{ - Config: testAccIAMRolePolicyConfigUpdate, + Config: testAccIAMRolePolicyConfigUpdate(role, policy1, policy2), Check: resource.ComposeTestCheckFunc( testAccCheckIAMRolePolicy( "aws_iam_role.role", @@ -105,36 +110,40 @@ func testAccCheckIAMRolePolicy( } } -const testAccIAMRolePolicyConfig = ` +func testAccIAMRolePolicyConfig(role, policy1 string) string { + return fmt.Sprintf(` resource "aws_iam_role" "role" { - name = "test_role" + name = "tf_test_role_%s" path = "/" assume_role_policy = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Effect\":\"Allow\",\"Sid\":\"\"}]}" } resource "aws_iam_role_policy" "foo" { - name = "foo_policy" + name = "tf_test_policy_%s" role = "${aws_iam_role.role.name}" policy = "{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"*\",\"Resource\":\"*\"}}" } -` +`, role, policy1) +} -const testAccIAMRolePolicyConfigUpdate = ` +func testAccIAMRolePolicyConfigUpdate(role, policy1, policy2 string) string { + return fmt.Sprintf(` resource "aws_iam_role" "role" { - name = "test_role" + name = "tf_test_role_%s" path = "/" assume_role_policy = "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Action\":\"sts:AssumeRole\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Effect\":\"Allow\",\"Sid\":\"\"}]}" } resource "aws_iam_role_policy" "foo" { - name = "foo_policy" + name = "tf_test_policy_%s" role = "${aws_iam_role.role.name}" policy = "{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"*\",\"Resource\":\"*\"}}" } resource "aws_iam_role_policy" "bar" { - name = "bar_policy" + name = "tf_test_policy_2_%s" role = "${aws_iam_role.role.name}" policy = "{\"Version\":\"2012-10-17\",\"Statement\":{\"Effect\":\"Allow\",\"Action\":\"*\",\"Resource\":\"*\"}}" } -` +`, role, policy1, policy2) +}