An attribute either contains a primitive type, such as an integer or a string, or contains other attributes. Attributes
that contain other attributes are referred to as nested attributes, and are implemented by populating the
NestedAttributes field on the tfsdk.Attribute struct. Refer to
Schemas - Attributes in the Framework documentation for details.
This page explains how to migrate a primitive attribute from SDKv2 to the plugin Framework. For an example of
migrating a nested block to a nested attribute, refer to Providers in
this guide.
Remember the following differences between SDKv2 and the Framework when completing the migration.
In the Framework, an Attribute struct has either the Type or Attributes field defined. The Type field is set to
a primitive type such as an integer or string, and you use the Attributes field for NestedAttributes. Refer to
Providers for an example of using a single
nested attribute. Nested attributes are also described in more detail on the
Schemas page in the Framework documentation.
The following examples show how to migrate portions of the
http provider.
For a complete example, clone the
terraform-provider-http repository and compare the data_source.go file in
v2.2.0
and the data_source_http.go file
after the migration.
The following example from the data_source.go file shows the implementation of the type field of the url attribute
for the http data source with SDKv2.
The following example from the data_source_http.go file shows how the type of the url attribute for the http data
source is defined with the Framework after the migration.
The following examples show how to migrate portions of the
tls provider.
For a complete example, clone the
terraform-provider-tls repository and compare the common_cert.go file in
v3.4.0
and the resource_cert_request.go file
after the migration.
The following example from the data_source_http.go file shows how the type of the url attribute for the http data
source is defined with the Framework after the migration.