WEBVTT

00:01.970 --> 00:06.190
In this lecture, let's take
a look at providers in more detail.

00:08.780 --> 00:10.410
We saw in the previous lecture that

00:10.940 --> 00:13.360
after we write
a Terraform configuration file,

00:13.880 --> 00:16.940
the first thing to do is
to initialize the directory

00:17.020 --> 00:18.600
with the Terraform init command.

00:19.790 --> 00:21.110
When we run Terraform init

00:21.190 --> 00:24.480
within a directory containing
the configuration files,

00:24.560 --> 00:27.410
Terraform downloads
and installs plugins

00:27.490 --> 00:29.980
for the providers
used within the configuration.

00:31.300 --> 00:35.720
These can be plugins for cloud
providers such as AWS, GCP,

00:35.800 --> 00:39.760
Azure, or something as simple as
the local provider that we used

00:39.840 --> 00:41.960
to create a local
file type resource.

00:42.970 --> 00:45.360
Terraform uses
a plugin-based architecture

00:45.440 --> 00:48.510
to work with hundreds of such
infrastructure platforms.

00:49.510 --> 00:52.140
Terraform providers are
distributed by HashiCorp

00:52.220 --> 00:53.510
and are publicly available

00:53.590 --> 00:58.540
in the Terraform Registry at
the URL registry.terraform.io.

00:59.990 --> 01:01.920
There are three
tiers of providers.

01:03.130 --> 01:05.020
The first one is the
official provider.

01:05.930 --> 01:08.490
These are owned and
maintained by HashiCorp,

01:08.570 --> 01:12.320
and include the major cloud
providers such as AWS, GCP, and Azure.

01:13.340 --> 01:17.560
The local provider that we have used
so far is also an official provider.

01:18.680 --> 01:21.710
The second type of provider
is a partner provider.

01:22.580 --> 01:24.670
A partner provider
is owned and maintained

01:24.750 --> 01:27.470
by a third-party
technology company

01:27.550 --> 01:30.640
that has gone through a partner
provider process with HashiCorp.

01:31.890 --> 01:34.210
Some of the examples are
the BIG-IP provider

01:34.290 --> 01:38.410
from F5 networks, Heroku,
DigitalOcean, et cetera.

01:39.830 --> 01:42.950
Finally, we have the community
providers that are published

01:43.030 --> 01:46.540
and maintained by individual
contributors of the HashiCorp community.

01:48.440 --> 01:50.800
A Terraform init
command when run,

01:50.880 --> 01:53.480
shows the version of the
plugin that has been installed.

01:54.850 --> 01:59.270
In this case, we can see that
the plugin name hashicorp/local

01:59.350 --> 02:03.790
with the version 2.0.0 has been
installed in the directory.

02:04.760 --> 02:06.590
The Terraform init
is a safe command,

02:06.960 --> 02:10.080
and it can be run as many times
as needed without impacting

02:10.120 --> 02:12.410
the actual infrastructure
that is deployed.

02:14.530 --> 02:17.220
The plugins are downloaded
into a hidden directory

02:17.300 --> 02:20.930
called .terraform/plugins
in the working directory

02:21.010 --> 02:23.530
containing the configuration files.

02:23.610 --> 02:25.460
In our example,
the working directory

02:25.540 --> 02:29.040
is /root/terraform-local-file.

02:31.150 --> 02:35.160
The plugin name that you
see here, hashicorp/local,

02:35.520 --> 02:37.610
is also known as
the source address.

02:38.520 --> 02:41.910
This is an identifier that is
used by Terraform to locate

02:41.990 --> 02:44.080
and download the plugin
from the registry.

02:44.760 --> 02:47.230
Let's take a closer look
at the format of the name.

02:48.570 --> 02:52.360
The first part of the name,
which in this case is hashicorp,

02:52.440 --> 02:54.540
is the organizational namespace.

02:55.370 --> 02:57.060
This is followed by the type,

02:57.140 --> 02:59.930
which is the name of
the provider such as local.

03:00.750 --> 03:07.630
Other examples of providers are AWS,
AzureRM, Google, Random, et cetera.

03:08.550 --> 03:11.580
The plugin name can also
optionally have a hostname in front.

03:12.420 --> 03:15.950
The hostname is the name of the
registry where the plugin is located.

03:16.830 --> 03:20.550
If omitted, it defaults
to registry.terraform.io,

03:20.630 --> 03:22.560
which is HashiCorp's
public registry.

03:23.970 --> 03:26.360
Given the fact that the
local provider is stored

03:26.440 --> 03:30.460
in the public Terraform Registry
within the HashiCorp namespace,

03:30.540 --> 03:33.530
the source address for
it can be represented as

03:33.610 --> 03:38.410
registry.terraform.io/hashicorp/local,

03:39.020 --> 03:42.700
or simply by hashicorp/local
by omitting the hostname.

03:44.460 --> 03:48.190
By default, Terraform installs
the latest version of the provider.

03:49.190 --> 03:52.020
Provider plugins, especially
the official ones,

03:52.100 --> 03:54.750
are constantly updated
with newer versions.

03:54.830 --> 03:58.720
This is done to bring in new
functionality or to add in bug fixes,

03:59.700 --> 04:02.190
and these can introduce
breaking changes to your code.

04:03.340 --> 04:05.400
We can lock down our
configuration files

04:05.480 --> 04:08.220
to make use of a specific
provider version as well.

04:08.860 --> 04:11.340
We will see how to do
that later in this course.

