forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hashicorp#3707 from loivis/validatefunc/key_pair
resource/key_pair: drop custom ValidateFunc for name_prefix
- Loading branch information
Showing
2 changed files
with
20 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ func testSweepKeyPairs(region string) error { | |
|
||
resp, err := ec2conn.DescribeKeyPairs(&ec2.DescribeKeyPairsInput{ | ||
Filters: []*ec2.Filter{ | ||
&ec2.Filter{ | ||
{ | ||
Name: aws.String("key-name"), | ||
Values: []*string{aws.String("tmp-key*")}, | ||
}, | ||
|
@@ -62,7 +62,7 @@ func TestAccAWSKeyPair_basic(t *testing.T) { | |
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAWSKeyPairDestroy, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
{ | ||
Config: testAccAWSKeyPairConfig, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSKeyPairExists("aws_key_pair.a_key_pair", &conf), | ||
|
@@ -81,7 +81,7 @@ func TestAccAWSKeyPair_generatedName(t *testing.T) { | |
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAWSKeyPairDestroy, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
{ | ||
Config: testAccAWSKeyPairConfig_generatedName, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSKeyPairExists("aws_key_pair.a_key_pair", &conf), | ||
|
@@ -182,20 +182,18 @@ func testAccCheckAWSKeyPair_namePrefix(t *testing.T) { | |
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAWSKeyPairDestroy, | ||
Steps: []resource.TestStep{ | ||
resource.TestStep{ | ||
{ | ||
Config: testAccCheckAWSKeyPairPrefixNameConfig, | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSKeyPairExists("aws_key_pair.a_key_pair", &conf), | ||
testAccCheckAWSKeyPairGeneratedNamePrefix( | ||
"aws_key_pair.a_key_pair", "baz-"), | ||
testAccCheckAWSKeyPairGeneratedNamePrefix("aws_key_pair.a_key_pair", "baz-"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckAWSKeyPairGeneratedNamePrefix( | ||
resource, prefix string) resource.TestCheckFunc { | ||
func testAccCheckAWSKeyPairGeneratedNamePrefix(resource, prefix string) resource.TestCheckFunc { | ||
return func(s *terraform.State) error { | ||
r, ok := s.RootModule().Resources[resource] | ||
if !ok { | ||
|
@@ -214,20 +212,20 @@ func testAccCheckAWSKeyPairGeneratedNamePrefix( | |
|
||
const testAccAWSKeyPairConfig = ` | ||
resource "aws_key_pair" "a_key_pair" { | ||
key_name = "tf-acc-key-pair" | ||
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]" | ||
key_name = "tf-acc-key-pair" | ||
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]" | ||
} | ||
` | ||
|
||
const testAccAWSKeyPairConfig_generatedName = ` | ||
resource "aws_key_pair" "a_key_pair" { | ||
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]" | ||
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]" | ||
} | ||
` | ||
|
||
const testAccCheckAWSKeyPairPrefixNameConfig = ` | ||
resource "aws_key_pair" "a_key_pair" { | ||
key_name_prefix = "baz-" | ||
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]" | ||
key_name_prefix = "baz-" | ||
public_key = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 [email protected]" | ||
} | ||
` |