WEBVTT

00:00.550 --> 00:01.550
In this lecture,

00:01.720 --> 00:04.420
we will get introduced
to Infrastructure as Code,

00:04.580 --> 00:06.830
which is commonly known as IAC.

00:07.840 --> 00:11.320
We will also take a look
at commonly used IAC tools.

00:13.610 --> 00:16.040
Earlier,
we discussed about provisioning

00:16.210 --> 00:18.270
by making use
of the management console

00:18.440 --> 00:20.130
of various cloud providers.

00:20.820 --> 00:23.220
The better way
to provision cloud infrastructure

00:23.390 --> 00:26.090
is to codify
the entire provisioning process.

00:27.080 --> 00:29.250
This way
we can write and execute code,

00:29.470 --> 00:32.370
to define, provision,
configure, update,

00:32.540 --> 00:34.890
and eventually
destroy infrastructure resources.

00:36.050 --> 00:39.790
This is called
as Infrastructure as Code or IAC.

00:40.790 --> 00:42.230
With Infrastructure as Code,

00:42.390 --> 00:44.840
you can manage
nearly any infrastructure component

00:45.010 --> 00:46.010
as code,

00:46.180 --> 00:50.890
such as databases, networks, storage,
or even application configuration.

00:52.840 --> 00:54.890
The code you see here
is a shell script.

00:55.210 --> 00:57.650
However, it is not easy to manage it.

00:58.210 --> 01:00.410
It requires
programming or development skills

01:00.580 --> 01:01.860
to build and maintain.

01:02.940 --> 01:05.390
There's a lot of logic
that you will need to code,

01:05.560 --> 01:07.400
and it is not easily reusable.

01:08.280 --> 01:09.290
That's where tools

01:09.460 --> 01:11.490
like Terraform and Ansible
help with code

01:11.700 --> 01:14.860
that is easy to learn,
is human readable and maintain.

01:15.790 --> 01:17.790
A large shell script
can now be converted

01:17.960 --> 01:20.120
into a simple
Terraform configuration file

01:20.290 --> 01:21.290
like this.

01:22.720 --> 01:24.120
With Infrastructure as Code,

01:24.290 --> 01:26.140
we can define
infrastructure resources

01:26.310 --> 01:29.270
using simple, human readable
high-level language.

01:30.180 --> 01:31.410
Here is another example

01:31.570 --> 01:33.420
where we will be making use
of Ansible

01:33.590 --> 01:36.090
to provision three AWS EC2 instances,

01:36.450 --> 01:38.590
making use of a specific AMI.

01:39.760 --> 01:42.520
Although Ansible and Terraform
are IAC tools,

01:42.730 --> 01:45.980
they have some key differences
in what they are trying to achieve,

01:46.150 --> 01:47.150
and as a result,

01:47.320 --> 01:49.320
they have
some very different use cases.

01:50.570 --> 01:52.470
Here,
we'll see these differences next.

01:53.610 --> 01:55.460
There are
several different tools part

01:55.630 --> 01:57.480
of the Infrastructure as Code family;

01:57.960 --> 02:00.300
Ansible, Terraform, Puppet,

02:00.640 --> 02:03.510
CloudFormation, Packer, SaltStack,

02:03.680 --> 02:05.330
Vagrant, Docker, et cetera.

02:06.360 --> 02:09.320
Although you can possibly
make use of any of these tools

02:09.490 --> 02:10.910
to design similar solutions,

02:11.080 --> 02:14.410
they have all been created
to address a very specific goal.

02:15.800 --> 02:16.800
With that in mind,

02:17.000 --> 02:19.890
IAC can be broadly classified
into three types;

02:21.300 --> 02:22.600
configuration management:

02:23.080 --> 02:26.510
Ansible, Puppet, SaltStack
fall into this category.

02:27.520 --> 02:29.220
Tools used for server templating;

02:29.610 --> 02:33.240
Docker, Packer, and Vagrant
fall into this category.

02:33.680 --> 02:36.280
Finally, we have
infrastructure provisioning tools,

02:36.450 --> 02:38.350
such as Terraform and CloudFormation.

02:40.140 --> 02:42.190
Let's look at these
in a bit more detail.

02:43.960 --> 02:47.060
The first type of IAC tool
that we are going to take a look at

02:47.310 --> 02:49.240
is configuration management tools.

02:50.210 --> 02:51.210
These include tools

02:51.390 --> 02:54.200
like Ansible, Chef, Puppet,
and SaltStack,

02:55.630 --> 02:58.810
and these are commonly used
to install and manage software

