-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Terraform Test: Load terraform.tfvars file from test directory automatically #34008
Comments
Hi, I would like to be new contributor to the Terraform project, can I work on this issue ? |
Hi @JKIPIKA, sure thing! I'd be happy to review any PR you raised for this issue. A caveat / trap to look out for would be that we can execute tests both inside the main configuration directory and within any specified testing directory in the same execution. This means we need to keep track of two sets of variables for the tests, one loaded from the main configuration directory and one loaded for the testing directory. My approach would be:
Hopefully that makes sense! If you're still interested, feel free to raise a PR and tag me, or link it here, and I can take a look. Let me know any other questions! |
Thank you very much for explanation! I will raise a PR when i will have something worth sharing. |
Hi @JKIPIKA, please also make sure to read https://github.com/hashicorp/terraform/blob/main/.github/CONTRIBUTING.md#contributing-to-terraform. Thanks! |
Hi @crw, i have read contribution guide! I have dev environment ready at my local machine, can you please mark me as assignee to this issue ? |
Hello, sorry for the delay, the task was actually harder for me than I thought, can you please verify my solution ? |
@JKIPIKA thanks, let's keep that conversation in the PR. We appreciate your contribution! |
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. |
Terraform Version
Use Cases
It would be nice to let users specify a set of Terraform variable values for all the tests at once automatically. We can do this by loading a terraform.tfvars file from the testing directory automatically, like we do for the main configuration directory.
Attempted Solutions
You can place the variable values in terraform.tfvars file in the main configuration directory, but this might clash with any default variable values you want to specify for plans or applys against the main config.
Proposal
terraform test
loads the default variables from this function here.We could modify, or duplicate, that function so that it accepts a testing directory and will include two sets of variables one for any tests in the testing directory, and one for any tests within the main configuration directory.
References
No response
The text was updated successfully, but these errors were encountered: