provider-ephemeral-resources
정보
이 스킬은 개발자들에게 Terraform 프로바이더의 임시 리소스를 Plugin Framework를 사용해 구현하는 방법을 안내합니다. 이를 통해 토큰이나 인증서 같은 단기 자격 증명을 상태에 저장하지 않고 안전하게 관리할 수 있습니다. Open/Renew/Close 라이프사이클, 스키마 설계, 쓰기 전용 속성 및 프로바이더 구성과의 통합을 다룹니다. 민감한 임시 값을 노출하거나 프로바이더 간 자격 증명을 연결해야 하면서도, 해당 값이 플랜이나 상태 파일에 절대 표시되지 않도록 보장해야 할 때 사용하세요.
빠른 설치
Claude Code
추천npx skills add hashicorp/agent-skills -a claude-code/plugin add https://github.com/hashicorp/agent-skillsgit clone https://github.com/hashicorp/agent-skills.git ~/.claude/skills/provider-ephemeral-resourcesClaude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요
문서
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 theRenewAtreturned byOpen/Renew, for values that expire while Terraform is still running. Renew cannot return a new result — it can only extend/refresh whatOpenproduced (e.g. re-lease the same credential); if the value itself changes on renewal, the API is not renewable in this sense andOpenmust 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
var (
_ ephemeral.EphemeralResource = &tokenEphemeralResource{}
_ ephemeral.EphemeralResourceWithConfigure = &tokenEphemeralResource{}
_ ephemeral.EphemeralResourceWithRenew = &tokenEphemeralResource{}
_ ephemeral.EphemeralResourceWithClose = &tokenEphemeralResource{}
)
func NewTokenEphemeralResource() ephemeral.EphemeralResource {
return &tokenEphemeralResource{}
}
type tokenEphemeralResource struct {
client *examplecloud.Client
}
type tokenEphemeralResourceModel struct {
RoleName types.String `tfsdk:"role_name"`
Token types.String `tfsdk:"token"`
LeaseID types.String `tfsdk:"lease_id"`
}
func (r *tokenEphemeralResource) Metadata(_ context.Context, req ephemeral.MetadataRequest, resp *ephemeral.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_token"
}
func (r *tokenEphemeralResource) Schema(_ context.Context, _ ephemeral.SchemaRequest, resp *ephemeral.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"role_name": schema.StringAttribute{
Required: true,
MarkdownDescription: "Role to obtain a token for.",
},
"token": schema.StringAttribute{
Computed: true,
Sensitive: true,
MarkdownDescription: "The issued token. Never persisted to state.",
},
"lease_id": schema.StringAttribute{
Computed: true,
MarkdownDescription: "Identifier of the token lease.",
},
},
}
}
func (r *tokenEphemeralResource) Open(ctx context.Context, req ephemeral.OpenRequest, resp *ephemeral.OpenResponse) {
var data tokenEphemeralResourceModel
resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}
lease, err := r.client.IssueToken(ctx, data.RoleName.ValueString())
if err != nil {
resp.Diagnostics.AddError(
"Error opening Token",
fmt.Sprintf("issuing token for role (%s): %s", data.RoleName.ValueString(), err),
)
return
}
data.Token = types.StringValue(lease.Token)
data.LeaseID = types.StringValue(lease.ID)
resp.RenewAt = lease.ExpiresAt.Add(-2 * time.Minute) // renew with margin
resp.Private.SetKey(ctx, "lease_id", []byte(lease.ID))
resp.Diagnostics.Append(resp.Result.Set(ctx, &data)...)
}
func (r *tokenEphemeralResource) Renew(ctx context.Context, req ephemeral.RenewRequest, resp *ephemeral.RenewResponse) {
leaseID, diags := req.Private.GetKey(ctx, "lease_id")
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
lease, err := r.client.RenewLease(ctx, string(leaseID))
if err != nil {
resp.Diagnostics.AddError("Error renewing Token", err.Error())
return
}
resp.RenewAt = lease.ExpiresAt.Add(-2 * time.Minute)
}
func (r *tokenEphemeralResource) Close(ctx context.Context, req ephemeral.CloseRequest, resp *ephemeral.CloseResponse) {
leaseID, diags := req.Private.GetKey(ctx, "lease_id")
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}
if err := r.client.RevokeLease(ctx, string(leaseID)); err != nil {
resp.Diagnostics.AddError("Error closing Token", err.Error())
}
}
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:
var _ provider.ProviderWithEphemeralResources = &examplecloudProvider{}
func (p *examplecloudProvider) EphemeralResources(_ context.Context) []func() ephemeral.EphemeralResource {
return []func() ephemeral.EphemeralResource{
NewTokenEphemeralResource(),
}
}
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
GitHub 저장소
자주 묻는 질문
provider-ephemeral-resources Skill이란 무엇인가요?
provider-ephemeral-resources은(는) hashicorp이(가) 만든 Claude Skill입니다. Skill은 Claude가 필요할 때 불러오는 지침과 리소스를 묶어 추가 프롬프트 없이 provider-ephemeral-resources 관련 작업을 수행할 수 있게 합니다.
provider-ephemeral-resources은(는) 어떻게 설치하나요?
이 페이지의 설치 명령을 사용하세요. provider-ephemeral-resources을(를) Claude Code 플러그인으로 추가하거나 저장소를 skills 디렉터리에 복제한 다음 Claude를 다시 시작해 Skill을 불러옵니다.
provider-ephemeral-resources은(는) 어떤 카테고리에 속하나요?
provider-ephemeral-resources은(는) 디자인 카테고리에 속합니다.
provider-ephemeral-resources은(는) 무료로 사용할 수 있나요?
네. provider-ephemeral-resources은(는) AIMCP에 등록되어 있으며 무료로 설치할 수 있습니다.
연관 스킬
executing-plans 스킬은 검토 체크포인트가 포함된 통제된 배치로 실행할 완전한 구현 계획이 있을 때 사용합니다. 이 스킬은 계획을 불러와 비판적으로 검토한 후, 소규모 배치(기본값 3개 작업)로 작업을 실행하면서 각 배치 사이에 진행 상황을 아키텍트 검토를 위해 보고합니다. 이를 통해 내재된 품질 관리 체크포인트를 갖춘 체계적인 구현이 보장됩니다.
이 스킬은 코드 변경 사항을 요구 사항에 따라 분석하기 위해 코드 리뷰어 하위 에이전트를 호출합니다. 작업 완료 후, 주요 기능 구현 후, 또는 메인 브랜치에 병합하기 전에 사용해야 합니다. 이 리뷰는 현재 구현체와 원래 계획을 비교하여 문제를 조기에 발견하는 데 도움이 됩니다.
이 스킬은 개발자들이 HTTP, stdio 또는 SSE 전송 방식을 통해 MCP 서버를 Claude Code에 연결하는 포괄적인 가이드를 제공합니다. GitHub, Notion 및 사용자 정의 API와 같은 외부 서비스를 통합하기 위한 설치, 구성, 인증 및 보안을 다룹니다. MCP 통합 설정, 외부 도구 구성 또는 Claude의 모델 컨텍스트 프로토콜 작업 시 활용하세요.
이 스킬은 작업 분석을 기반으로 개발자가 Claude Code 웹 인터페이스와 CLI 인터페이스 중 선택할 수 있도록 돕고, 두 환경 간 원활한 세션 텔레포트를 가능하게 합니다. 웹, CLI 또는 모바일 환경 전환 시 세션 상태와 컨텍스트를 관리하여 워크플로를 최적화합니다. 다양한 단계에서 서로 다른 도구가 필요한 복잡한 프로젝트에 사용하세요.
