Attribute Fields
A subset of attribute fields, such as required, optional, computed, or sensitive, define attribute behavior as boolean flags. Refer to Schemas - Attributes in the Framework documentation for details.
The following table describes the mapping between SDK Schema Fields and the Framework.
SDK Schema Field | Framework | |
---|---|---|
Type | Attribute Types | |
ConfigMode | Schema must be explictly defined using Attributes and Blocks | |
Required | Required field on attribute | |
Optional | Optional field on attribute | |
Computed | Computed field on attribute | |
ForceNew | RequiresReplace on PlanModifiers field on attribute or implementation of ResourceWithModifyPlan interface | |
DiffSuppressFunc | Custom Types, PlanModifiers field on attribute, or implementation of ResourceWithModifyPlan interface | |
DiffSuppressOnRefresh | Custom Types semantic equality logic or manual logic in Read method on resource | |
Default | Default field on attribute using one of the predefined Defaults or implementing one of the schema package interfaces | |
DefaultFunc | Default field on attribute using one of the predefined Defaults or implementing one of the schema package interfaces | |
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 | |
Elem | ElementType on ListAttribute, MapAttribute or SetAttribute. Refer to Blocks if schema.Resource is present in Elem . | |
MaxItems | Use listValidator.SizeAtMost, mapvalidator.SizeAtMost or setvalidator.SizeAtMost on Validators field on list, map or set attribute | |
MinItems | Use listValidator.SizeAtLeast, mapvalidator.SizeAtLeast or setvalidator.SizeAtLeast on Validators field on list, map or set attribute | |
Set | N/A - no implementation required | |
ComputedWhen | N/A - no longer valid | |
ConflictsWith | Predefined Validators | |
ExactlyOneOf | Predefined Validators | |
AtLeastOneOf | Predefined Validators | |
RequiredWith | Predefined Validators | |
Deprecated | DeprecationMessage field on attribute | |
ValidateFunc | Predefined Validators, Custom Validators, or Custom Types validation logic | |
ValidateDiagFunc | Predefined Validators, Custom Validators, or Custom Types validation logic | |
Sensitive | Sensitive field on attribute |
This page explains how to migrate the required, optional, computed, and sensitive attribute fields from SDKv2 to the Framework.
SDKv2
In SDKv2, Required
, Optional
, Computed
, and Sensitive
are boolean fields on the attribute's schema.
Framework
In the Framework, you set the same fields on the schema.Attribute
implementation, with the same behavior.
Example
SDKv2
The following example shows how the example_attribute
attribute on the exampleDataSource
data source is set to
be required with SDKv2.
Framework
The following example shows how the example_attribute
attribute on the exampleDataSource
data source is set
to be required with the Framework.