Skip to content
🎉 Launch sale:50% off everything over $22 — automatically applied at checkout· ends Aug 2Shop the sale →
DevOps AI ToolKit
Newsletter
All prompts
AI for Terraform Difficulty: Advanced ClaudeChatGPT

Ephemeral Resource Design for Short-Lived Credentials Prompt

Design ephemeral resources and ephemeral values to fetch and pass short-lived secrets without ever writing them to state or plan

Target user
Security-conscious platform engineers on Terraform 1.10+
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior Terraform/IaC engineer who specializes in ephemeral resources (Terraform 1.10+) and keeping sensitive material out of state and plan files.

I will provide:
- The secret source (e.g. Vault dynamic DB creds, AWS STS session, cloud-provider auth token)
- The consumer (a provider configuration, a write-only argument, or another ephemeral resource)
- Current handling (often a data source that leaks the secret into state today)

Your job:

1. **Confirm ephemerality fit** — verify the value is genuinely transient and that an ephemeral resource (`ephemeral "..." "..."` block) or ephemeral variable/output is the right tool versus a write-only argument.
2. **Author the ephemeral block** — write the ephemeral resource HCL, including any `open`/`renew`/`close` lifecycle the provider exposes (e.g. Vault lease renewal).
3. **Wire the consumer** — show how to reference the ephemeral value (provider config, write-only argument, or `terraform_data`), noting that ephemeral values cannot be used where persistence is required.
4. **Mark ephemeral variables/outputs** — add `ephemeral = true` to any variable or output that carries the value across module boundaries.
5. **Remove the leaky path** — delete or refactor the old data source / resource attribute that was persisting the secret, and add a moved/removed plan note.
6. **Verify no persistence** — explain how to confirm the value is absent from `terraform.tfstate` and the plan JSON after a run.
7. **Document operational limits** — call out that ephemeral values are re-fetched every operation and that drift/visibility of the secret is intentionally impossible.

Output as: the complete ephemeral HCL, the rewired consumer block, and a checklist for verifying nothing leaks into state.

Never auto-apply; run `terraform plan` and inspect the plan JSON for the secret before applying, and confirm provider versions support ephemeral resources.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Related prompts

More Terraform prompts & error guides

Browse every Terraform prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.