2 2 0 Custom Terraform Provider: Provider Block (HCL)
As the Provider does not have any CRUD functions defined, it doesn't do anything. Andrew tests the mechanism of the skeleton plugin by building the Go binary and running terraform init
and terraform apply
- as terraform executes the Go binary, the init
and apply
commands should run successfully and it means the plugin is working.
Code Notes
As we defined a custom provider, we can now declare it in a terraform file.
Difference between required_providers
& provider
required_providers
& provider
It is a top-level block that sits inside the
terraform{}
block in the Terraform configuration.It is used to specify the providers that are required for the entire configuration.
If you are familiar with Node.js/React, you can think of
package.json
. They are not the exact equivalents of each other, but share a common point - both of them list out the dependencies required for a project.Example: let's say that we are going to use all the three major cloud services (AWS, Azure, and GCP) to deploy our terratowns houses to TerraTowns. Then the required providers will look like:
provider
: instantiation of therequired_provider
The
provider
block is typically used withinresource
ordata
blocks to create an instance of thatprovider
.A
provider
specifies the configuration for managing particular resource(s) or data source.Below example is an instantiation of the
required_provider
terratowns
listed above.
Resources
Development workflow documentation: 2.2.0 Provider Block for Custom Terraform Provider
Last updated