ephemeral
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package ephemeral contains all interfaces, request types, and responsetypes for an ephemeral resource implementation.
In Terraform, an ephemeral resource is a concept which enables providerdevelopers to offer practitioners ephemeral values, which will not be storedin any artifact produced by Terraform (plan/state). Ephemeral resources canoptionally implement renewal logic via the (EphemeralResource).Renew methodand cleanup logic via the (EphemeralResource).Close method.
Ephemeral resources are not saved into the Terraform plan or state and canonly be referenced in other ephemeral values, such as provider configurationattributes. Ephemeral resources are defined by a type/name, such as "examplecloud_thing",a schema representing the structure and data types of configuration, and lifecycle logic.
The main starting point for implementations in this package is theEphemeralResource type which represents an instance of an ephemeral resourcethat has its own configuration and lifecycle logic. Theephemeral.EphemeralResourceimplementations are referenced by the [provider.ProviderWithEphemeralResources] typeEphemeralResources method, which enables the ephemeral resource practitioner usage.
Index¶
- type CloseRequest
- type CloseResponse
- type ConfigValidator
- type ConfigureRequest
- type ConfigureResponse
- type Deferred
- type DeferredReason
- type EphemeralResource
- type EphemeralResourceWithClose
- type EphemeralResourceWithConfigValidators
- type EphemeralResourceWithConfigure
- type EphemeralResourceWithRenew
- type EphemeralResourceWithValidateConfig
- type MetadataRequest
- type MetadataResponse
- type OpenClientCapabilities
- type OpenRequest
- type OpenResponse
- type RenewRequest
- type RenewResponse
- type SchemaRequest
- type SchemaResponse
- type ValidateConfigRequest
- type ValidateConfigResponse
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeCloseRequest¶
type CloseRequest struct {// Private is provider-defined ephemeral resource private state data// which was previously provided by the latest Open or Renew operation.//// Use the GetKey method to read data.Private *privatestate.ProviderData}CloseRequest represents a request for the provider to close an ephemeralresource. An instance of this request struct is supplied as an argument tothe ephemeral resource's Close function.
typeCloseResponse¶
type CloseResponse struct {// Diagnostics report errors or warnings related to closing the// resource. An empty slice indicates a successful operation with no// warnings or errors generated.Diagnosticsdiag.Diagnostics}CloseResponse represents a response to a CloseRequest. Aninstance of this response struct is supplied as an argumentto the ephemeral resource's Close function, in which the providershould set values on the CloseResponse as appropriate.
typeConfigValidator¶
type ConfigValidator interface {// Description describes the validation in plain text formatting.//// This information may be automatically added to ephemeral resource plain text// descriptions by external tooling.Description(context.Context)string// MarkdownDescription describes the validation in Markdown formatting.//// This information may be automatically added to ephemeral resource Markdown// descriptions by external tooling.MarkdownDescription(context.Context)string// ValidateEphemeralResource performs the validation.//// This method name is separate from ConfigValidators in resource and other packages in// order to allow generic validators.ValidateEphemeralResource(context.Context,ValidateConfigRequest, *ValidateConfigResponse)}ConfigValidator describes reusable EphemeralResource configuration validation functionality.
typeConfigureRequest¶
type ConfigureRequest struct {// ProviderData is the data set in the// [provider.ConfigureResponse.EphemeralResourceData] field. This data is// provider-specifc and therefore can contain any necessary remote system// clients, custom provider data, or anything else pertinent to the// functionality of the EphemeralResource.//// This data is only set after the ConfigureProvider RPC has been called// by Terraform.ProviderDataany}ConfigureRequest represents a request for the provider to configure anephemeral resource, i.e., set provider-level data or clients. An instance ofthis request struct is supplied as an argument to the EphemeralResource typeConfigure method.
typeConfigureResponse¶
type ConfigureResponse struct {// Diagnostics report errors or warnings related to configuring of the// EphemeralResource. An empty slice indicates a successful operation with no// warnings or errors generated.Diagnosticsdiag.Diagnostics}ConfigureResponse represents a response to a ConfigureRequest. Aninstance of this response struct is supplied as an argument to theEphemeralResource type Configure method.
typeDeferred¶
type Deferred struct {// Reason is the reason for deferring the change.ReasonDeferredReason}Deferred is used to indicate to Terraform that a change needs to be deferred for a reason.
NOTE: This functionality is related to deferred action support, which is currently experimental and is subjectto change or break without warning. It is not protected by version compatibility guarantees.
typeDeferredReason¶
type DeferredReasonint32
DeferredReason represents different reasons for deferring a change.
NOTE: This functionality is related to deferred action support, which is currently experimental and is subjectto change or break without warning. It is not protected by version compatibility guarantees.
const (// DeferredReasonUnknown is used to indicate an invalid `DeferredReason`.// Provider developers should not use it.DeferredReasonUnknownDeferredReason = 0// DeferredReasonEphemeralResourceConfigUnknown is used to indicate that the resource configuration// is partially unknown and the real values need to be known before the change can be planned.DeferredReasonEphemeralResourceConfigUnknownDeferredReason = 1// DeferredReasonProviderConfigUnknown is used to indicate that the provider configuration// is partially unknown and the real values need to be known before the change can be planned.DeferredReasonProviderConfigUnknownDeferredReason = 2// DeferredReasonAbsentPrereq is used to indicate that a hard dependency has not been satisfied.DeferredReasonAbsentPrereqDeferredReason = 3)
func (DeferredReason)String¶
func (dDeferredReason) String()string
typeEphemeralResource¶
type EphemeralResource interface {// Metadata should return the full name of the ephemeral resource, such as// examplecloud_thing.Metadata(context.Context,MetadataRequest, *MetadataResponse)// Schema should return the schema for this ephemeral resource.Schema(context.Context,SchemaRequest, *SchemaResponse)// Open is called when the provider must generate a new ephemeral resource. Config values// should be read from the OpenRequest and new response values set on the OpenResponse.Open(context.Context,OpenRequest, *OpenResponse)}EphemeralResource represents an instance of an ephemeral resource type. This is the coreinterface that all ephemeral resources must implement.
Ephemeral resources can optionally implement these additional concepts:
Configure: Include provider-level data or clients via EphemeralResourceWithConfigure
Validation: Schema-based or entire configuration via EphemeralResourceWithConfigValidatorsor EphemeralResourceWithValidateConfig.
Renew: Handle renewal of an expired remote object via EphemeralResourceWithRenew.Ephemeral resources can indicate to Terraform when a renewal must occur via the RenewAtresponse field of the Open/Renew methods. Renew cannot return new result data for theephemeral resource instance, so this logic is only appropriate for remote objects likeHashiCorp Vault leases, which can be renewed without changing their data.
Close: Allows providers to clean up the ephemeral resource via EphemeralResourceWithClose.
typeEphemeralResourceWithClose¶
type EphemeralResourceWithClose interface {EphemeralResource// Close is called when the provider can clean up the ephemeral resource.// Config values may be read from the CloseRequest.Close(context.Context,CloseRequest, *CloseResponse)}EphemeralResourceWithClose is an interface type that extendsEphemeralResource to include a method which the framework will call whenTerraform determines that the ephemeral resource can be safely cleaned up.
typeEphemeralResourceWithConfigValidators¶
type EphemeralResourceWithConfigValidators interface {EphemeralResource// ConfigValidators returns a list of functions which will all be performed during validation.ConfigValidators(context.Context) []ConfigValidator}EphemeralResourceWithConfigValidators is an interface type that extends EphemeralResource to include declarative validations.
Declaring validation using this methodology simplifies implementation ofreusable functionality. These also include descriptions, which can be usedfor automating documentation.
Validation will include ConfigValidators and ValidateConfig, if both areimplemented, in addition to any Attribute or Type validation.
typeEphemeralResourceWithConfigure¶
type EphemeralResourceWithConfigure interface {EphemeralResource// Configure enables provider-level data or clients to be set in the// provider-defined EphemeralResource type.Configure(context.Context,ConfigureRequest, *ConfigureResponse)}EphemeralResourceWithConfigure is an interface type that extends EphemeralResource toinclude a method which the framework will automatically call so providerdevelopers have the opportunity to setup any necessary provider-level dataor clients in the EphemeralResource type.
typeEphemeralResourceWithRenew¶
type EphemeralResourceWithRenew interface {EphemeralResource// Renew is called when the provider must renew the ephemeral resource based on// the provided RenewAt time. This RenewAt response field can be set in the OpenResponse and RenewResponse.//// Renew cannot return new result data for the ephemeral resource instance, so this logic is only appropriate// for remote objects like HashiCorp Vault leases, which can be renewed without changing their data.Renew(context.Context,RenewRequest, *RenewResponse)}EphemeralResourceWithRenew is an interface type that extends EphemeralResource toinclude a method which the framework will call when Terraform detects that theprovider-defined returned RenewAt time for an ephemeral resource has passed. This RenewAtresponse field can be set in the OpenResponse and RenewResponse.
typeEphemeralResourceWithValidateConfig¶
type EphemeralResourceWithValidateConfig interface {EphemeralResource// ValidateConfig performs the validation.ValidateConfig(context.Context,ValidateConfigRequest, *ValidateConfigResponse)}EphemeralResourceWithValidateConfig is an interface type that extends EphemeralResource to include imperative validation.
Declaring validation using this methodology simplifies one-offfunctionality that typically applies to a single ephemeral resource. Any documentationof this functionality must be manually added into schema descriptions.
Validation will include ConfigValidators and ValidateConfig, if both areimplemented, in addition to any Attribute or Type validation.
typeMetadataRequest¶
type MetadataRequest struct {// ProviderTypeName is the string returned from// [provider.MetadataResponse.TypeName], if the Provider type implements// the Metadata method. This string should prefix the EphemeralResource type name// with an underscore in the response.ProviderTypeNamestring}MetadataRequest represents a request for the EphemeralResource to return metadata,such as its type name. An instance of this request struct is supplied asan argument to the EphemeralResource type Metadata method.
typeMetadataResponse¶
type MetadataResponse struct {// TypeName should be the full ephemeral resource type, including the provider// type prefix and an underscore. For example, examplecloud_thing.TypeNamestring}MetadataResponse represents a response to a MetadataRequest. Aninstance of this response struct is supplied as an argument to theEphemeralResource type Metadata method.
typeOpenClientCapabilities¶
type OpenClientCapabilities struct {// DeferralAllowed indicates whether the Terraform client initiating// the request allows a deferral response.//// NOTE: This functionality is related to deferred action support, which is currently experimental and is subject// to change or break without warning. It is not protected by version compatibility guarantees.DeferralAllowedbool}OpenClientCapabilities allows Terraform to publish informationregarding optionally supported protocol features for the OpenEphemeralResource RPC,such as forward-compatible Terraform behavior changes.
typeOpenRequest¶
type OpenRequest struct {// Config is the configuration the user supplied for the ephemeral// resource.Configtfsdk.Config// ClientCapabilities defines optionally supported protocol features for the// OpenEphemeralResource RPC, such as forward-compatible Terraform behavior changes.ClientCapabilitiesOpenClientCapabilities}OpenRequest represents a request for the provider to open an ephemeralresource. An instance of this request struct is supplied as an argument tothe ephemeral resource's Open function.
typeOpenResponse¶
type OpenResponse struct {// Result is the object representing the values of the ephemeral// resource following the Open operation. This field is pre-populated// from OpenRequest.Config and should be set during the resource's Open// operation.Resulttfsdk.EphemeralResultData// Private is the private state ephemeral resource data following the// Open operation. This field is not pre-populated as there is no// pre-existing private state data during the ephemeral resource's// Open operation.//// This private data will be passed to any Renew or Close operations.Private *privatestate.ProviderData// RenewAt is an optional date/time field that indicates to Terraform// when this ephemeral resource must be renewed at. Terraform will call// the (EphemeralResource).Renew method when the current date/time is on// or after RenewAt during a Terraform operation.//// It is recommended to add extra time (usually no more than a few minutes)// before an ephemeral resource expires to account for latency.RenewAttime.Time// Diagnostics report errors or warnings related to opening the ephemeral// resource. An empty slice indicates a successful operation with no// warnings or errors generated.Diagnosticsdiag.Diagnostics// Deferred indicates that Terraform should defer opening this// ephemeral resource until a followup apply operation.//// This field can only be set if// `(ephemeral.OpenRequest).ClientCapabilities.DeferralAllowed` is true.//// NOTE: This functionality is related to deferred action support, which is currently experimental and is subject// to change or break without warning. It is not protected by version compatibility guarantees.Deferred *Deferred}OpenResponse represents a response to a OpenRequest. Aninstance of this response struct is supplied as an argumentto the ephemeral resource's Open function, in which the providershould set values on the OpenResponse as appropriate.
typeRenewRequest¶
type RenewRequest struct {// Private is provider-defined ephemeral resource private state data// which was previously provided by the latest Open or Renew operation.// Any existing data is copied to RenewResponse.Private to prevent// accidental private state data loss.//// Use the GetKey method to read data. Use the SetKey method on// RenewResponse.Private to update or remove a value.Private *privatestate.ProviderData}RenewRequest represents a request for the provider to renew an ephemeralresource. An instance of this request struct is supplied as an argument tothe ephemeral resource's Renew function.
typeRenewResponse¶
type RenewResponse struct {// RenewAt is an optional date/time field that indicates to Terraform// when this ephemeral resource must be renewed at. Terraform will call// the (EphemeralResource).Renew method when the current date/time is on// or after RenewAt during a Terraform operation.//// It is recommended to add extra time (usually no more than a few minutes)// before an ephemeral resource expires to account for latency.RenewAttime.Time// Private is the private state ephemeral resource data following the// Renew operation. This field is pre-populated from RenewRequest.Private// and can be modified during the ephemeral resource's Renew operation.//// This private data will be passed to any Renew or Close operations.Private *privatestate.ProviderData// Diagnostics report errors or warnings related to renewing the ephemeral// resource. An empty slice indicates a successful operation with no// warnings or errors generated.Diagnosticsdiag.Diagnostics}RenewResponse represents a response to a RenewRequest. Aninstance of this response struct is supplied as an argumentto the ephemeral resource's Renew function, in which the providershould set values on the RenewResponse as appropriate.
typeSchemaRequest¶
type SchemaRequest struct{}SchemaRequest represents a request for the EphemeralResource to return its schema.An instance of this request struct is supplied as an argument to theEphemeralResource type Schema method.
typeSchemaResponse¶
type SchemaResponse struct {// Schema is the schema of the ephemeral resource.Schemaschema.Schema// Diagnostics report errors or warnings related to retrieving the ephemeral// resource schema. An empty slice indicates success, with no warnings// or errors generated.Diagnosticsdiag.Diagnostics}SchemaResponse represents a response to a SchemaRequest. An instance of thisresponse struct is supplied as an argument to the EphemeralResource type Schemamethod.
typeValidateConfigRequest¶
type ValidateConfigRequest struct {// Config is the configuration the user supplied for the ephemeral resource.//// This configuration may contain unknown values if a user uses// interpolation or other functionality that would prevent Terraform// from knowing the value at request time.Configtfsdk.Config}ValidateConfigRequest represents a request to validate theconfiguration of an ephemeral resource. An instance of this request struct issupplied as an argument to the EphemeralResource ValidateConfig receiver methodor automatically passed through to each ConfigValidator.
typeValidateConfigResponse¶
type ValidateConfigResponse struct {// Diagnostics report errors or warnings related to validating the ephemeral resource// configuration. An empty slice indicates success, with no warnings or// errors generated.Diagnosticsdiag.Diagnostics}ValidateConfigResponse represents a response to aValidateConfigRequest. An instance of this response struct issupplied as an argument to the EphemeralResource ValidateConfig receiver methodor automatically passed through to each ConfigValidator.