02:58.980 --> 03:00.780
on existing infrastructure resources

03:00.950 --> 03:04.480
such as servers, databases,
networking devices, et cetera.

03:05.640 --> 03:08.240
Unlike the ad-hoc shelf scripts
that we saw earlier,

03:08.500 --> 03:10.400
configuration management tools
maintain

03:10.570 --> 03:13.010
a consistent and a standard
structure of code,

03:13.430 --> 03:16.740
and this makes it easier
to manage and update it as needed.

03:18.180 --> 03:21.930
They are also designed to run
on multiple remote resources at once.

03:23.010 --> 03:25.360
An Ansible playbook or a role
can be checked

03:25.530 --> 03:27.280
into a version control repository.

03:27.910 --> 03:31.140
This allows us
to reuse and distribut it as needed.

03:32.180 --> 03:33.180
However,

03:33.350 --> 03:36.750
perhaps the most important feature
of a configuration management tool

03:36.920 --> 03:38.750
is that they are idempotent.

03:39.470 --> 03:42.470
This means that you can run the code
multiple times

03:42.650 --> 03:43.950
and every time you run it,

03:44.120 --> 03:46.270
it will only make changes
that are necessary

03:46.440 --> 03:48.790
to bring the environment
into a defined state.

03:50.010 --> 03:52.740
It would leave anything
already in place as it is,

03:52.950 --> 03:55.300
without us having to write
any additional code.

03:56.250 --> 03:57.250
Next,

03:57.410 --> 03:59.410
let's look
at server templating tools.

03:59.880 --> 04:00.880
These are tools

04:01.050 --> 04:03.750
like Docker, Vagrant,
and Packer from HashiCorp

04:03.920 --> 04:05.220
that can be used to create

04:05.380 --> 04:07.980
a custom image
of a virtual machine or a container.

04:09.250 --> 04:10.730
These images already contain

04:10.910 --> 04:14.010
all the required software
and dependencies installed on them,

04:14.490 --> 04:15.640
and for the most part,

04:15.930 --> 04:18.250
this eliminates the need
of installing software

04:18.420 --> 04:20.490
after a VM or a container
is deployed.

04:21.650 --> 04:24.590
The most common examples
for server templated images

04:24.760 --> 04:25.950
are VM images

04:26.120 --> 04:29.580
such as those
that are offered on osboxes.org,

04:30.280 --> 04:32.610
custom AMIs in Amazon AWS,

04:32.850 --> 04:36.120
and Docker images on DockerHub
and other container registries.

04:37.580 --> 04:40.940
Server templating tools
also promote immutable infrastructure

04:41.140 --> 04:42.990
unlike
configuration management tools.

04:44.150 --> 04:45.150
This means that,

04:45.320 --> 04:47.400
once the VM or a container
is deployed,

04:47.600 --> 04:49.400
it is designed to remain unchanged.

04:49.960 --> 04:52.260
If there are changes to be made
to the image,

04:52.520 --> 04:54.520
instead of updating
the running instance,

04:54.690 --> 04:56.850
like in the case
of configuration management tools

04:57.010 --> 04:58.010
such as Ansible,

04:58.320 --> 05:01.390
we update the image
and then re-deploy a new instance

05:01.560 --> 05:02.920
using the updated image.

05:04.210 --> 05:06.410
We have a section
on immutable infrastructure

05:06.580 --> 05:07.580
later in this course

05:07.750 --> 05:10.050
where we will look at it
in much more detail.

05:11.720 --> 05:13.280
The last type of IAC tool

05:13.450 --> 05:15.850
which is specifically
of interest for this course

05:16.020 --> 05:17.180
is provisioning tools.

05:18.210 --> 05:21.110
These tools are used to provision
infrastructure components

05:21.280 --> 05:23.220
using a simple declarative code.

05:24.570 --> 05:27.220
These infrastructure components
can range from servers

05:27.380 --> 05:31.800
such virtual machines, databases,
VPCs, subnets,

05:32.160 --> 05:33.780
security groups, storage,

05:34.030 --> 05:37.080
and just about any services
based on the provider we choose.

05:38.480 --> 05:40.510
While CloudFormation
is specifically used

05:40.680 --> 05:42.740
to deploy services in AWS,

05:43.140 --> 05:44.680
Terraform is vendor agnostic

05:44.890 --> 05:48.410
and supports provider plugins
for almost all major cloud providers.

05:49.290 --> 05:50.540
In the upcoming lecture,

05:50.710 --> 05:53.860
we will see how Terraform helps
in provisioning infrastructure.

