Skip to content

Commit

Permalink
Merge pull request #14588 from terraform-providers/t-012-syntax-and-f…
Browse files Browse the repository at this point in the history
…mt-iam

tests/provider: Update resource testing to 0.12 syntax (IAM Resources)
  • Loading branch information
YakDriver authored Aug 17, 2020
2 parents d8f2464 + 62ced4f commit de560b7
Show file tree
Hide file tree
Showing 19 changed files with 811 additions and 504 deletions.
8 changes: 5 additions & 3 deletions aws/resource_aws_iam_access_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ resource "aws_iam_user" "a_user" {
}
resource "aws_iam_access_key" "a_key" {
user = "${aws_iam_user.a_user.name}"
user = aws_iam_user.a_user.name
}
`, rName)
}
Expand All @@ -212,11 +212,13 @@ resource "aws_iam_user" "a_user" {
}
resource "aws_iam_access_key" "a_key" {
user = "${aws_iam_user.a_user.name}"
user = aws_iam_user.a_user.name
pgp_key = <<EOF
%s
EOF
}
`, rName, key)
}
Expand All @@ -228,7 +230,7 @@ resource "aws_iam_user" "a_user" {
}
resource "aws_iam_access_key" "a_key" {
user = "${aws_iam_user.a_user.name}"
user = aws_iam_user.a_user.name
status = "Inactive"
}
`, rName)
Expand Down
17 changes: 9 additions & 8 deletions aws/resource_aws_iam_account_password_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,18 @@ func testAccCheckAWSIAMAccountPasswordPolicyExists(n string, res *iam.GetAccount

const testAccAWSIAMAccountPasswordPolicy = `
resource "aws_iam_account_password_policy" "test" {
allow_users_to_change_password = true
minimum_password_length = 8
require_numbers = true
allow_users_to_change_password = true
minimum_password_length = 8
require_numbers = true
}
`

const testAccAWSIAMAccountPasswordPolicy_modified = `
resource "aws_iam_account_password_policy" "test" {
allow_users_to_change_password = true
minimum_password_length = 7
require_numbers = false
require_symbols = true
require_uppercase_characters = true
allow_users_to_change_password = true
minimum_password_length = 7
require_numbers = false
require_symbols = true
require_uppercase_characters = true
}
`
220 changes: 110 additions & 110 deletions aws/resource_aws_iam_group_membership_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ resource "aws_iam_user" "user" {
resource "aws_iam_group_membership" "team" {
name = "%s"
users = ["${aws_iam_user.user.name}"]
group = "${aws_iam_group.group.name}"
users = [aws_iam_user.user.name]
group = aws_iam_group.group.name
}
`, groupName, userName, membershipName)
}
Expand All @@ -197,11 +197,11 @@ resource "aws_iam_group_membership" "team" {
name = "%s"
users = [
"${aws_iam_user.user_two.name}",
"${aws_iam_user.user_three.name}",
aws_iam_user.user_two.name,
aws_iam_user.user_three.name,
]
group = "${aws_iam_group.group.name}"
group = aws_iam_group.group.name
}
`, groupName, userName, userName2, userName3, membershipName)
}
Expand All @@ -220,10 +220,10 @@ resource "aws_iam_group_membership" "team" {
name = "%s"
users = [
"${aws_iam_user.user_three.name}",
aws_iam_user.user_three.name,
]
group = "${aws_iam_group.group.name}"
group = aws_iam_group.group.name
}
`, groupName, userName3, membershipName)
}
Expand All @@ -236,117 +236,117 @@ resource "aws_iam_group" "group" {
resource "aws_iam_group_membership" "team" {
name = "%s"
group = "${aws_iam_group.group.name}"
group = aws_iam_group.group.name
# TODO: Switch back to simple list reference when test configurations are upgraded to 0.12 syntax
users = [
"${aws_iam_user.user.*.name[0]}",
"${aws_iam_user.user.*.name[1]}",
"${aws_iam_user.user.*.name[2]}",
"${aws_iam_user.user.*.name[3]}",
"${aws_iam_user.user.*.name[4]}",
"${aws_iam_user.user.*.name[5]}",
"${aws_iam_user.user.*.name[6]}",
"${aws_iam_user.user.*.name[7]}",
"${aws_iam_user.user.*.name[8]}",
"${aws_iam_user.user.*.name[9]}",
"${aws_iam_user.user.*.name[10]}",
"${aws_iam_user.user.*.name[11]}",
"${aws_iam_user.user.*.name[12]}",
"${aws_iam_user.user.*.name[13]}",
"${aws_iam_user.user.*.name[14]}",
"${aws_iam_user.user.*.name[15]}",
"${aws_iam_user.user.*.name[16]}",
"${aws_iam_user.user.*.name[17]}",
"${aws_iam_user.user.*.name[18]}",
"${aws_iam_user.user.*.name[19]}",
"${aws_iam_user.user.*.name[20]}",
"${aws_iam_user.user.*.name[21]}",
"${aws_iam_user.user.*.name[22]}",
"${aws_iam_user.user.*.name[23]}",
"${aws_iam_user.user.*.name[24]}",
"${aws_iam_user.user.*.name[25]}",
"${aws_iam_user.user.*.name[26]}",
"${aws_iam_user.user.*.name[27]}",
"${aws_iam_user.user.*.name[28]}",
"${aws_iam_user.user.*.name[29]}",
"${aws_iam_user.user.*.name[30]}",
"${aws_iam_user.user.*.name[31]}",
"${aws_iam_user.user.*.name[32]}",
"${aws_iam_user.user.*.name[33]}",
"${aws_iam_user.user.*.name[34]}",
"${aws_iam_user.user.*.name[35]}",
"${aws_iam_user.user.*.name[36]}",
"${aws_iam_user.user.*.name[37]}",
"${aws_iam_user.user.*.name[38]}",
"${aws_iam_user.user.*.name[39]}",
"${aws_iam_user.user.*.name[40]}",
"${aws_iam_user.user.*.name[41]}",
"${aws_iam_user.user.*.name[42]}",
"${aws_iam_user.user.*.name[43]}",
"${aws_iam_user.user.*.name[44]}",
"${aws_iam_user.user.*.name[45]}",
"${aws_iam_user.user.*.name[46]}",
"${aws_iam_user.user.*.name[47]}",
"${aws_iam_user.user.*.name[48]}",
"${aws_iam_user.user.*.name[49]}",
"${aws_iam_user.user.*.name[50]}",
"${aws_iam_user.user.*.name[51]}",
"${aws_iam_user.user.*.name[52]}",
"${aws_iam_user.user.*.name[53]}",
"${aws_iam_user.user.*.name[54]}",
"${aws_iam_user.user.*.name[55]}",
"${aws_iam_user.user.*.name[56]}",
"${aws_iam_user.user.*.name[57]}",
"${aws_iam_user.user.*.name[58]}",
"${aws_iam_user.user.*.name[59]}",
"${aws_iam_user.user.*.name[60]}",
"${aws_iam_user.user.*.name[61]}",
"${aws_iam_user.user.*.name[62]}",
"${aws_iam_user.user.*.name[63]}",
"${aws_iam_user.user.*.name[64]}",
"${aws_iam_user.user.*.name[65]}",
"${aws_iam_user.user.*.name[66]}",
"${aws_iam_user.user.*.name[67]}",
"${aws_iam_user.user.*.name[68]}",
"${aws_iam_user.user.*.name[69]}",
"${aws_iam_user.user.*.name[70]}",
"${aws_iam_user.user.*.name[71]}",
"${aws_iam_user.user.*.name[72]}",
"${aws_iam_user.user.*.name[73]}",
"${aws_iam_user.user.*.name[74]}",
"${aws_iam_user.user.*.name[75]}",
"${aws_iam_user.user.*.name[76]}",
"${aws_iam_user.user.*.name[77]}",
"${aws_iam_user.user.*.name[78]}",
"${aws_iam_user.user.*.name[79]}",
"${aws_iam_user.user.*.name[80]}",
"${aws_iam_user.user.*.name[81]}",
"${aws_iam_user.user.*.name[82]}",
"${aws_iam_user.user.*.name[83]}",
"${aws_iam_user.user.*.name[84]}",
"${aws_iam_user.user.*.name[85]}",
"${aws_iam_user.user.*.name[86]}",
"${aws_iam_user.user.*.name[87]}",
"${aws_iam_user.user.*.name[88]}",
"${aws_iam_user.user.*.name[89]}",
"${aws_iam_user.user.*.name[90]}",
"${aws_iam_user.user.*.name[91]}",
"${aws_iam_user.user.*.name[92]}",
"${aws_iam_user.user.*.name[93]}",
"${aws_iam_user.user.*.name[94]}",
"${aws_iam_user.user.*.name[95]}",
"${aws_iam_user.user.*.name[96]}",
"${aws_iam_user.user.*.name[97]}",
"${aws_iam_user.user.*.name[98]}",
"${aws_iam_user.user.*.name[99]}",
"${aws_iam_user.user.*.name[100]}",
aws_iam_user.user[0].name,
aws_iam_user.user[1].name,
aws_iam_user.user[2].name,
aws_iam_user.user[3].name,
aws_iam_user.user[4].name,
aws_iam_user.user[5].name,
aws_iam_user.user[6].name,
aws_iam_user.user[7].name,
aws_iam_user.user[8].name,
aws_iam_user.user[9].name,
aws_iam_user.user[10].name,
aws_iam_user.user[11].name,
aws_iam_user.user[12].name,
aws_iam_user.user[13].name,
aws_iam_user.user[14].name,
aws_iam_user.user[15].name,
aws_iam_user.user[16].name,
aws_iam_user.user[17].name,
aws_iam_user.user[18].name,
aws_iam_user.user[19].name,
aws_iam_user.user[20].name,
aws_iam_user.user[21].name,
aws_iam_user.user[22].name,
aws_iam_user.user[23].name,
aws_iam_user.user[24].name,
aws_iam_user.user[25].name,
aws_iam_user.user[26].name,
aws_iam_user.user[27].name,
aws_iam_user.user[28].name,
aws_iam_user.user[29].name,
aws_iam_user.user[30].name,
aws_iam_user.user[31].name,
aws_iam_user.user[32].name,
aws_iam_user.user[33].name,
aws_iam_user.user[34].name,
aws_iam_user.user[35].name,
aws_iam_user.user[36].name,
aws_iam_user.user[37].name,
aws_iam_user.user[38].name,
aws_iam_user.user[39].name,
aws_iam_user.user[40].name,
aws_iam_user.user[41].name,
aws_iam_user.user[42].name,
aws_iam_user.user[43].name,
aws_iam_user.user[44].name,
aws_iam_user.user[45].name,
aws_iam_user.user[46].name,
aws_iam_user.user[47].name,
aws_iam_user.user[48].name,
aws_iam_user.user[49].name,
aws_iam_user.user[50].name,
aws_iam_user.user[51].name,
aws_iam_user.user[52].name,
aws_iam_user.user[53].name,
aws_iam_user.user[54].name,
aws_iam_user.user[55].name,
aws_iam_user.user[56].name,
aws_iam_user.user[57].name,
aws_iam_user.user[58].name,
aws_iam_user.user[59].name,
aws_iam_user.user[60].name,
aws_iam_user.user[61].name,
aws_iam_user.user[62].name,
aws_iam_user.user[63].name,
aws_iam_user.user[64].name,
aws_iam_user.user[65].name,
aws_iam_user.user[66].name,
aws_iam_user.user[67].name,
aws_iam_user.user[68].name,
aws_iam_user.user[69].name,
aws_iam_user.user[70].name,
aws_iam_user.user[71].name,
aws_iam_user.user[72].name,
aws_iam_user.user[73].name,
aws_iam_user.user[74].name,
aws_iam_user.user[75].name,
aws_iam_user.user[76].name,
aws_iam_user.user[77].name,
aws_iam_user.user[78].name,
aws_iam_user.user[79].name,
aws_iam_user.user[80].name,
aws_iam_user.user[81].name,
aws_iam_user.user[82].name,
aws_iam_user.user[83].name,
aws_iam_user.user[84].name,
aws_iam_user.user[85].name,
aws_iam_user.user[86].name,
aws_iam_user.user[87].name,
aws_iam_user.user[88].name,
aws_iam_user.user[89].name,
aws_iam_user.user[90].name,
aws_iam_user.user[91].name,
aws_iam_user.user[92].name,
aws_iam_user.user[93].name,
aws_iam_user.user[94].name,
aws_iam_user.user[95].name,
aws_iam_user.user[96].name,
aws_iam_user.user[97].name,
aws_iam_user.user[98].name,
aws_iam_user.user[99].name,
aws_iam_user.user[100].name,
]
}
resource "aws_iam_user" "user" {
count = 101
name = "${format("%s%%d", count.index + 1)}"
name = format("%s%%d", count.index + 1)
}
`, groupName, membershipName, userNamePrefix)
}
16 changes: 10 additions & 6 deletions aws/resource_aws_iam_group_policy_attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ resource "aws_iam_policy" "policy" {
]
}
EOF
}
resource "aws_iam_group_policy_attachment" "test-attach" {
group = "${aws_iam_group.group.name}"
policy_arn = "${aws_iam_policy.policy.arn}"
group = aws_iam_group.group.name
policy_arn = aws_iam_policy.policy.arn
}
`, groupName, policyName)
}
Expand Down Expand Up @@ -170,6 +171,7 @@ resource "aws_iam_policy" "policy" {
]
}
EOF
}
resource "aws_iam_policy" "policy2" {
Expand All @@ -190,6 +192,7 @@ resource "aws_iam_policy" "policy2" {
]
}
EOF
}
resource "aws_iam_policy" "policy3" {
Expand All @@ -210,16 +213,17 @@ resource "aws_iam_policy" "policy3" {
]
}
EOF
}
resource "aws_iam_group_policy_attachment" "test-attach" {
group = "${aws_iam_group.group.name}"
policy_arn = "${aws_iam_policy.policy2.arn}"
group = aws_iam_group.group.name
policy_arn = aws_iam_policy.policy2.arn
}
resource "aws_iam_group_policy_attachment" "test-attach2" {
group = "${aws_iam_group.group.name}"
policy_arn = "${aws_iam_policy.policy3.arn}"
group = aws_iam_group.group.name
policy_arn = aws_iam_policy.policy3.arn
}
`, groupName, policyName, policyName2, policyName3)
}
Expand Down
Loading

0 comments on commit de560b7

Please sign in to comment.