Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ func (a *DoSomethingAction) Metadata(ctx context.Context, req action.MetadataReq

The [`action.Action` interface `Schema` method](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/action#Action.Schema) defines a [schema](/terraform/plugin/framework/handling-data/schemas) describing what data is available in the action configuration. An action itself does not have output data that can be referenced by other parts of a Terraform configuration.

### Unlinked action
### Action

An unlinked action is an action type that cannot make changes to state, which can be defined by using the [`schema.UnlinkedSchema`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/action/schema#UnlinkedSchema) type in the `Schema` field:
An action can be defined by using the [`schema.Schema`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/action/schema#Schema) type in the `Schema` field:

```go
func (a *DoSomethingAction) Schema(ctx context.Context, req action.SchemaRequest, resp *action.SchemaResponse) {
resp.Schema = schema.UnlinkedSchema{
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"required_string": schema.StringAttribute{
Required: true,
Expand All @@ -63,7 +63,7 @@ func (a *DoSomethingAction) Schema(ctx context.Context, req action.SchemaRequest
}
```

Unlinked actions can only return diagnostics and progress messages (during [`Invoke`](#invoke-method)). Unlinked actions still participate in planning operations
Actions can only return diagnostics and progress messages (during [`Invoke`](#invoke-method)). Actions still participate in planning operations
via [`ModifyPlan`](#modifyplan-method), which can be used as an "online" validation for the action configuration.


Expand Down Expand Up @@ -173,7 +173,7 @@ type DoThingActionModel struct {
}

func (e *DoThingAction) Schema(ctx context.Context, req action.SchemaRequest, resp *action.SchemaResponse) {
resp.Schema = schema.UnlinkedSchema{
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{
Description: "Name of the thing to do something to.",
Expand Down Expand Up @@ -337,9 +337,7 @@ func (d DoThingAction) ValidateConfig(ctx context.Context, req action.ValidateCo
## ModifyPlan method

Actions have a limited ability to participate in the planning process of Terraform, which is facilitated by the `PlanAction` RPC. As actions do not have any output data that can be consumed by
other parts of the Terraform configuration, the only impact an action can have on the plan is by returning diagnostics, like performing validation that requires API client access.

Action types that can modify resource state will be able to plan whatever changes are needed during the `PlanAction` RPC. These action types are not available in Terraform 1.14, but are planned for future releases.
other parts of the Terraform configuration, the only impact an action can have on the plan is by returning diagnostics, like performing validation that requires API client access. Actions are currently not able to propose resource state modifications during the plan, but future work is planned to support this.

Actions can participate in the planning operation of Terraform by implementing the [`action.ActionWithModifyPlan` interface](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/action#ActionWithModifyPlan). For example:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,7 @@ can use actions to express workflows that don't strictly fit into typical [CRUD
such as disaster recovery or ad-hoc maintenance. Actions can be invoked directly with the Terraform CLI or with
a trigger in a plan/apply workflow.

## Action types

Each action in a provider has a statically defined action type in the [schema](/terraform/plugin/framework/actions/implementation#schema-method), which informs Terraform how the action can be used
by the practitioner and what effect the action can have on [resource state](/terraform/plugin/framework/handling-data/terraform-concepts#state).
Currently, the only available action type is:

- [Unlinked](/terraform/plugin/framework/actions/implementation#unlinked-action) - An action type that cannot cause changes to state.

Action types that can modify resource state are not available in Terraform 1.14, but are planned for future releases.
Actions are currently not able to modify resource state, but future work is planned to support this.

## Implementation

Expand Down
Loading