pub trait Resource: Send + Sync {
type State<'a>: Serialize + Deserialize<'a> + Send;
type PrivateState<'a>: Serialize + Deserialize<'a> + Send;
type ProviderMetaState<'a>: Serialize + Deserialize<'a> + Send;
// Required methods
fn schema(&self, diags: &mut Diagnostics) -> Option<Schema>;
fn read<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
state: Self::State<'a>,
private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn plan_create<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
proposed_state: Self::State<'a>,
config_state: Self::State<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn plan_update<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
prior_state: Self::State<'a>,
proposed_state: Self::State<'a>,
config_state: Self::State<'a>,
prior_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>, Vec<AttributePath>)>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn plan_destroy<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
prior_state: Self::State<'a>,
prior_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<Self::PrivateState<'a>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn create<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
planned_state: Self::State<'a>,
config_state: Self::State<'a>,
planned_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn update<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
prior_state: Self::State<'a>,
planned_state: Self::State<'a>,
config_state: Self::State<'a>,
planned_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn destroy<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
prior_state: Self::State<'a>,
planned_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn validate<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
config: Self::State<'a>,
) -> Pin<Box<dyn Future<Output = Option<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn import<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
id: String,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn upgrade<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
version: i64,
prior_state: RawValue,
) -> Pin<Box<dyn Future<Output = Option<Self::State<'a>>> + Send + 'async_trait>>
where Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Trait for implementing a resource with automatic serialization/deserialization
See also: DynamicResource
Required Associated Types§
Sourcetype State<'a>: Serialize + Deserialize<'a> + Send
type State<'a>: Serialize + Deserialize<'a> + Send
State of the resource
The state will be automatically serialized/deserialized at the border of the request.
Sourcetype PrivateState<'a>: Serialize + Deserialize<'a> + Send
type PrivateState<'a>: Serialize + Deserialize<'a> + Send
Private state of the resource
The private state will be automatically serialized/deserialized at the border of the request.
Sourcetype ProviderMetaState<'a>: Serialize + Deserialize<'a> + Send
type ProviderMetaState<'a>: Serialize + Deserialize<'a> + Send
State of the provider metadata
The state will be automatically serialized/deserialized at the border of the request.
Required Methods§
Sourcefn schema(&self, diags: &mut Diagnostics) -> Option<Schema>
fn schema(&self, diags: &mut Diagnostics) -> Option<Schema>
Sourcefn read<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
state: Self::State<'a>,
private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn read<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
state: Self::State<'a>,
private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read the new state of the resource
§Arguments
diags- Diagnostics to record warnings and errors that occured during the readstate- State as stored in the Terraform stateprivate_state- Private state as stored in the Terraform stateprovider_meta_state- State of the provider metadata as declared in the Terraform file
§Remarks
Return must be None if the resource has been destroyed externally.
Return must be Some if the resource is still there, even if there was errors while reading the resource.
Sourcefn plan_create<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
proposed_state: Self::State<'a>,
config_state: Self::State<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn plan_create<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
proposed_state: Self::State<'a>,
config_state: Self::State<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Plan the creation of a new resource
§Arguments
diags- Diagnostics to record warnings and errors that occured during the planproposed_state- State proposed by Terraformconfig_state- State as declared in the Terraform fileprovider_meta_state- State of the provider metadata as declared in the Terraform file
§Remarks
The return is ignored if there is an error in diagnostics.
If the return is None, an ad-hoc error is added to diagnostics.
Sourcefn plan_update<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
prior_state: Self::State<'a>,
proposed_state: Self::State<'a>,
config_state: Self::State<'a>,
prior_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>, Vec<AttributePath>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn plan_update<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
prior_state: Self::State<'a>,
proposed_state: Self::State<'a>,
config_state: Self::State<'a>,
prior_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>, Vec<AttributePath>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Plan the changes on the resource
§Arguments
diags- Diagnostics to record warnings and errors that occured during the planprior_state- State as stored in the Terraform stateproposed_state- State proposed by Terraformconfig_state- State as declared in the Terraform fileprivate_state- Private state as stored in the Terraform stateprovider_meta_state- State of the provider metadata as declared in the Terraform file
§Remarks
The return is ignored if there is an error in diagnostics.
If the return is None, an ad-hoc error is added to diagnostics.
Sourcefn plan_destroy<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
prior_state: Self::State<'a>,
prior_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<Self::PrivateState<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn plan_destroy<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
prior_state: Self::State<'a>,
prior_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<Self::PrivateState<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Plan the destruction of the resource
§Arguments
diags- Diagnostics to record warnings and errors that occured during the planprior_state- State as stored in the Terraform stateprior_private_state- Private state as stored in the Terraform stateprovider_meta_state- State of the provider metadata as declared in the Terraform file
§Remarks
The return is ignored if there is an error in diagnostics.
If the return is None, an ad-hoc error is added to diagnostics.
Sourcefn create<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
planned_state: Self::State<'a>,
config_state: Self::State<'a>,
planned_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
planned_state: Self::State<'a>,
config_state: Self::State<'a>,
planned_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Create a new resource
§Arguments
diags- Diagnostics to record warnings and errors that occured during the creationplanned_state- State proposed by the provider upon planconfig_state- State as declared in the Terraform fileplanned_private_state- Private state proposed by the provider upon planprovider_meta_state- State of the provider metadata as declared in the Terraform file
§Remarks
If the return is None, an ad-hoc error is added to diagnostics.
Return must be Some if the resource was created, even if there was errors while creating the resource.
Sourcefn update<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
prior_state: Self::State<'a>,
planned_state: Self::State<'a>,
config_state: Self::State<'a>,
planned_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
prior_state: Self::State<'a>,
planned_state: Self::State<'a>,
config_state: Self::State<'a>,
planned_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Apply the changes on the resource
§Arguments
diags- Diagnostics to record warnings and errors that occured during the updateprior_state- State as stored in the Terraform stateplanned_state- State proposed by the provider upon planconfig_state- State as declared in the Terraform fileplanned_private_state- Private state proposed by the provider upon planprovider_meta_state- State of the provider metadata as declared in the Terraform file
§Remarks
If the return is None, an ad-hoc error is added to diagnostics, and the resource state is kept unchanged.
Return must be Some if the resource was updated, even if there was errors while updated the resource.
Sourcefn destroy<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
prior_state: Self::State<'a>,
planned_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn destroy<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
prior_state: Self::State<'a>,
planned_private_state: Self::PrivateState<'a>,
provider_meta_state: Self::ProviderMetaState<'a>,
) -> Pin<Box<dyn Future<Output = Option<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Destroy the resource
§Arguments
diags- Diagnostics to record warnings and errors that occured during the destructionprior_state- State as stored in the Terraform stateplanned_private_state- Private state proposed by the provider upon planprovider_meta_state- State of the provider metadata as declared in the Terraform file
§Remarks
The return is ignored if there is an error in diagnostics.
If the return is None, an ad-hoc error is added to diagnostics.
Provided Methods§
Sourcefn validate<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
config: Self::State<'a>,
) -> Pin<Box<dyn Future<Output = Option<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn validate<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
config: Self::State<'a>,
) -> Pin<Box<dyn Future<Output = Option<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Validate the configuration of the resource
§Arguments
diags- Diagnostics to record warnings and errors that occured during validationconfig- State as declared in the Terraform file
§Remarks
The return is ignored if there is an error in diagnostics.
If the return is None, an ad-hoc error is added to diagnostics.
Sourcefn import<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
id: String,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn import<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
id: String,
) -> Pin<Box<dyn Future<Output = Option<(Self::State<'a>, Self::PrivateState<'a>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Import an existing resource
§Arguments
diags- Diagnostics to record warnings and errors that occured during the importid- Opaque string that the provider can use to identify the actual resource to import
§Remarks
If the return is None, an ad-hoc error is added to diagnostics.
Return must be Some if the resource was imported, even if there was errors while importing the resource.
Sourcefn upgrade<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
version: i64,
prior_state: RawValue,
) -> Pin<Box<dyn Future<Output = Option<Self::State<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn upgrade<'a, 'life0, 'life1, 'async_trait>(
&'life0 self,
diags: &'life1 mut Diagnostics,
version: i64,
prior_state: RawValue,
) -> Pin<Box<dyn Future<Output = Option<Self::State<'a>>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Upgrade the resource from a prior version of the resource
§Arguments
diags- Diagnostics to record warnings and errors that occured during the importversion- Prior version of the resource to upgrade as recorded in Terraform stateprior_state- Prior state of the resource to upgrade as recorded in Terraform state
§Remarks
If the return is None, an ad-hoc error is added to diagnostics, and the resource state is kept unchanged.
Return must be Some if the resource was upgraded, even if there was errors while upgraded the resource.
Because the schema of the resource might have changed, the prior state must be deserialized explicitely.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.