hashicorp/agent-skills/provider-ephemeral-resources
Claude Code and agent skill by hashicorp/agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Implement Terraform provider ephemeral resources with the Plugin Framework: the Open/Renew/Close lifecycle, ephemeral schema design, registration via EphemeralResources, renewal for expiring credentials, and how ephemeral values flow into write-only attributes and provider configuration. Use when adding an ephemeral resource, exposing secrets/tokens/certificates that must never persist in state or plan, deciding between an ephemeral resource and a data source, or wiring short-lived credentials from one provider into another.
Install
npx vskill@latest install hashicorp/agent-skills/provider-ephemeral-resourcesSKILL.md
The same SKILL.md was published earlier as hashicorp/agent-skills/provider-ephemeral-resources.
Terraform Provider Ephemeral Resources
Ephemeral resources (Terraform 1.10+) produce values that are never persisted to state or plan. They exist for exactly one job: handing secrets — tokens, generated passwords, short-lived certificates, decrypted values — to the parts of a configuration that need them, without writing them to disk. Any data source that returns a sensitive value is a candidate to be (or to also exist as) an ephemeral resource.
Official docs: Ephemeral Resources.
When to Use One
| Situation | Use | |
|---|---|---|
| Read-only lookup of non-sensitive data | Data source | |
| Value is sensitive and only needed at apply time (DB password for a provider block, token for a write-only attribute) | Ephemeral resource | |
| Sensitive value that downstream managed resources must store (e.g. as an attribute) | Regular resource/data source — but pair with write-only attributes where possible | |
| Credential that expires mid-operation (STS-style tokens, short-TTL leases) | Ephemeral resource with Renew |
Ephemeral results can be used in provider configuration, write-only attributes, provisioner configuration, and other ephemeral contexts — but not in regular attributes, because those persist to state.
Lifecycle
Terraform calls up to three methods per operation:
- `Open` (required) — fetch or create the value; runs during plan
and/or apply whenever the result is needed. There is no state to refresh and nothing to import.
- `Renew` (optional) — called when the wall clock passes the
RenewAt returned by Open/Renew, for values that expire while Terraform is still running. Renew cannot return a new result — it can only extend/refresh what Open produced (e.g. re-lease the same credential); if the value itself changes on renewal, the API is not renewable in this sense and Open must return a longer-lived value.
- `Close` (optional) — called when Terraform is done with the value;
revoke leases or delete temporary credentials here.
Open can pass bytes forward via resp.Private; Renew and Close receive them — use this for lease IDs needed to renew/revoke.
Implementation
Configure follows the same ProviderData-cast pattern as resources (the provider-resources skill, if available, shows it); the client comes from resp.EphemeralResourceData set in the provider's Configure.
Registration
The provider opts in via provider.ProviderWithEphemeralResources:
Set resp.EphemeralResourceData = client in the provider's Configure alongside ResourceData/DataSourceData.
Design Rules
- Never log the value, never put it in a diagnostic. The whole point is
non-persistence; an error message containing the token defeats it.
- Mark the secret attribute
Sensitive: trueanyway — it guards rendering
in the ephemeral value's own lifecycle output.
- No plan modifiers, no import, no
idconvention — there is no state for
any of them to act on.
- Schema inputs follow the same rules as data source arguments; expose the
API's identifiers (role_name), not invented ones.
- Set
RenewAtwith a safety margin before the real expiry; Terraform
renews lazily, not on a precise timer.
- If the upstream value cannot be revoked, skip
Closerather than
implementing a no-op that suggests revocation happens.
Testing
Ephemeral results never reach state, so tests assert them indirectly — the standard pattern echoes the ephemeral value through the echoprovider into a regular resource the test can inspect. Minimum coverage: a basic open-and-use test and per-attribute tests alongside required fields. Use the provider-test-patterns skill (if available) — its ephemeral testing reference covers the echoprovider setup, version gating (tfversion.SkipBelow(tfversion.Version1_10_0)), and multi-step patterns.
Documentation
Registry docs live at docs/ephemeral-resources/<name>.md, generated by tfplugindocs like every other page type. Use the provider-docs skill (if available) for the workflow; document the renewal/revocation behavior explicitly — users need to know whether closing their Terraform run revokes the credential.
Checklist
- [ ] Value genuinely must not persist (otherwise a data source is simpler)
- [ ]
Openimplemented;Renew/Closeonly where the API supports them - [ ] Secret attributes
Sensitive: true; value never logged or in diagnostics - [ ] Lease/handle passed via
Private, not via the result - [ ]
RenewAtset with margin for expiring credentials - [ ] Registered in
EphemeralResources();EphemeralResourceDataset in provider Configure - [ ] Echo-provider acceptance tests, version-gated to Terraform >= 1.10
- [ ] Docs page explains lifetime, renewal, and revocation behavior
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/terraform/skills/provider-ephemeral-resources/SKILL.md
Popularity
- Repository stars
- 819
- Repository forks
- 120
- 7-day trend score
- 34
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/hashicorp/agent-skills/provider-ephemeral-resources)