I use environment variables in Terraform Cloud to store sensitive information, and when I try to use them, it looks like Terraform Cloud is not exporting them.
H’m. I don’t have much experience with Terraform Cloud (yet), but it looks like you doing everything correctly. I don’t suppose it’s something silly like needing to prefix your environment variable names with TF_VAR_, is it? I don’t know whether that behaviour has carried over to TF Cloud, or whether it just matters for local execution; many of the TF Cloud examples I’ve seen don’t follow that prefix naming convention, for example.
Ah, so even when you just changed the names of the environment variables in TF Cloud to TF_VAR_cloudflare_email, etc., and left your actual TF code the same as you originally posted, it didn’t work?
Which version of Terraform are you using? I believe it will need to be fairly recent – 0.12.18 or greater, according to this post – for it to work without using interpolation syntax (i.e., with dollar signs and curly braces).
Hmm, this is what I have not tried to do, I have tried various options with variable names in the files themselves. I assumed that Terraform Cloud itself adds the necessary prefixes to the variable names that are specified in its backend, in addition, there are no warnings in the backend about this But I will try and write about the result.
At the same time, it seems to me that this looks like a bug, either it is a bug in some procedure, or it is a bug with sensitive variables, perhaps they are not exported, I will check this too.
I use Terraform v0.14.3, this is the latest version at the moment:
I think product managers need to take a closer look at this point and at least add a simple warning in the section with environment variables, I think this might help others like me)
@jlj7 I can’t find how to mark your post as an answer, is there such a possibility here?
Absolutely. +1 from me. [Edit: particularly because, as I said, I’m sure I’ve seen tutorials that don’t do this. I was honestly reaching, when I suggested it.]
I don’t think so, but I’m surprised (and happy!) to have been of help!
@aleon1220 it is a bad idea to store API keys / tokens in the configuration, my question was exactly about this and, it has been successfully solved for a long time, you can find the solution above.