diff --git a/builtin/providers/aws/data_source_aws_instance_test.go b/builtin/providers/aws/data_source_aws_instance_test.go index 1f5bb21a33..48323436f4 100644 --- a/builtin/providers/aws/data_source_aws_instance_test.go +++ b/builtin/providers/aws/data_source_aws_instance_test.go @@ -173,12 +173,13 @@ func TestAccAWSInstanceDataSource_privateIP(t *testing.T) { } func TestAccAWSInstanceDataSource_keyPair(t *testing.T) { + rName := fmt.Sprintf("tf-test-key-%d", acctest.RandInt()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccInstanceDataSourceConfig_keyPair, + Config: testAccInstanceDataSourceConfig_keyPair(rName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "data.aws_instance.foo", "ami", "ami-408c7f28"), @@ -187,7 +188,7 @@ func TestAccAWSInstanceDataSource_keyPair(t *testing.T) { resource.TestCheckResourceAttr( "data.aws_instance.foo", "tags.#", "1"), resource.TestCheckResourceAttr( - "data.aws_instance.foo", "key_name", "tmp-key"), + "data.aws_instance.foo", "key_name", rName), ), }, }, @@ -415,13 +416,14 @@ data "aws_instance" "foo" { } ` -const testAccInstanceDataSourceConfig_keyPair = ` +func testAccInstanceDataSourceConfig_keyPair(rName string) string { + return fmt.Sprintf(` provider "aws" { region = "us-east-1" } resource "aws_key_pair" "debugging" { - key_name = "tmp-key" + key_name = "%s" public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 phodgson@thoughtworks.com" } @@ -443,8 +445,8 @@ data "aws_instance" "foo" { name = "key-name" values = ["${aws_instance.foo.key_name}"] } +}`, rName) } -` const testAccInstanceDataSourceConfig_VPC = ` resource "aws_vpc" "foo" {