provider-ephemeral-resources

Implement Terraform Plugin Framework ephemeral resources with Open, Renew, and Close lifecycle methods.

859|125|Updated Nov 8, 2025
One-click install
npx skills add https://github.com/hashicorp/agent-skills --skill provider-ephemeral-resources
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: provider-ephemeral-resources
Source: https://github.com/hashicorp/agent-skills/tree/main/plugins/terraform/skills/provider-ephemeral-resources
Command: npx skills add https://github.com/hashicorp/agent-skills --skill provider-ephemeral-resources

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Terraform providers often need to hand secrets like tokens, generated passwords, and short-lived certificates to configurations without persisting them to state or plan files. This Skill guides the implementation of ephemeral resources in the Terraform Plugin Framework so sensitive values never touch disk.

Core Features & Use Cases

  • Lifecycle Implementation: Covers the Open, Renew, and Close methods, including passing lease handles via Private state and setting RenewAt with a safety margin for expiring credentials.
  • Schema and Registration Guidance: Explains ephemeral schema design, Sensitive attribute marking, registration via EphemeralResources, and wiring EphemeralResourceData in the provider Configure method.
  • Decision Support: Provides a decision table for choosing between an ephemeral resource and a data source, plus design rules that prevent leaking secrets into logs or diagnostics.
  • Use Case: A provider needs to issue a short-lived STS-style token that feeds a write-only attribute on another resource. Use this Skill to implement the ephemeral resource with renewal and revocation, then test it through the echoprovider pattern.

Quick Start

Ask the AI to implement a Terraform ephemeral resource that issues a short-lived token for a given role using the Plugin Framework, including renewal and revocation.

Frequently Asked Questions about provider-ephemeral-resources

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement an ephemeral resource in the Terraform Plugin Framework?

Implement the ephemeral.EphemeralResource interface with an Open method that fetches or creates the value, define a schema with Sensitive computed attributes, and register it in the provider's EphemeralResources method. Add Renew and Close only when the upstream API supports lease renewal and revocation.

When should I use an ephemeral resource vs a data source in Terraform?

Use a data source for read-only lookups of non-sensitive data. Use an ephemeral resource when the value is sensitive and only needed at apply time, such as a database password for a provider block or a token for a write-only attribute, because ephemeral values never persist to state or plan.

What Terraform version supports ephemeral resources?

Ephemeral resources require Terraform 1.10 or later. Acceptance tests should be version-gated with tfversion.SkipBelow(tfversion.Version1_10_0) so they skip on older CLI versions.

How do I test ephemeral resources if values never reach state?

Test ephemeral resources indirectly by echoing the value through the echoprovider into a regular resource the test can inspect. Cover a basic open-and-use test plus per-attribute tests, and gate the tests to Terraform 1.10 or later.

How does credential renewal work in Terraform ephemeral resources?

Open returns a RenewAt timestamp, and Terraform calls Renew when the wall clock passes it. Renew can only extend the existing credential, not return a new value, so pass lease identifiers through resp.Private and set RenewAt with a safety margin before real expiry.