-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Pass IAM policy as JSON through vars? #121
Comments
Can you share your code to provide some context? |
@brikis98 Sure thing. I'm trying to test creating IAM instance profile module. I'm trying to pass an IAM policy in JSON through Terraform variable:
|
Ah, I gotcha. Can you share the error message you get? It's probably an issue with escaping quotes. |
I have run into the same problem and get this error–
It appears that the json string is being interpreted as HCL. |
It looks like using an env variable rather than -var will force the the variable to be interpreted as a string. Not sure if all variables could be handled this way, since some may depend on the hcl-parsing behavior. |
Also, given that terraform 0.12 is moving toward more complex variables, there may need to be a different strategy here. |
I suppose we could add a flag to generate a |
I came across this after hitting this problem. The module I want to test has a variable that's a list and another variable that's a dictionary. With the CLI vars being strings this would cause errors. I found this bug and the talk of generating a Seeking a good, immediate, solution, I was looking at Azure examples and I noticed a neat trick they were doing in https://github.com/Azure/terraform-azurerm-loadbalancer. They have a fixture directory that is a terraform module.
The
The It also sets up other necessary resources and randomises the name via interpolation. Doing so in Terraform is a another nice trick for testing on Azure since terratest does not have a azure helper module (#89 Add Support for Azure). I like this solution as it means terratest doesn't need any changes such as a feature added to generate a |
This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please feel free to reach out if you have or find the answers we need so that we can investigate further. Thank you! |
I have just hit this exact issue (Terratest added additional quotes to an attribute value that is part of a list of objects). The workaround with a tvfars file worked for me. |
I'm trying to pass IAM policy JSON through terraformOptions.Vars, but without success (raw JSON results in syntax error). Any help?
The text was updated successfully, but these errors were encountered: