Skip to content

Conversation

@annawinkler
Copy link
Contributor

@annawinkler annawinkler commented Sep 30, 2022

What

  • Clarify what happens with terraform.tfvars in TFC and TFE on this page

Why

A customer noticed behavior that was undocumented, reported in this issue.


Merge Checklist

If items do not apply to your changes, add (N/A) and mark them as complete.

Pull Request

  • One or more labels describe the type of change (e.g. clarification) and associated product (e.g. tfc).
  • Description links to related pull requests or issues, if any.

Content

  • [NA] Redirects have been added for moved, renamed, or deleted pages. This requires a separate PR in the terraform-website repository redirects.next.js file.
  • [NA] API documentation and the API Changelog have been updated.
  • [NA] Links to related content where appropriate (e.g., API endpoints, permissions, etc.).
  • [NA] Pages with related content are updated and link to this content when appropriate.
  • [NA] Sidebar navigation files have been updated for added, deleted, reordered, or renamed pages.
  • [NA] New pages have metadata (page name and description) at the top.
  • [NA] New images are 2048 px wide. They have HashiCorp standard annotation color (#F92672) and format (rectangle with rounded corners), blurred sensitive details (e.g. credentials, usernames, user icons), and descriptive alt text in the markdown for accessibility.
  • [NA] New code blocks have the correct syntax and line breaks to eliminate horizontal scroll bars.
  • [NA] UI elements (button names, page names, etc.) are bolded.
  • [NA] The Vercel website preview successfully deployed.

Reviews

  • I or someone else reviewed the content for technical accuracy.
  • I or someone else reviewed the content for typos, punctuation, spelling, and grammar.

@vercel
Copy link

vercel bot commented Sep 30, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
terraform-docs-common ✅ Ready (Inspect) Visit Preview Oct 4, 2022 at 8:40PM (UTC)

Paired with @nfagerlund to update the info for `terraform.tfvars`
@annawinkler annawinkler merged commit 5ad7a2c into main Oct 5, 2022
@annawinkler annawinkler deleted the aw/more-about-terraform-tfvars-file branch October 5, 2022 14:35
hashibot-web added a commit that referenced this pull request Sep 28, 2023
@yermulnik
Copy link

A customer noticed behavior that was undocumented, reported in this issue.

@annawinkler @brandonc I do apologize for bumping this PR from 2022, but given the link to the mentioned issue isn't available to ordinary mortals like me, could you please share some details on how TF Cloud handles terraform.tfvars file nowadays: does it overwrite the file only when there's at least one TF Cloud workspace variable defined or does it not overwrite/ignore this file at all anymore but instead writes TF Cloud workspace vars into a *.auto.tfvars file with a special name (if yes, then since when and whether this was announced and communicated to community)?

The «Although Terraform Cloud uses variables from terraform.tfvars» is a bit ambiguous as doesn't provide definitive answer on how this file is handled by TF Cloud. And given the behavior had changed, it would've been expected this to be communicated to TF Cloud customers (especially to those who pay for the SaaS).

I used to know that TF Cloud overwrites terraform.tfvars unconditionally and hence in some edge cases we use *.auto.tfvars to bypass a need to create and manage TF Cloud workspace vars.
This was (in)directly confirmed by @apparentlymart at https://discuss.hashicorp.com/t/how-do-i-pass-var-file-on-teffaform-cloud/8505/6 back in 2021, though recently I've found this is not fully true anymore. So it looks like it is not a matter anymore and we can start using more straightforward terraform.tfvars. But there's no details and no guarantee this won't change over time with no explicit notice.

Thanks in advance.

@yermulnik
Copy link

@apparentlymart pointed out this comment #158 (comment) (thanks @apparentlymart for the pointer!) — this comment explains a lot on the matter and it would really great to have that added into TF documentation for tfvars so that people can see difference between regular TF (community edition), TFC and TFE. Thanks in advance.

@yermulnik
Copy link

Looks like the https://developer.hashicorp.com/terraform/cloud-docs/workspaces/variables#precedence is what explains the flow and details and is what turned out to misled me with overwrite (vs override: overwrite files vs override variables) 😢 I mistakenly was thinking that TF Cloud Workspace vars are written into terraform.tfvars file by overwriting this file, rather than to be merged into data set loaded from terraform.tfvars from the slug (the slug is what is being uploaded from the dir where user is running terraform, right?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants