I am currently trying to implement an aws_iam_policy in terraform that looks like:
resource "aws_iam_policy" "policyName" {
name = "policyName"
path = "/"
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Effect = "Allow"
NotAction = [
"iam:*"
]
Resource = "*"
Condition = {
test = "StringEquals"
variable = "s3:prefix"
values = [
"home/"
]
}
}
]
})
}
However, when I try to deploy this in an environment I'm using within a team, I get an error saying there are syntax errors with this (the logs only point out the starting line and nowhere else). When I take out the Condition block the error disappears, so I know it's something to do with the condition. I have checked the terraform documentation and they do not have an = after the condition, but when I remove the = I get an error saying the = is expected. Would anyone know of the correct syntax/the right place to look for documentation regarding this (as stated previously the documentation at https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document doesn't work for me)?