tfy_api_key are stored directly in terraform.tfvars. While convenient for initial setup, this is a security risk if the file is committed to version control.
Terraform only reads from the secrets backend. You are responsible for creating and updating the secrets outside of Terraform.
Supported Backends
How It Works
Every backend follows the same pattern:- A
use_remote_credentialsvariable (defaulttrue) controls whether secrets are read from the remote store or fall through toterraform.tfvars. - Data sources are gated with
count = var.use_remote_credentials ? 1 : 0— when disabled, no remote calls are made. - A
localsblock resolvestfy_api_keyfrom either the remote store orvar.tfy_api_key. main.tfreferenceslocal.tfy_api_key— it does not need to change when you switch backends.
Migration Guide
Pick the tab that matches your secrets infrastructure and follow the steps.- AWS Secrets Manager
- AWS SSM Parameter Store
- HashiCorp Vault
- 1Password
Prerequisites
Prerequisites
- AWS IAM permissions — the identity running Terraform needs:
secretsmanager:GetSecretValuesecretsmanager:DescribeSecret
Migration Steps
Migration Steps
1
Create the secret in AWS Secrets Manager
Before running Terraform, manually create a secret in AWS Secrets Manager. The secret value must be a JSON object containing all the credentials you want to manage:Via the AWS Console:
- Open AWS Secrets Manager → click Store a new secret.
- Choose Other type of secret.
- Select Plaintext and paste the JSON above (with your actual value).
- Name the secret (e.g.
truefoundry/<your-cluster-name>/terraform-secrets). - Complete the wizard and note the secret name.
2
Add secrets.tf
Create a file named Add a line to
secrets.tf in your Terraform root directory with the following contents:secrets.tf
locals for each key in your secret. The fallback variables (e.g. var.license_key) are only used when use_remote_credentials = false.3
Configure terraform.tfvars
terraform.tfvars
4
Update main.tf and apply
Replace references to Then initialize and apply:
var.tfy_api_key with local.tfy_api_key (and similarly for any other secrets):FAQ
How do I update secrets after migration?
How do I update secrets after migration?
Update the secret value directly in your secrets store (AWS Secrets Manager, SSM, Vault, or 1Password), then run
tofu apply to propagate the new values.How do I fall back to terraform.tfvars?
How do I fall back to terraform.tfvars?
All four backends support a quick fallback without removing in your
secrets.tf. Set:terraform.tfvars and provide the tfy_api_key value directly. The remote data source will be skipped entirely (count = 0) — no network calls to the secrets backend will be made.How do I switch between backends?
How do I switch between backends?
- Replace the contents of
secrets.tfwith the new backend’s configuration from the relevant tab above. - Update
terraform.tfvarswith the new backend’s variables and remove the old backend’s variables. - Re-initialize and apply: