How can i Use the Team token to automate plan/apply via CI


Using terraform cloud, how can i use the team token for authenticate on our account with our CI process?

Currently, i tried to add the contents of /home/tclaro/.terraform.d/credentials.tfrc.json with the new generated token under the CI container that we are using with:

mkdir -p /root/.terraform.d/
echo -n “$TF_TOKEN” > /root/.terraform.d/credentials.tfrc.json
chmod 600 /root/.terraform.d/credentials.tfrc.json

But still, when the CI process executes, it prompts:

Initializing the backend…

Error: Required token could not be found

Run the following command to generate a token for
terraform login

So, How could i pass the team token as environment variable?


After checking the following document, it doesnt seems quite clear how can i achieve that:

on the CLI config, using:

credentials "" {
  token = "xxxxxx.atlasv1.zzzzzzzzzzzzz"

Would be directly on the tf files? sorry for all the questions but im confused regarding how can i achieve CI integrtion with terraform.