Resources
A key component to Terraform Provider development is defining the creation, read, update, and deletion functionality of a resource to map those API operations into the Terraform lifecycle. While the Call APIs with Terraform Providers tutorial and Schemas documentation cover the basic aspects of developing Terraform resources, this section covers more advanced features of resource development.
Import
Many operators migrating to Terraform will have previously existing infrastructure they want to bring under the management of Terraform. Terraform allows resources to implement Import Support to begin managing those existing infrastructure components.
Retries and Customizable Timeouts
The reality of cloud infrastructure is that it typically takes time to perform operations such as booting operating systems, discovering services, and replicating state across network edges. Terraform implements functionality to retry API requests or specifically declare state change criteria, while allowing customizable timeouts for operators. More information can be found in the Retries and Customizable Timeouts section.
Customizing Differences
Terraform tracks the state of provisioned resources in its state file, and compares the user-passed configuration against that state. When Terraform detects a discrepancy, it presents the user with the differences between the configuration and the state. Sometimes these scenarios require special handling, which is where Customizing Differences can help.
Data Consistency Errors
Terraform has data consistency rules for resources, which may not be easily discovered for resources using this SDK, but problematic for practitioners in their workflow or provider developers when the resource is being migrated to terraform-plugin-framework. The Data Consistency Errors page discusses the causes for these issues, how to discover them, and how to potentially resolve them.
State Migrations
Resources define the data types and API interactions required to create, update, and destroy infrastructure with a cloud vendor, while the Terraform state stores mapping and metadata information for those remote objects.
When resource implementations change (due to bug fixes, improvements, or changes to the backend APIs Terraform interacts with), they can sometimes become incompatible with existing state. When this happens, a migration is needed for resources provisioned in the wild with old schema configurations. Terraform resources support migrating state values in these scenarios via State Migration.