Skip to main content
By default, sensitive values like 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

BackendBest for
AWS Secrets ManagerTeams already on AWS who want managed secret rotation
AWS SSM Parameter StoreTeams on AWS who prefer a simpler key-value store
HashiCorp VaultTeams using Vault as a central secrets platform
1PasswordTeams using 1Password for credential management

How It Works

Every backend follows the same pattern:
  1. A use_remote_credentials variable (default true) controls whether secrets are read from the remote store or fall through to terraform.tfvars.
  2. Data sources are gated with count = var.use_remote_credentials ? 1 : 0 — when disabled, no remote calls are made.
  3. A locals block resolves tfy_api_key from either the remote store or var.tfy_api_key.
  4. main.tf references local.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 IAM permissions — the identity running Terraform needs:
    • secretsmanager:GetSecretValue
    • secretsmanager:DescribeSecret
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:
{
  "tfy_api_key": "eyJhbGciOi...",
  "license_key": "your-license-key"
}
Via the AWS Console:
  1. Open AWS Secrets Manager → click Store a new secret.
  2. Choose Other type of secret.
  3. Select Plaintext and paste the JSON above (with your actual value).
  4. Name the secret (e.g. truefoundry/<your-cluster-name>/terraform-secrets).
  5. Complete the wizard and note the secret name.
2

Add secrets.tf

Create a file named secrets.tf in your Terraform root directory with the following contents:
secrets.tf
variable "use_remote_credentials" {
  type        = bool
  description = "When true, pull secrets from AWS Secrets Manager. When false, use values from terraform.tfvars directly."
  default     = true
}

variable "tfy_credentials_name" {
  type        = string
  description = "Name of the Secrets Manager secret that stores TrueFoundry credentials"
}

data "aws_secretsmanager_secret_version" "tfy_secrets" {
  count     = var.use_remote_credentials ? 1 : 0
  secret_id = var.tfy_credentials_name
}

locals {
  secrets     = var.use_remote_credentials ? jsondecode(data.aws_secretsmanager_secret_version.tfy_secrets[0].secret_string) : {}
  tfy_api_key = var.use_remote_credentials ? local.secrets["tfy_api_key"] : var.tfy_api_key
  license_key = var.use_remote_credentials ? local.secrets["license_key"] : var.license_key
}
Add a line to 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
use_remote_credentials = true
tfy_credentials_name   = "truefoundry/<your-cluster-name>/terraform-secrets"
4

Update main.tf and apply

Replace references to var.tfy_api_key with local.tfy_api_key (and similarly for any other secrets):
 module "platform-integrations" {
   # ...
-  tfy_api_key = var.tfy_api_key
+  tfy_api_key = local.tfy_api_key
   # ...
 }
Then initialize and apply:
tofu init
tofu plan        # review — no new resources, just data source reads
tofu apply

FAQ

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.
All four backends support a quick fallback without removing secrets.tf. Set:
use_remote_credentials = false
in your 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.
  1. Replace the contents of secrets.tf with the new backend’s configuration from the relevant tab above.
  2. Update terraform.tfvars with the new backend’s variables and remove the old backend’s variables.
  3. Re-initialize and apply:
tofu init -upgrade    # install any new providers
tofu plan
tofu apply
The secrets.tf file should contain only one backend’s configuration at a time.

Quick Reference

BackendAuth MethodExtra ProvidersVariables in terraform.tfvars
AWS Secrets ManagerAWS IAM (existing)Noneuse_remote_credentials, tfy_credentials_name
AWS SSM Parameter StoreAWS IAM (existing)Noneuse_remote_credentials, tfy_credentials_name
HashiCorp VaultVAULT_ADDR + VAULT_TOKEN env varshashicorp/vaultuse_remote_credentials, vault_secret_mount, vault_secret_path
1PasswordOP_SERVICE_ACCOUNT_TOKEN env var1Password/onepassworduse_remote_credentials, op_vault_uuid, op_item_uuid