In this lecture, let's take a look at providers in more detail.
We saw in the previous lecture that
after we write a Terraform configuration file,
the first thing to do is to initialize the directory
with the Terraform init command.
When we run Terraform init
within a directory containing the configuration files,
Terraform downloads and installs plugins
for the providers used within the configuration.
These can be plugins for cloud providers such as AWS, GCP,
Azure, or something as simple as the local provider that we used
to create a local file type resource.
Terraform uses a plugin-based architecture
to work with hundreds of such infrastructure platforms.
Terraform providers are distributed by HashiCorp
and are publicly available
in the Terraform Registry at the URL registry.terraform.io.
There are three tiers of providers.
The first one is the official provider.
These are owned and maintained by HashiCorp,
and include the major cloud providers such as AWS, GCP, and Azure.
The local provider that we have used so far is also an official provider.
The second type of provider is a partner provider.
A partner provider is owned and maintained
by a third-party technology company
that has gone through a partner provider process with HashiCorp.
Some of the examples are the BIG-IP provider
from F5 networks, Heroku, DigitalOcean, et cetera.
Finally, we have the community providers that are published
and maintained by individual contributors of the HashiCorp community.
A Terraform init command when run,
shows the version of the plugin that has been installed.
In this case, we can see that the plugin name hashicorp/local
with the version 2.0.0 has been installed in the directory.
The Terraform init is a safe command,
and it can be run as many times as needed without impacting
the actual infrastructure that is deployed.
The plugins are downloaded into a hidden directory
called .terraform/plugins in the working directory
containing the configuration files.
In our example, the working directory
is /root/terraform-local-file.
The plugin name that you see here, hashicorp/local,
is also known as the source address.
This is an identifier that is used by Terraform to locate
and download the plugin from the registry.
Let's take a closer look at the format of the name.
The first part of the name, which in this case is hashicorp,
is the organizational namespace.
This is followed by the type,
which is the name of the provider such as local.
Other examples of providers are AWS, AzureRM, Google, Random, et cetera.
The plugin name can also optionally have a hostname in front.
The hostname is the name of the registry where the plugin is located.
If omitted, it defaults to registry.terraform.io,
which is HashiCorp's public registry.
Given the fact that the local provider is stored
in the public Terraform Registry within the HashiCorp namespace,
the source address for it can be represented as
registry.terraform.io/hashicorp/local,
or simply by hashicorp/local by omitting the hostname.
By default, Terraform installs the latest version of the provider.
Provider plugins, especially the official ones,
are constantly updated with newer versions.
This is done to bring in new functionality or to add in bug fixes,
and these can introduce breaking changes to your code.
We can lock down our configuration files
to make use of a specific provider version as well.
We will see how to do that later in this course.