Fireship · @fireship
Terraform in 100 Seconds
Uploaded July 28, 2021 · Length 2:18
Summary
terraform provides a way to build and manage cloud infrastructure as code using a human-readable blueprint.
- terraform
- infrastructure as code
- cloud provisioning
- hashicorp
- aws
- google cloud
- azure
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
terraform an infrastructure as code tool
- 0:02
that can provision resources in the
- 0:04
cloud
- 0:05
from simple declarative code when
- 0:07
building an app in the cloud you may
- 0:08
find yourself using the graphical user
- 0:10
interface of your favorite cloud
- 0:12
provider
- 0:12
clicking on buttons and paying for
- 0:14
products just like you would on an
- 0:15
e-commerce site the only drawback of
- 0:17
this approach is that it's complete and
- 0:19
total chaos you might click a thousand
- 0:20
different buttons to get your vm
- 0:22
configured properly
- 0:23
but what happens when you need to
- 0:24
reproduce the same thing again in the
- 0:26
future
- 0:26
terraform provides a way to build change
- 0:28
and version infrastructure
- 0:30
safely and efficiently by representing
- 0:32
your infrastructure
- 0:33
and all that settings with the hashicorp
- 0:35
configuration language or optionally
- 0:37
json think of it like a human readable
- 0:39
blueprint that can execute and
- 0:41
automate everything you do in the cloud
- 0:43
it's free and open source
- 0:45
and the first step to get started is to
- 0:46
install the cli on your local system
- 0:49
then from your project create a file
- 0:51
ending in tf
- 0:52
at the top we have a terraform block
- 0:54
that controls global settings for
- 0:55
terraform itself
- 0:56
most importantly we can define providers
- 0:58
here which are like plugins that can
- 1:00
connect to different cloud providers
- 1:02
like aws
- 1:03
google cloud azure etc below that we
- 1:05
have a provider block which gives
- 1:07
terraform the necessary credentials to
- 1:09
connect to our google cloud account
- 1:11
from there we can create actual cloud
- 1:13
infrastructure using a resource block it
- 1:15
takes a type as its first argument which
- 1:17
corresponds to a product on google cloud
- 1:20
then a custom name to identify it as the
- 1:22
second argument
- 1:23
inside the block we can customize the
- 1:24
settings of the resource like its
- 1:26
machine type
- 1:27
zone and anything else you can imagine
- 1:29
now that our infrastructure is defined
- 1:30
as code we can run terraform init to
- 1:33
initialize the project
- 1:34
then terraform apply to make the actual
- 1:36
changes to google cloud
- 1:38
it'll require a confirmation before
- 1:39
making the changes then after it's
- 1:41
complete
- 1:42
the terraform show command can be used
- 1:43
to inspect the current state of the
- 1:45
infrastructure what's awesome
- 1:46
is that as we add more resources to the
- 1:48
configuration terraform keeps track of
- 1:50
the changes or diff
- 1:52
similar to a version control system like
- 1:54
git just run terraform apply again to
- 1:56
deploy any changes to the configuration
- 1:58
now once your startup has failed and it


