keep-secrets-out-of-terraform-state
Use when IaC variables or resources may hold credentials. Keeps plaintext secrets out of state and plan files, which sit in a bucket and a CI artefact by default.
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 80
- Forks
- 17
01 前言 Front Matter
- name
- keep-secrets-out-of-terraform-state
- description
- Use when IaC variables or resources may hold credentials. Keeps plaintext secrets out of state and plan files, which sit in a bucket and a CI artefact by default.
02 资源文件 3
- 许可证LICENSE1.0 KB
- 参考文档SOURCE.md361 B
- 参考文档TRUST.auto.yaml2.1 KB
03 SKILL.md 正文
Keep secrets out of Terraform state
State records every attribute of every resource, including generated passwords and keys, and it lives in a bucket and a CI artefact. A secret in state is a secret leaked.
Procedure
- Treat state as confidential and encrypt it:
encrypt = trueon the S3 backend, SSE-KMS on the bucket, and a bucket policy denying unencrypted PUT. - Never pass secrets as resource arguments that land in state. Reference a secret manager instead:
data "aws_secretsmanager_secret_version" "db" { secret_id = "prod/db" }
password = data.aws_secretsmanager_secret_version.db.secret_string
Even this writes the value to state; prefer letting the platform inject it (
manage_master_user_password = trueon RDS). - Mark variables
sensitive = trueso values are redacted in plan output and CI logs. - Scan for leaked secrets before state or plan files leave the runner: grep -rEi 'password|secret|token|private_key' tf.plan.backup || true
- Keep plan files out of git: add
*.tfplan,*.tfstate,*.tfvarsto.gitignore, and never committerraform.tfstate.backup. - In CI pull secrets from the runner's OIDC-assumed role or the pipeline secret store at apply time, not from checked-in
terraform.tfvars. - Rotate anything that was ever written to state: assume it leaked.
- Restrict the KMS key at rest with a policy that excludes roles which only need to read.
Pitfalls
variable "db_password"with a default sitting in a committedterraform.tfvars.- A plan file committed for review that carries a resource's generated password in cleartext.
- Marking a variable sensitive but then routing it through a
localused in a non-sensitive output, which un-redacts it. - Assuming
sensitive = trueremoves the value: it only hides the display, the value stays in state and plan JSON. - An output marked
sensitive = truereused by another output that is not, leaking the value.
Verification
aws s3api get-bucket-encryption --bucket acme-tfstate # SSEConfigured
grep -rEi 'password|secret|token|private_key' tf.plan.backup # no hits
Report: the state encryption config, the secret-manager references used, and the scan result showing no plaintext credentials.
04 同仓库更多 Skills
recipe-performance
Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold/warm/background-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout/paint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.
mexc-spot-websocket
MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.
mexc-spot-rest
MEXC Spot REST workflows for public data, signed account requests, orders, wallet/admin actions, and secure signing without exposing API keys.
mexc-futures-websocket
MEXC Futures WebSocket workflows for public streams, private account/order/position streams, ping/pong, subscriptions, and depth maintenance.
0xklen-version-and-refresh-sanctions-lists
暂无简介
verify-tests-cover-changed-lines
Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.