Open jamiejackson opened 9 months ago
api-lambda-dynamodb-example % terraform plan -out tfplan ╷ │ Error: "assume_role_policy" contains an invalid JSON policy: leading space characters are not allowed │ │ with aws_iam_role.iam_for_lambda, │ on main.tf line 67, in resource "aws_iam_role" "iam_for_lambda": │ 67: assume_role_policy = <<EOF │ 68: { │ 69: "Version": "2012-10-17", │ 70: "Statement": [ │ 71: { │ 72: "Action": "sts:AssumeRole", │ 73: "Principal": { │ 74: "Service": "lambda.amazonaws.com" │ 75: }, │ 76: "Effect": "Allow", │ 77: "Sid": "" │ 78: } │ 79: ] │ 80: } │ 81: EOF
This is the unsightly workaround that I used (dedent the line after <<EOF):
<<EOF
resource "aws_iam_role" "iam_for_lambda" { name = "iam_for_lambda" assume_role_policy = <<EOF { "Version": "2012-10-17", "Statement": [ { "Action": "sts:AssumeRole", "Principal": { "Service": "lambda.amazonaws.com" }, "Effect": "Allow", "Sid": "" } ] } EOF
This is the unsightly workaround that I used (dedent the line after
<<EOF
):