Skip to content

Commit

Permalink
tests/provider: Update resource testing to 0.12 syntax (Sec/Ser Resou…
Browse files Browse the repository at this point in the history
…rces)
  • Loading branch information
YakDriver committed Aug 17, 2020
1 parent 6a468af commit 13ba0ef
Show file tree
Hide file tree
Showing 8 changed files with 697 additions and 642 deletions.
30 changes: 15 additions & 15 deletions aws/resource_aws_secretsmanager_secret_rotation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,46 +124,46 @@ resource "aws_lambda_function" "test1" {
filename = "test-fixtures/lambdatest.zip"
function_name = "%[1]s-1"
handler = "exports.example"
role = "${aws_iam_role.iam_for_lambda.arn}"
role = aws_iam_role.iam_for_lambda.arn
runtime = "nodejs12.x"
}
resource "aws_lambda_permission" "test1" {
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.test1.function_name}"
principal = "secretsmanager.amazonaws.com"
statement_id = "AllowExecutionFromSecretsManager1"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.test1.function_name
principal = "secretsmanager.amazonaws.com"
statement_id = "AllowExecutionFromSecretsManager1"
}
# Not a real rotation function
resource "aws_lambda_function" "test2" {
filename = "test-fixtures/lambdatest.zip"
function_name = "%[1]s-2"
handler = "exports.example"
role = "${aws_iam_role.iam_for_lambda.arn}"
role = aws_iam_role.iam_for_lambda.arn
runtime = "nodejs12.x"
}
resource "aws_lambda_permission" "test2" {
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.test2.function_name}"
principal = "secretsmanager.amazonaws.com"
statement_id = "AllowExecutionFromSecretsManager2"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.test2.function_name
principal = "secretsmanager.amazonaws.com"
statement_id = "AllowExecutionFromSecretsManager2"
}
resource "aws_secretsmanager_secret" "test" {
name = "%[1]s"
}
resource "aws_secretsmanager_secret_rotation" "test" {
secret_id = "${aws_secretsmanager_secret.test.id}"
rotation_lambda_arn = "${aws_lambda_function.test1.arn}"
secret_id = aws_secretsmanager_secret.test.id
rotation_lambda_arn = aws_lambda_function.test1.arn
rotation_rules {
rotation_rules {
automatically_after_days = %[2]d
}
}
depends_on = [aws_lambda_permission.test1]
depends_on = [aws_lambda_permission.test1]
}
`, rName, automaticallyAfterDays)
}
62 changes: 32 additions & 30 deletions aws/resource_aws_secretsmanager_secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ resource "aws_kms_key" "test2" {
}
resource "aws_secretsmanager_secret" "test" {
kms_key_id = "${aws_kms_key.test1.id}"
kms_key_id = aws_kms_key.test1.id
name = "%s"
}
`, rName)
Expand All @@ -572,7 +572,7 @@ resource "aws_kms_key" "test2" {
}
resource "aws_secretsmanager_secret" "test" {
kms_key_id = "${aws_kms_key.test2.id}"
kms_key_id = aws_kms_key.test2.id
name = "%s"
}
`, rName)
Expand All @@ -591,7 +591,7 @@ func testAccAwsSecretsManagerSecretConfig_RotationLambdaARN(rName string) string
return baseAccAWSLambdaConfig(rName, rName, rName) + fmt.Sprintf(`
resource "aws_secretsmanager_secret" "test" {
name = "%[1]s"
rotation_lambda_arn = "${aws_lambda_function.test1.arn}"
rotation_lambda_arn = aws_lambda_function.test1.arn
depends_on = [aws_lambda_permission.test1]
}
Expand All @@ -601,31 +601,31 @@ resource "aws_lambda_function" "test1" {
filename = "test-fixtures/lambdatest.zip"
function_name = "%[1]s-1"
handler = "exports.example"
role = "${aws_iam_role.iam_for_lambda.arn}"
role = aws_iam_role.iam_for_lambda.arn
runtime = "nodejs12.x"
}
resource "aws_lambda_permission" "test1" {
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.test1.function_name}"
principal = "secretsmanager.amazonaws.com"
statement_id = "AllowExecutionFromSecretsManager1"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.test1.function_name
principal = "secretsmanager.amazonaws.com"
statement_id = "AllowExecutionFromSecretsManager1"
}
# Not a real rotation function
resource "aws_lambda_function" "test2" {
filename = "test-fixtures/lambdatest.zip"
function_name = "%[1]s-2"
handler = "exports.example"
role = "${aws_iam_role.iam_for_lambda.arn}"
role = aws_iam_role.iam_for_lambda.arn
runtime = "nodejs12.x"
}
resource "aws_lambda_permission" "test2" {
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.test2.function_name}"
principal = "secretsmanager.amazonaws.com"
statement_id = "AllowExecutionFromSecretsManager2"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.test2.function_name
principal = "secretsmanager.amazonaws.com"
statement_id = "AllowExecutionFromSecretsManager2"
}
`, rName)
}
Expand All @@ -637,20 +637,20 @@ resource "aws_lambda_function" "test" {
filename = "test-fixtures/lambdatest.zip"
function_name = "%[1]s"
handler = "exports.example"
role = "${aws_iam_role.iam_for_lambda.arn}"
role = aws_iam_role.iam_for_lambda.arn
runtime = "nodejs12.x"
}
resource "aws_lambda_permission" "test" {
action = "lambda:InvokeFunction"
function_name = "${aws_lambda_function.test.function_name}"
principal = "secretsmanager.amazonaws.com"
statement_id = "AllowExecutionFromSecretsManager1"
action = "lambda:InvokeFunction"
function_name = aws_lambda_function.test.function_name
principal = "secretsmanager.amazonaws.com"
statement_id = "AllowExecutionFromSecretsManager1"
}
resource "aws_secretsmanager_secret" "test" {
name = "%[1]s"
rotation_lambda_arn = "${aws_lambda_function.test.arn}"
rotation_lambda_arn = aws_lambda_function.test.arn
rotation_rules {
automatically_after_days = %[2]d
Expand Down Expand Up @@ -701,9 +701,9 @@ resource "aws_secretsmanager_secret" "test" {
func testAccAwsSecretsManagerSecretConfig_Policy(rName string) string {
return fmt.Sprintf(`
resource "aws_iam_role" "test" {
name = %[1]q
name = %[1]q
assume_role_policy = <<EOF
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
Expand All @@ -718,6 +718,7 @@ resource "aws_iam_role" "test" {
]
}
EOF
}
resource "aws_secretsmanager_secret" "test" {
Expand All @@ -727,18 +728,19 @@ resource "aws_secretsmanager_secret" "test" {
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EnableAllPermissions",
"Effect": "Allow",
"Principal": {
"AWS": "${aws_iam_role.test.arn}"
},
"Action": "secretsmanager:GetSecretValue",
"Resource": "*"
}
{
"Sid": "EnableAllPermissions",
"Effect": "Allow",
"Principal": {
"AWS": "${aws_iam_role.test.arn}"
},
"Action": "secretsmanager:GetSecretValue",
"Resource": "*"
}
]
}
POLICY
}
`, rName)
}
12 changes: 6 additions & 6 deletions aws/resource_aws_secretsmanager_secret_version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ resource "aws_secretsmanager_secret" "test" {
}
resource "aws_secretsmanager_secret_version" "test" {
secret_id = "${aws_secretsmanager_secret.test.id}"
secret_id = aws_secretsmanager_secret.test.id
secret_string = "test-string"
}
`, rName)
Expand All @@ -228,8 +228,8 @@ resource "aws_secretsmanager_secret" "test" {
}
resource "aws_secretsmanager_secret_version" "test" {
secret_id = "${aws_secretsmanager_secret.test.id}"
secret_binary = "${base64encode("test-binary")}"
secret_id = aws_secretsmanager_secret.test.id
secret_binary = base64encode("test-binary")
}
`, rName)
}
Expand All @@ -241,7 +241,7 @@ resource "aws_secretsmanager_secret" "test" {
}
resource "aws_secretsmanager_secret_version" "test" {
secret_id = "${aws_secretsmanager_secret.test.id}"
secret_id = aws_secretsmanager_secret.test.id
secret_string = "test-string"
version_stages = ["one", "AWSCURRENT"]
Expand All @@ -256,7 +256,7 @@ resource "aws_secretsmanager_secret" "test" {
}
resource "aws_secretsmanager_secret_version" "test" {
secret_id = "${aws_secretsmanager_secret.test.id}"
secret_id = aws_secretsmanager_secret.test.id
secret_string = "test-string"
version_stages = ["two", "AWSCURRENT"]
Expand All @@ -271,7 +271,7 @@ resource "aws_secretsmanager_secret" "test" {
}
resource "aws_secretsmanager_secret_version" "test" {
secret_id = "${aws_secretsmanager_secret.test.id}"
secret_id = aws_secretsmanager_secret.test.id
secret_string = "test-string"
version_stages = ["one", "two", "AWSCURRENT"]
Expand Down
Loading

0 comments on commit 13ba0ef

Please sign in to comment.