-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Use the TF_DATA_DIR
env var for temporary files
#36863
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
base: main
Are you sure you want to change the base?
Conversation
This (effectively) prevents Terraform from crossing filesystem boundaries when installing providers and cloudplugins.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @lattwood
Have you considered setting $TMPDIR
or equivalent?
Is there a reason that wouldn't/didn't work for you?
@radeksimko yes, we have, and that's the plan to work around this. What nobody would be expecting is Terraform continuing to beat the expletive out of I was surprised and caught offguard by this. I wouldn't be surprised if others end up having the same/similar experience, so I decided the least I could do is fire off a PR to make the behaviour adhere to the principle of least surprise. Plus, I had to read the source code to find out the behaviour, I'd like to save others from having to do the same. |
I appreciate the frustration but I'm afraid I don't understand how the mentioned surprising behaviour is addressed by introducing a new environment variable. It sounds like the surprise comes more from Would you be open to instead documenting |
oh, I didn't add a new environment variable- https://developer.hashicorp.com/terraform/cli/config/environment-variables#tf_data_dir I took advantage of an existing one that's used for relocating |
I see, I did not realise this was an existing variable. Thanks for clarifying that. One side effect of moving files of "temporary nature" outside of Going back to the original motivation though
Maybe I'm missing something here - is there a reason why the OS' If your intention is to have immutable filesystem at apply time, you could run Regardless of where the archives get stored, I still agree that we could clarify in the docs that the archives do get written somewhere as part of |
Just one extra thought - while we do currently rely entirely on the OS in terms of the cleanup we could remove the archives proactively from Would that help? |
This (effectively) prevents Terraform from crossing filesystem boundaries when installing providers and cloudplugins.
I am proposing this change, because of a recent experience with running a large number of
terraform init
statements (and I mean a lot). We do our checkouts on ephemeral storage for performance reasons, but we were shocked to discover that Terraform was still writing to the boot drive after making that change. This uses TF_DATA_DIR for the temporary files if it's set. If it isn't set, it will evaluate as""
, and here's what happens, right from the godoc-and then for
TempDir
-(I guess this means there's a bug, too, since I didn't see any checks for if it exists or has accessible permissions)
Target Release
1.13.x
CHANGELOG entry
Ehhh, not sure what to go for with this.