terraform how to access env variablee code example

Example: terraform env variables

#Terraform Environment Variables:-

export TF_CLI_CONFIG_FILE="$HOME/.terraformrc-custom"
export TF_INPUT=0
export TF_LOG_PATH=./terraform.log
export TF_LOG=TRACE

TF_CLI_ARGS="-input=false" terraform apply -force is the equivalent to manually typing: terraform apply -input=false -force
TF_CLI_ARGS_plan="-refresh=false"

export TF_VAR_region=us-west-1
export TF_VAR_ami=ami-049d8641
export TF_VAR_alist='[1,2,3]'
export TF_VAR_amap='{ foo = "bar", baz = "qux" }'

#If TF_IN_AUTOMATION is set to any non-empty value, 
#Terraform adjusts its output to avoid suggesting specific commands to run next
export TF_IN_AUTOMATION

#TF_DATA_DIR changes the location where Terraform keeps its per-working-directory data,
#such as the current remote backend configuration.
export TF_DATA_DIR

#Set TF_REGISTRY_DISCOVERY_RETRY to configure the max number of request retries the remote registry client will attempt 
#for client connection errors or 500-range responses that are safe to retry
export TF_REGISTRY_DISCOVERY_RETRY

#The default client timeout for requests to the remote registry is 10s. 
#TF_REGISTRY_CLIENT_TIMEOUT can be configured and increased during extraneous circumstances.
export TF_REGISTRY_CLIENT_TIMEOUT=15

#If TF_IGNORE is set to "trace", Terraform will output debug messages to display ignored files and folders. 
#This is useful when debugging large repositories with .terraformignore files.
export TF_IGNORE=trace

Tags:

Misc Example