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

Hi,

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 app.terraform.io:
terraform login

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

edit:

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


on the CLI config, using:

credentials "app.terraform.io" {
  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.

1 Like

I am having the same issue. It seems that I cannot pickup the config in the CI environment.