You are on page 1of 30

Al

an
R
o
What is

d
r
ig
u
es
What is Terraform

es
u
Tool Language

ig
1
Open-source tool It uses a declarative language
developed by HashiCorp.
3 to define the code.

r
d
o
Cloud

R
Infrastructure
You can use it to build
It helps to automate and
manage your infrastructure.
n 2 infrastructure on multiple

4 cloud environments.
a
Terraform

Al
c
Al
an
R
o
d
r
Terraform

ig
u
es
es
u
ig
Core Terraform workflow

r
1. Write – Here you create the code configuration file.

d
2. Plan – Here you can see the changes that are going to be made by Terraform.

o
3. Apply – This will apply the changes.

R
a n

Terraform
Al
es
u
ig
Terraform configuration – This is the complete document in the Terraform language. This tells terraform how to
manage the infrastructure.

r
d
Providers – These are plugins for Terraform. This helps Terraform to work with cloud providers.

o
R
a n

Terraform
Al
es
u
ig
Te r r a f o r m

r
d
o
R
a n
Al
es
u
ig
You can write the configuration file either in JSON or HCL.

r
Argument – This assigns a value to a particular name

d
Block – This is a container for content.

o
In a block you will define the type – For example resource.

R
You then define labels within the block.
a n

Terraform
Al
es
u
ig
The resource block is the most important block.

r
This defines the infrastructure objects that need to be created.

d
In the body of the block you define configuration arguments for the resource.

o
R
a n

Terraform
Al
es
u
ig
Te r r a f o r m

r
d
o
R
a n
Al
es
u
ig
terraform init

r
This is used to initialize a working directory that contains the Terraform configuration files.

d
This is the first command that needs to run.

o
This command will also install any plugins required by the providers.

R
This command will also create a dependency lock file.
a n

Terraform
Al
es
u
ig
terraform plan -out main.tfplan

r
This command is going to create an execution plan.

d
Here you can preview the changes that Terraform is going to carry out.

o
You can specify to save the generated file to disk.

R
This command will also create a dependency lock file.
a n

Terraform
Al
es
u
ig
terraform apply

r
This command executes the actions within the Terraform plan.

d
o
R
a n

Terraform
Al
es
u
ig
Te r r a f o r m

r
d
o
R
a n
Al
es
u
ig
Terraform maintains state data that maps the real-world resources to the configuration.

r
The state data is stored in a local file named terraform.tfstate.

d
The state file can also be stored remotely which works best for a team environment.

o
The state file helps terraform to lay out a plan when it comes to the configuration file.

R
a n

Terraform
Al
es
u
ig
Do NOT modify the terraform state file.

r
Make changes to your configuration file to make changes to your infrastructure.

d
Its also advised that when you maintain your infrastructure with Terraform , don’t make manual changes to the

o
resources.

R
a n

Terraform
Al
Al
an
count

R
o
d
r
ig
u
es
The count Meta-Argument

es
u
Several objects Index

ig
1
This helps to manage You can use count.index to
several resources in your
3 get a handle to each unique

r
terraform configuration file. instance.

d
o
Numeric

R
Multiple instances
The count meta-argument
You can create multiple
instances of a resource.
n 2 accepts numeric

4 expressions.
a
Terraform

Al
c
Al
an
R
for_each

o
d
r
ig
u
es
The for_each Meta-Argument

es
u
Several objects Map or strings

ig
1
This helps to manage Here you define a map or
several resources in your
3 set of strings. Terraform will

r
terraform configuration file. create an instance for each
member in that map or set.

d
o
each object

R
Multiple instances
The each object helps to
You can create multiple
instances of a resource.
n 2 modify the configuration of

4 each instance.
a
Terraform

Al
c
Al
a
Data

n
R
o
d
r
ig
u
es
Data Sources

es
u
Outside resources Single resource

ig
1
This helps to use Each data source is
information defined outside
3 associated with a single

r
of Terraform. resource.

d
o
Provider

R
Data block
The data source depends on
The data source is defined
with the use of the data
n 2 the provider.

block.
4
a
Terraform

Al
c
Al
an
R
o
Provisioners

d
r
ig
u
es
es
u
ig
This can be used to implement certain behaviors that cannot be implemented via Terraform’s declarative model.

r
local-exec – This can be used to invoke a local executable after a resource is created.

d
This will invoke a process on the machine that is running Terraform.

o
R
a n

Terraform
Al
es
u
ig
Connection Block

r
This describes how to access a remote resource.

d
Connection blocks can be nested directly within a resource block. This would affect the resource’s provisioners.

o
It could also come within a provisioner block. This would affect the provisioner.

R
a n

Terraform
Al
es
u
ig
file provisioner

r
This can be used to copy files or directories from the machine running Terraform to the newly created resource.

d
This provisioner supports both ssh and winrm type connections.

o
R
a n

Terraform
Al
es
u
ig
r
Azure Web App Logging

d
o
R
n
a
Al
es
u
ig
You get a set of logging features that are available for the Azure Web App.

r
The different types of logging that are available are

d
Application Logging – This captures log messages that are generated by your application code.

o
Web server logging – This records raw HTTP request data.

R
a n
Al

Logging
es
u
ig
Detailed Error Messages – This stores copies of the .htm error pages that would have been sent to the client
browser.

r
d
Deployment logging – These are logs when you publish content to an application.

o
You can also stream logs in real time.

R
a n
Al

Logging
Al
an
R
o
d
r
Terraform

ig
u
es
Terraform Cloud

es
u
SaaS Backup

ig
1
This is a software as a Terraform cloud also
service offering wherein a
3 maintains backups of the

r
lot of aspects are managed state file.
on the cloud.

d
o
Users

R
Local CLI
You can have multiple users
You can still run your local
CLI to work with Terraform
n 2 work with Terraform Cloud.

cloud, but the state file can


4
a
be managed on the cloud
Terraform

Al

itself.
c

You might also like