provider/aws: Randomize key pair name for EC2 instance test (#14389)
This commit is contained in:
parent
2aa7faa38c
commit
145fa084f9
|
@ -860,6 +860,8 @@ func TestAccAWSInstance_keyPairCheck(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
keyPairName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(5))
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
IDRefreshName: "aws_instance.foo",
|
||||
|
@ -868,10 +870,10 @@ func TestAccAWSInstance_keyPairCheck(t *testing.T) {
|
|||
CheckDestroy: testAccCheckInstanceDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: testAccInstanceConfigKeyPair,
|
||||
Config: testAccInstanceConfigKeyPair(keyPairName),
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckInstanceExists("aws_instance.foo", &v),
|
||||
testCheckKeyPair("tmp-key"),
|
||||
testCheckKeyPair(keyPairName),
|
||||
),
|
||||
},
|
||||
},
|
||||
|
@ -1852,13 +1854,14 @@ resource "aws_eip" "foo_eip" {
|
|||
}
|
||||
`
|
||||
|
||||
const testAccInstanceConfigKeyPair = `
|
||||
func testAccInstanceConfigKeyPair(keyPairName 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"
|
||||
}
|
||||
|
||||
|
@ -1870,7 +1873,8 @@ resource "aws_instance" "foo" {
|
|||
Name = "testAccInstanceConfigKeyPair_TestAMI"
|
||||
}
|
||||
}
|
||||
`
|
||||
`, keyPairName)
|
||||
}
|
||||
|
||||
const testAccInstanceConfigRootBlockDeviceMismatch = `
|
||||
resource "aws_vpc" "foo" {
|
||||
|
|
Loading…
Reference in New Issue