Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation for mapping between SDKv2 and the Framework #660

Merged
merged 8 commits into from
Feb 10, 2023
9 changes: 9 additions & 0 deletions website/docs/plugin/framework/data-sources/timeouts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ resource "timeouts_example" "example" {
}
```

Import the [timeouts module](https://github.com/hashicorp/terraform-plugin-framework-timeouts).

```go
import (
/* ... */
"github.com/hashicorp/terraform-plugin-framework-timeouts/datasource/timeouts"
)
````
You can use this module to mutate the `schema.Schema` as follows:
```go
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,38 @@ This page explains how to migrate nested blocks that are not computed (i.e., do
[Blocks with Computed Fields](/plugin/framework/migrating/attributes-blocks/blocks-computed) for more details
about migrating nested blocks that contain fields that are computed.

The following table describes the mapping between [SDK Schema Fields](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-sdk/helper/schema#Schema) and the Framework.

| SDK Schema Field | Framework |
|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Type | [ListNestedBlock](/plugin/framework/migrating/attributes-blocks/blocks), [SetNestedBlock](/plugin/framework/migrating/attributes-blocks/blocks) |
| ConfigMode | Schema must be explictly defined using [Attributes](/plugin/framework/migrating/attributes-blocks/attribute-schema) and [Blocks](/plugin/framework/migrating/attributes-blocks/blocks) |
| Required | [listvalidator.IsRequired](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/listvalidator#IsRequired), [setvalidator.IsRequired](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/setvalidator#IsRequired) |
| Optional | N/A - no implementation required |
| Computed | [Blocks with Computed Fields](/plugin/framework/migrating/attributes-blocks/blocks-computed) |
| ForceNew | [RequiresReplace](/plugin/framework/migrating/attributes-blocks/force-new) on `PlanModifiers` field on attribute within block or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface |
| DiffSuppressFunc | [PlanModifiers](/framework/migrating/resources/plan-modification#framework) field on attribute within block or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface |
| DiffSuppressOnRefresh | [Read](/plugin/framework/migrating/resources/crud) method on resource |
| Default | [PlanModifiers](/framework/migrating/resources/plan-modification#framework) field on attribute within block or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface |
| DefaultFunc | [PlanModifiers](/framework/migrating/resources/plan-modification#framework) field on attribute within block or implementation of [ResourceWithModifyPlan](/plugin/framework/migrating/resources/plan-modification#framework) interface |
| Description | `Description` field on attribute |
| InputDefault | N/A - no longer valid |
| StateFunc | Requires implementation of bespoke logic before storing state, for instance in resource [Create method](plugin/framework/migrating/resources/crud#framework-1) |
| Elem | N/A - define `Type` as [ListNestedBlock](/plugin/framework/migrating/attributes-blocks/blocks) or [SetNestedBlock](/plugin/framework/migrating/attributes-blocks/blocks) |
| MaxItems | Use [listValidator.SizeAtMost](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/listvalidator#SizeAtMost) or [setvalidator.SizeAtMost](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/setvalidator#SizeAtMost) on `Validators` field on `ListNestedBlock` or `SetNestedBlock` |
| MinItems | Use [listValidator.SizeAtLeast](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/listvalidator#SizeAtLeast) or [setvalidator.SizeAtLeast](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework-validators/setvalidator#SizeAtLeast) on `Validators` field on `ListNestedBlock` or `SetNestedBlock` |
| Set | N/A - no implementation required | |
| ComputedWhen | N/A - no longer valid |
| ConflictsWith | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) |
| ExactlyOneOf | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) |
| AtLeastOneOf | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) |
| RequiredWith | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) |
| Deprecated | `DeprecationMessage` field on attribute within block |
| ValidateFunc | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) and [Custom Validators](/plugin/framework/migrating/attributes-blocks/validators-custom) |
| ValidateDiagFunc | [Predefined Validators](/plugin/framework/migrating/attributes-blocks/validators-predefined) and [Custom Validators](/plugin/framework/migrating/attributes-blocks/validators-custom) |
| Sensitive | N/A - only supported on attributes |


## Nested Block Example

The following example shows a nested block in Terraform resource configuration. The `subject` nested
Expand Down
Loading