-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid JSON policy Error #3970
Comments
Hi @srikanthsoma 👋 I was not able to reproduce the invalid JSON error on Terraform 0.11.5 and AWS provider 1.13.0 with the
Can you please provide more details, such as how you are configuring the resource? |
Hello, Most probably it's because the policy contains leading spaces. For resource "aws_iam_role" assume_role_policy (and leading spaces in the JSON), terraform shows an error message that the policy cannot contain leading spaces. I think that the error message given by terraform in this case should be more specific. |
|
it seems one resource uses |
When you create a EOF injection, JSON doesn't like white spaces. The code about should look something like this:
|
Is there any reason why whitespace couldn't be trimmed? I find it much more readable to have it tab indented. |
Had this exact same issue on TF 0.12.2. This policy: Was fixed by removing the spaces ahead of the opening curly brace: |
Hi folks! I'm closing this as a duplicate of #1873. Please direct any further discussion there. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
This issue was originally opened by @srikanthsoma as hashicorp/terraform#17717. It was migrated here as a result of the provider split. The original body of the issue is below.
Hi,
Terraform validate says "policy" contains invalid JSON policy
This is my json policy which is validate then why terraform validate says invalid policy?
Terraform -v:
0.11.3
Terraform reproduce:
terraform plan
terraform validate
Error:
Error: aws_iam_policy.test_policy: "policy" contains an invalid JSON policy
The text was updated successfully, but these errors were encountered: