Skip to content
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

Fix quoting for list variables in tf_vars #22

Closed
sklarsa opened this issue Jan 13, 2021 · 3 comments
Closed

Fix quoting for list variables in tf_vars #22

sklarsa opened this issue Jan 13, 2021 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@sklarsa
Copy link

sklarsa commented Jan 13, 2021

Running the latest tftest version (1.5.4)

My module has a list variable...
variables.py

variable role_policies {
  type    = list
  default = []
}

And when I run the following code in my test...
test_module.py

new_role = tf_plan(role_policies=["ecs_task_execution"])

I get the following output...

E       tftest.TerraformTestError: Error running command plan: 1
E       Error: Invalid character
E
E         on <value for var.role_policies> line 1:
E         (source code not available)
E
E       Single quotes are not valid. Use double quotes (") to enclose strings.
E
E
E       Error: Invalid expression
E
E         on <value for var.role_policies> line 1:
E         (source code not available)
E
E       Expected the start of an expression, but found an invalid expression token.

This seems similar to #20

@ludoo
Copy link
Collaborator

ludoo commented Jan 13, 2021

Steven, thanks for reporting this, I'll get on it ASAP.

@ludoo ludoo self-assigned this Jan 13, 2021
@ludoo ludoo added the bug Something isn't working label Jan 13, 2021
@ludoo
Copy link
Collaborator

ludoo commented Jan 13, 2021

Hah, I read that too quickly (dinner was calling), and did not spot the fact you're passing a Python list to tf_plan, not a Terraform list, which is a Python string. Try this

new_role = tf_plan(role_policies='["ecs_task_execution"]')

And let me know if it works, as we're using tons of list variables in our tests and I've never had issues with them.

@ludoo ludoo added question Further information is requested and removed bug Something isn't working labels Jan 13, 2021
@sklarsa
Copy link
Author

sklarsa commented Jan 13, 2021

Yep that works.. thanks!

@sklarsa sklarsa closed this as completed Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants