Package resource contains all interfaces, request types, and response types for a managed resource implementation.
In Terraform, a managed resource is a concept which enables provider developers to offer practitioners full lifecycle management (create, read, update, and delete) of a infrastructure component. Managed resources can also stand in for one-time infrastructure operations that require tracking, by implementing create logic, while omitting update and delete logic.
Resources are saved into the Terraform state and can be referenced by other parts of a configuration. Resources are defined by a resource type/name, such as "examplecloud_thing", a schema representing the structure and data types of configuration, plan, and state, and lifecycle logic.
The main starting point for implementations in this package is the Resource type which represents an instance of a resource type that has its own configuration, plan, state, and lifecycle logic. The resource.Resource implementations are referenced by the [provider.Provider] type Resources method, which enables the resource practitioner and testing usage.
This section is empty.
This section is empty.
ImportStatePassthroughID is a helper function to set the import identifier to a given state attribute path. The attribute must accept a string value.
For resources that support identity, this method will also automatically pass through the Identity field if imported by the identity attribute of a import config block (Terraform 1.12+ and later). In this scenario where identity is provided instead of the string ID, the state field defined at `attrPath` will be set to null.
ImportStatePassthroughWithIdentity is a helper function to retrieve either the import identifier or a given identity attribute that is then used to set to given attribute path in state, based on the method used by the practitioner to import. The identity and state attributes provided must be of type string.
The helper method should only be used on resources that support identity via the resource.ResourceWithIdentity interface.
This method will also automatically pass through the Identity field if imported by the identity attribute of a import config block (Terraform 1.12+ and later).
ConfigValidator describes reusable Resource configuration validation functionality.
type ConfigureRequest struct { ProviderData any }
ConfigureRequest represents a request for the provider to configure a resource, i.e., set provider-level data or clients. An instance of this request struct is supplied as an argument to the Resource type Configure method.
ConfigureResponse represents a response to a ConfigureRequest. An instance of this response struct is supplied as an argument to the Resource type Configure method.
CreateRequest represents a request for the provider to create a resource. An instance of this request struct is supplied as an argument to the resource's Create function.
CreateResponse represents a response to a CreateRequest. An instance of this response struct is supplied as an argument to the resource's Create function, in which the provider should set values on the CreateResponse as appropriate.
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 subject to change or break without warning. It is not protected by version compatibility guarantees.
type DeferredReason int32
DeferredReason represents different reasons for deferring a change.
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.
DeleteRequest represents a request for the provider to delete a resource. An instance of this request struct is supplied as an argument to the resource's Delete function.
DeleteResponse represents a response to a DeleteRequest. An instance of this response struct is supplied as an argument to the resource's Delete function, in which the provider should set values on the DeleteResponse as appropriate.
type IdentitySchemaRequest struct{}
IdentitySchemaRequest represents a request for the Resource to return its identity schema. An instance of this request struct is supplied as an argument to the Resource type IdentitySchema method.
IdentitySchemaResponse represents a response to a SchemaRequest. An instance of this response struct is supplied as an argument to the Resource type IdentitySchema method.
Implementation handler for an UpgradeIdentity operation.
This is used to encapsulate all upgrade logic from a prior identity to the current version when a Resource implements the ResourceWithUpgradeIdentity interface.
type ImportStateClientCapabilities struct { DeferralAllowed bool }
ImportStateClientCapabilities allows Terraform to publish information regarding optionally supported protocol features for the ImportResourceState RPC, such as forward-compatible Terraform behavior changes.
ImportStateRequest represents a request for the provider to import a resource. An instance of this request struct is supplied as an argument to the Resource's ImportState method.
ImportStateResponse represents a response to a ImportStateRequest. An instance of this response struct is supplied as an argument to the Resource's ImportState method, in which the provider should set values on the ImportStateResponse as appropriate.
type MetadataRequest struct { ProviderTypeName string }
MetadataRequest represents a request for the Resource to return metadata, such as its type name. An instance of this request struct is supplied as an argument to the Resource type Metadata method.
MetadataResponse represents a response to a MetadataRequest. An instance of this response struct is supplied as an argument to the Resource type Metadata method.
type ModifyPlanClientCapabilities struct { DeferralAllowed bool }
ModifyPlanClientCapabilities allows Terraform to publish information regarding optionally supported protocol features for the PlanResourceChange RPC, such as forward-compatible Terraform behavior changes.
ModifyPlanRequest represents a request for the provider to modify the planned new state that Terraform has generated for the resource.
ModifyPlanResponse represents a response to a ModifyPlanRequest. An instance of this response struct is supplied as an argument to the resource's ModifyPlan function, in which the provider should modify the Plan and populate the RequiresReplace field as appropriate.
MoveStateRequest represents a request for the provider to move a source resource state into the target resource state with any necessary data transformation logic. An instance of this request struct is supplied as an argument to each [StateMover.StateMover].
MoveStateResponse represents a response to a MoveStateRequest. An instance of this response struct is supplied as an argument to StateMover implementations. The provider should set response values only within the implementation that aligns with a supported request, or put differently, a response that contains no error diagnostics nor state is considered as skipped by the framework. Any fulfilling response, whether via error diagnostics or state data, will cause the framework to not call other implementations and immediately return that response. The framework will return an implementation not found error if all implementations return responses without error diagnostics and state.
type ProviderDeferredBehavior struct { EnablePlanModification bool }
ProviderDeferredBehavior enables provider-defined logic to be executed in the case of a deferred response from provider configuration.
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.
type ReadClientCapabilities struct { DeferralAllowed bool }
ReadClientCapabilities allows Terraform to publish information regarding optionally supported protocol features for the ReadResource RPC, such as forward-compatible Terraform behavior changes.
ReadRequest represents a request for the provider to read a resource, i.e., update values in state according to the real state of the resource. An instance of this request struct is supplied as an argument to the resource's Read function.
ReadResponse represents a response to a ReadRequest. An instance of this response struct is supplied as an argument to the resource's Read function, in which the provider should set values on the ReadResponse as appropriate.
type Resource interface { Metadata(context.Context, MetadataRequest, *MetadataResponse) Schema(context.Context, SchemaRequest, *SchemaResponse) Create(context.Context, CreateRequest, *CreateResponse) Read(context.Context, ReadRequest, *ReadResponse) Update(context.Context, UpdateRequest, *UpdateResponse) Delete(context.Context, DeleteRequest, *DeleteResponse) }
Resource represents an instance of a managed resource type. This is the core interface that all resources must implement.
Resources can optionally implement these additional concepts:
Although not required, it is conventional for resources to implement the ResourceWithImportState interface.
ResourceBehavior controls framework-specific logic when interacting with a resource.
ResourceWithConfigValidators is an interface type that extends Resource to include declarative validations.
Declaring validation using this methodology simplifies implmentation of reusable functionality. These also include descriptions, which can be used for automating documentation.
Validation will include ConfigValidators and ValidateConfig, if both are implemented, in addition to any Attribute or Type validation.
ResourceWithConfigure is an interface type that extends Resource to include a method which the framework will automatically call so provider developers have the opportunity to setup any necessary provider-level data or clients in the Resource type.
This method is intended to replace the provider.ResourceType type NewResource method in a future release.
ResourceWithIdentity is an interface type that extends Resource to implement managed resource identity.
Managed resources can optionally define an identity schema, which represents a separate object stored in state alongside the resource instance data. This identity data is used by Terraform to uniquely identify managed resources and has additional restrictions that allow external programs to determine equality between two identities.
Resource identity schemas can only contain primitive (bool, string, number) attributes and lists that contain primitive elements. Additionally, a resource identity should have the following properties:
Optional interface on top of Resource that enables provider control over the ImportResourceState RPC. This RPC is called by Terraform when the `terraform import` command is executed. Afterwards, the ReadResource RPC is executed to allow providers to fully populate the resource state.
ResourceWithModifyPlan represents a resource instance with a ModifyPlan function.
Optional interface on top of Resource that enables provider control over the MoveResourceState RPC. This RPC is called by Terraform when there is a `moved` configuration block that changes the resource type and where this Resource is the target resource type. Since state data operations can cause data loss for practitioners, this support is explicitly opt-in to ensure that all data transformation logic is explicitly defined by the provider.
If the Resource does not implement this interface and Terraform sends a MoveResourceState request, the framework will automatically return an error diagnostic notifying the practitioner that this resource does not support the requested operation.
This functionality is only supported in Terraform 1.8 and later.
Optional interface on top of Resource that enables provider control over the UpgradeResourceState RPC. This RPC is automatically called by Terraform when the current Schema type Version field is greater than the stored state. Terraform does not store previous Schema information, so any breaking changes to state data types must be handled by providers.
Terraform CLI can execute the UpgradeResourceState RPC even when the prior state version matches the current schema version. The framework will automatically intercept this request and attempt to respond with the existing state. In this situation the framework will not execute any provider defined logic, so declaring it for this version is extraneous.
ResourceWithValidateConfig is an interface type that extends Resource to include imperative validation.
Declaring validation using this methodology simplifies one-off functionality that typically applies to a single resource. Any documentation of this functionality must be manually added into schema descriptions.
Validation will include ConfigValidators and ValidateConfig, if both are implemented, in addition to any Attribute or Type validation.
type SchemaRequest struct{}
SchemaRequest represents a request for the Resource to return its schema. An instance of this request struct is supplied as an argument to the Resource type Schema method.
SchemaResponse represents a response to a SchemaRequest. An instance of this response struct is supplied as an argument to the Resource type Schema method.
Implementation handler for a state move operation. After determining the source resource is supported, this should encapsulate all data transformation logic from a source resource to the current schema version of this Resource. The Resource is connected to these implementations by implementing the ResourceWithMoveState interface.
This functionality is only available in Terraform 1.8 or later. It is invoked when a configuration contains a `moved` configuration block where the source resource type in the `from` argument differs from the target resource type in the `to` argument, causing Terraform to call this provider operation and the framework to route the request to this Resource as the target.
Each implementation is responsible for determining whether the request should be handled or skipped. The implementation is considered skipped by the framework when the response contains no error diagnostics or state. Otherwise, any error diagnostics or state data, will cause the framework to consider the request completed and not call other StateMover implementations. The framework will return an implementation not found error if all implementations return responses without error diagnostics or state.
Implementation handler for a UpgradeState operation.
This is used to encapsulate all upgrade logic from a prior state to the current schema version when a Resource implements the ResourceWithUpgradeState interface.
UpdateRequest represents a request for the provider to update a resource. An instance of this request struct is supplied as an argument to the resource's Update function.
UpdateResponse represents a response to an UpdateRequest. An instance of this response struct is supplied as an argument to the resource's Update function, in which the provider should set values on the UpdateResponse as appropriate.
Request information for the provider logic to update a resource identity from a prior resource identity version to the current identity version.
Response information for the provider logic to update a resource identity from a prior resource identity version to the current identity version.
Request information for the provider logic to update a resource state from a prior state version to the current schema version. An instance of this is supplied as a parameter to a StateUpgrader, which ultimately comes from a Resource's UpgradeState method.
Response information for the provider logic to update a resource state from a prior state version to the current schema version. An instance of this is supplied as a parameter to a StateUpgrader, which ultimately came from a Resource's UpgradeState method.
type ValidateConfigClientCapabilities struct { WriteOnlyAttributesAllowed bool }
ValidateConfigClientCapabilities allows Terraform to publish information regarding optionally supported protocol features for the ValidateResourceConfig RPC, such as forward-compatible Terraform behavior changes.
ValidateConfigRequest represents a request to validate the configuration of a resource. An instance of this request struct is supplied as an argument to the Resource ValidateConfig receiver method or automatically passed through to each ConfigValidator.
ValidateConfigResponse represents a response to a ValidateConfigRequest. An instance of this response struct is supplied as an argument to the Resource ValidateConfig receiver method or automatically passed through to each ConfigValidator.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4