Prompt

Need to keep secrets out of Terraform state

Technology / Cybersecurity1 observationLast seen Oct 25, 2026

Latest observation

Oct 25, 2026OpenAI APIWeb search: off

Yes — you generally want to avoid putting secrets into Terraform state, because state is often stored remotely, shared with teammates/automation, and can persist longer than you expect.

Best options

1) Don’t manage the secret value with Terraform

Use Terraform to create the resource, but inject the secret outside Terraform:

  • CI/CD secret store
  • Vault
  • AWS Secrets Manager / SSM Parameter Store
  • Azure Key Vault
  • GCP Secret Manager

Then have your app or runtime fetch the secret directly from that store.

2) Pass secret values as sensitive variables

If you must pass a secret into Terraform:

  • mark the variable as sensitive = true
  • avoid outputting it
  • avoid using it in resource arguments unless unavoidable

Example:

variable "db_password" {
  type      = string
  sensitive = true
}

This hides it from CLI output, but it can still end up in state if used in a resource.

3) Use resources that reference secret IDs, not secret values

Prefer patterns like:

  • store secret in a secret manager
  • pass only the secret ARN/name/ID into Terraform
  • configure the consuming service to read it at runtime

Example:

resource "aws_secretsmanager_secret" "db" {
  name = "db-password"
}

resource "aws_secretsmanager_secret_version" "db" {
  secret_id     = aws_secretsmanager_secret.db.id
  secret_string = var.db_password
}

This still stores the value in Terraform state, so it’s only acceptable if you understand the tradeoff.

If you must use Terraform with secrets

Minimize exposure:

  • use an encrypted remote backend
  • restrict state access tightly
  • enable state encryption at rest and in transit
  • use short-lived credentials
  • rotate secrets regularly
  • do not commit state locally or to git

Important limitation

Terraform cannot fully prevent secrets from entering state if the secret value is part of the resource configuration. sensitive only hides it in UI/plan output; it does not guarantee it stays out of state.

Practical rule

If the value is a true secret, try to:

  • store it outside Terraform
  • have Terraform manage only references to it

If you want, I can show you the safest pattern for a specific provider like AWS, Azure, GCP, or Kubernetes.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.