SlideShare a Scribd company logo
TERRAFORM – DEVOPS
@2020 copyright KalKey training
TERRAFORM
A. Introduction:
• What is Terrafrom
• Why use Terraform
• Providers
B. Installation & Setting up Lab
• Installing Terraform – Windows users
• Installing Terraform – Linux users
• Setting up AWS Account
C. Deploying Infrastructure with Terraform
• Creating First EC2 Instance with Terraform
• Understanding Resources and Providers
• Destroying Infrastructure with Terraform
• Terraform state
@2020 copyright KalKey training
D. Interpolation, Attributes & Variables:
• Attributes and Output Values
• Referencing Cross-Account Resource Attributes
• Terraform Variables
E. Terraform Provisioners
• Understanding Provisioners in
Terraform
• Implementing remote-exec
provisioners
• Implementing local-exec
provisioners
@2020 copyright KalKey training
F. Terraform Modules & Workspaces:
• DRY Principle
• Implementing EC2 module with Terraform
• Variables and Terraform Modules
• Terraform Workspace
G. Discussions
@2020 copyright KalKey training
A. INTRODUCTION
What is Terraform?
• Terraform is a tool for building, changing, and versioning
infrastructure safely and efficiently. Terraform can manage existing
and popular service providers as well as custom in-house solutions.
• Configuration files describe to Terraform the components needed
to run a single application or your entire datacenter. Terraform
generates an execution plan describing what it will do to reach the
desired state, and then executes it to build the described
infrastructure. As the configuration changes, Terraform is able to
determine what changed and create incremental execution plans
which can be applied.
• The infrastructure Terraform can manage includes low-level
components such as compute instances, storage, and networking, as
well as high-level components such as DNS entries, SaaS features, etc.
@2020 copyright KalKey training
Key Features:
Infrastructure as Code
Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your
datacenter to be versioned and treated as you would any other code. Additionally, infrastructure
can be shared and re-used.
Execution Plans
Terraform has a "planning" step where it generates an execution plan. The execution plan shows
what Terraform will do when you call apply. This lets you avoid any surprises when Terraform
manipulates infrastructure.
Change Automation
Complex changesets can be applied to your infrastructure with minimal human interaction. With
the previously mentioned execution plan and resource graph, you know exactly what Terraform
will change and in what order, avoiding many possible human errors.
@2020 copyright KalKey training
@2020 copyright KalKey training
@2020 copyright KalKey training
@2020 copyright KalKey training
B. INSTALLATION & SETTING UP LAB
• yum update
• yum install wget unzip
• sudo wget https://releases.hashicorp.com/terraform/0.12.2/terraform_0.12.2_linux_amd64.zip
• mv terraform_0.12.2_linux_amd64.zip /usr/local/bin/
• cd /usr/local/bin/
• unzip ./terraform_0.12.2_linux_amd64.zip
• terraform –v
@2020 copyright KalKey training
@2020 copyright KalKey training
C. Deploying Infrastructure with Terraform
• Creating First EC2 Instance with Terraform
1. Go to AWS console and launch an ec2 instance to manage or create the
infrastructure . Install terraform on that and configure the environment path.
2. Now create a file with terraform code with .tf extension to launch an ec2-instance
.
3. It can be written in HCL (Hashicorp Configuration Language) or JSON.
@2020 copyright KalKey training
Authentication with AWS
@2020 copyright KalKey training
• Creating and Configuring IAM User
@2020 copyright KalKey training
• Example:
provider "aws" {
region = "us-west-2"
access_key = "PUT-YOUR-ACCESS-KEY-HERE"
secret_key = "PUT-YOUR-SECRET-KEY-HERE"
}
resource "aws_instance" "myec2" {
ami = "ami-082b5a644766e0e6f"
instance_type = "t2.micro"
}
@2020 copyright KalKey training
• Commands :
1. $ terraform init // initializing and installing the plugins
2. $ terraform validate // validating the terraform files
3. $ terraform plan //testing the configuration files before run
4. $ terraform apply //applying and running the code mentioned
inside the terraform files
@2020 copyright KalKey training
@2020 copyright KalKey training
• Destroying Infrastructure with Terraform
terraform destroy // destroy all resources mention in the .tf file
terraform destroy -target aws_instance.myec2 // destroy the target only
=> After destroying the resources do comment out the resources inside terraform
file. Otherwise it will recreate again
Infrastructure managed by Terraform will be destroyed. This will ask for
confirmation before destroying. The terraform destroy command terminates
resources defined in your Terraform configuration. This command is the
reverse of terraform apply in that it terminates all the resources specified by
the configuration. It does not destroy resources running elsewhere that are
not described in the current configuration.
@2020 copyright KalKey training
• Terraform State
Terraform must store state about your managed infrastructure and configuration. This state is
used by Terraform to map real world resources to your configuration, keep track of metadata,
and to improve performance for large infrastructures. This state is stored by default in a
local file named "terraform.
Desired State:
It is the state where you have defined in your configuration, with the actual state of your
existing resources.
Current State:
Current configuration which is running in the environment and mentioned in the local file.
@2020 copyright KalKey training
@2020 copyright KalKey training
To refresh the current state:
terraform refresh
 Scenario:
If you change a parameter manually in any services inside AWS and then you want to
roll back to previous value then it is mandatory to have it inside the desired state files.
@2020 copyright KalKey training

More Related Content

PPTX
Introduction of tomcat
Kalkey
 
PPTX
Terraform day 3
Kalkey
 
PPTX
Ansible day 4
Gourav Varma
 
PDF
Securing Containers - Sathyajit Bhat - Adobe - Container Conference 18
CodeOps Technologies LLP
 
PPT
Docker swarm
Kalkey
 
PDF
Installing WordPress on AWS
Manish Jain
 
PDF
Docker for developers on mac and windows
Docker, Inc.
 
PDF
Heat - keep the clouds up
Kiran Murari
 
Introduction of tomcat
Kalkey
 
Terraform day 3
Kalkey
 
Ansible day 4
Gourav Varma
 
Securing Containers - Sathyajit Bhat - Adobe - Container Conference 18
CodeOps Technologies LLP
 
Docker swarm
Kalkey
 
Installing WordPress on AWS
Manish Jain
 
Docker for developers on mac and windows
Docker, Inc.
 
Heat - keep the clouds up
Kiran Murari
 

What's hot (18)

PPTX
Final terraform
Gourav Varma
 
PDF
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
SlideTeam
 
PDF
Infrastructure as code
Axel Quack
 
PDF
Deploying a Kubernetes App with Amazon EKS
Laura Frank Tacho
 
PPTX
Terraform day 2
Kalkey
 
PDF
Using Docker For Development
Laura Frank Tacho
 
PPTX
Infrastructure-as-Code (IaC) Using Terraform (Advanced Edition)
Adin Ermie
 
PPTX
Infrastructure-as-Code (IaC) using Terraform
Adin Ermie
 
PDF
Monitoring on Kubernetes using Prometheus - Chandresh
CodeOps Technologies LLP
 
PPTX
Securing Containers - Sathyajit Bhat - Adobe
CodeOps Technologies LLP
 
PDF
Cooling Tower
guest69f868
 
ODP
Aeolus - Clouds Flying in Assembly
lutter
 
PDF
Azure Kubernetes Service - benefits and challenges
Wojciech Barczyński
 
PDF
Serverless Architectural Patterns 
and Best Practices - Madhu Shekar - AWS
CodeOps Technologies LLP
 
PDF
Understanding AWS with Terraform
Knoldus Inc.
 
PPTX
Container Orchestration with Docker Swarm and Kubernetes
Will Hall
 
PPTX
How Cloudify uses Chef as a Foundation for PaaS
Nati Shalom
 
PDF
Case Study: Using Terraform and Packer to deploy go applications to AWS
Patrick Bolduan
 
Final terraform
Gourav Varma
 
Kubernetes Concepts And Architecture Powerpoint Presentation Slides
SlideTeam
 
Infrastructure as code
Axel Quack
 
Deploying a Kubernetes App with Amazon EKS
Laura Frank Tacho
 
Terraform day 2
Kalkey
 
Using Docker For Development
Laura Frank Tacho
 
Infrastructure-as-Code (IaC) Using Terraform (Advanced Edition)
Adin Ermie
 
Infrastructure-as-Code (IaC) using Terraform
Adin Ermie
 
Monitoring on Kubernetes using Prometheus - Chandresh
CodeOps Technologies LLP
 
Securing Containers - Sathyajit Bhat - Adobe
CodeOps Technologies LLP
 
Cooling Tower
guest69f868
 
Aeolus - Clouds Flying in Assembly
lutter
 
Azure Kubernetes Service - benefits and challenges
Wojciech Barczyński
 
Serverless Architectural Patterns 
and Best Practices - Madhu Shekar - AWS
CodeOps Technologies LLP
 
Understanding AWS with Terraform
Knoldus Inc.
 
Container Orchestration with Docker Swarm and Kubernetes
Will Hall
 
How Cloudify uses Chef as a Foundation for PaaS
Nati Shalom
 
Case Study: Using Terraform and Packer to deploy go applications to AWS
Patrick Bolduan
 
Ad

Similar to Terraform day 1 (20)

PPTX
Debasihish da final.ppt
Kalkey
 
PPTX
Terraform day1
Gourav Varma
 
PPTX
Terraform infraestructura como código
Victor Adsuar
 
PDF
Terraform In Action Meap V10 Meap Scott Winkler
heyenpardis0
 
PDF
Terraform in Depth (MEAP V01) Robert Hafner
kutterjadeja
 
PDF
Terraform in Depth (MEAP V01) Robert Hafner
teverafidhi
 
PDF
Terraform: Infrastructure as Code
Pradeep Bhadani
 
PDF
Configuration management II - Terraform
Xavier Serrat Bordas
 
PPTX
Terraform
Harish Kumar
 
PDF
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
ssuser705051
 
PDF
Terraform-2.pdf
rutiksankapal21
 
PDF
Terraform Interview Questions By Scholarhat.pdf
Scholarhat
 
PDF
Terraform introduction
Jason Vance
 
PPTX
Terraform Basics
Mohammed Fazuluddin
 
PPTX
Terraform: Taming the Machines Through Continuous Integration
Justin Rice
 
PDF
Infrastructure as Code with Terraform
Pedro J. Molina
 
PDF
APIsecure 2023 - How to abuse Terraform to elevate access, Mike McCabe
apidays
 
PDF
Introductory Overview to Managing AWS with Terraform
Michael Heyns
 
PDF
Instant download Terraform in Depth (MEAP V01) Robert Hafner pdf all chapter
akceyohros
 
PDF
Terraform Up Running Writing Infrastructure as Code 2nd Edition Yevgeniy Brikman
fittepulloos
 
Debasihish da final.ppt
Kalkey
 
Terraform day1
Gourav Varma
 
Terraform infraestructura como código
Victor Adsuar
 
Terraform In Action Meap V10 Meap Scott Winkler
heyenpardis0
 
Terraform in Depth (MEAP V01) Robert Hafner
kutterjadeja
 
Terraform in Depth (MEAP V01) Robert Hafner
teverafidhi
 
Terraform: Infrastructure as Code
Pradeep Bhadani
 
Configuration management II - Terraform
Xavier Serrat Bordas
 
Terraform
Harish Kumar
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
ssuser705051
 
Terraform-2.pdf
rutiksankapal21
 
Terraform Interview Questions By Scholarhat.pdf
Scholarhat
 
Terraform introduction
Jason Vance
 
Terraform Basics
Mohammed Fazuluddin
 
Terraform: Taming the Machines Through Continuous Integration
Justin Rice
 
Infrastructure as Code with Terraform
Pedro J. Molina
 
APIsecure 2023 - How to abuse Terraform to elevate access, Mike McCabe
apidays
 
Introductory Overview to Managing AWS with Terraform
Michael Heyns
 
Instant download Terraform in Depth (MEAP V01) Robert Hafner pdf all chapter
akceyohros
 
Terraform Up Running Writing Infrastructure as Code 2nd Edition Yevgeniy Brikman
fittepulloos
 
Ad

More from Kalkey (16)

PPTX
Docker advance topic (2)
Kalkey
 
PPTX
Docker introduction (1)
Kalkey
 
PPTX
Nexus
Kalkey
 
PPTX
Sonarqube
Kalkey
 
PPTX
Jenkins advance topic
Kalkey
 
PPTX
Jenkins introduction
Kalkey
 
PPTX
Intro
Kalkey
 
PPTX
Ansible day 3
Kalkey
 
PPTX
Cloud computing 1
Kalkey
 
PPTX
Shell programming 2
Kalkey
 
PPTX
Adnible day 2.ppt
Kalkey
 
PPTX
Shell programming 1.ppt
Kalkey
 
PPTX
Linux day 3ppt
Kalkey
 
PPTX
Ansible day 1.ppt
Kalkey
 
PPTX
Linux day 2.ppt
Kalkey
 
PPTX
Docker advance topic
Kalkey
 
Docker advance topic (2)
Kalkey
 
Docker introduction (1)
Kalkey
 
Nexus
Kalkey
 
Sonarqube
Kalkey
 
Jenkins advance topic
Kalkey
 
Jenkins introduction
Kalkey
 
Intro
Kalkey
 
Ansible day 3
Kalkey
 
Cloud computing 1
Kalkey
 
Shell programming 2
Kalkey
 
Adnible day 2.ppt
Kalkey
 
Shell programming 1.ppt
Kalkey
 
Linux day 3ppt
Kalkey
 
Ansible day 1.ppt
Kalkey
 
Linux day 2.ppt
Kalkey
 
Docker advance topic
Kalkey
 

Recently uploaded (20)

PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
CDH. pptx
AneetaSharma15
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
PPTX
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
DOCX
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
CDH. pptx
AneetaSharma15
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Gupta Art & Architecture Temple and Sculptures.pptx
Virag Sontakke
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
Kanban Cards _ Mass Action in Odoo 18.2 - Odoo Slides
Celine George
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
SAROCES Action-Plan FOR ARAL PROGRAM IN DEPED
Levenmartlacuna1
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
Five Point Someone – Chetan Bhagat | Book Summary & Analysis by Bhupesh Kushwaha
Bhupesh Kushwaha
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
An introduction to Prepositions for beginners.pptx
drsiddhantnagine
 

Terraform day 1

  • 1. TERRAFORM – DEVOPS @2020 copyright KalKey training
  • 2. TERRAFORM A. Introduction: • What is Terrafrom • Why use Terraform • Providers B. Installation & Setting up Lab • Installing Terraform – Windows users • Installing Terraform – Linux users • Setting up AWS Account C. Deploying Infrastructure with Terraform • Creating First EC2 Instance with Terraform • Understanding Resources and Providers • Destroying Infrastructure with Terraform • Terraform state @2020 copyright KalKey training
  • 3. D. Interpolation, Attributes & Variables: • Attributes and Output Values • Referencing Cross-Account Resource Attributes • Terraform Variables E. Terraform Provisioners • Understanding Provisioners in Terraform • Implementing remote-exec provisioners • Implementing local-exec provisioners @2020 copyright KalKey training
  • 4. F. Terraform Modules & Workspaces: • DRY Principle • Implementing EC2 module with Terraform • Variables and Terraform Modules • Terraform Workspace G. Discussions @2020 copyright KalKey training
  • 5. A. INTRODUCTION What is Terraform? • Terraform is a tool for building, changing, and versioning infrastructure safely and efficiently. Terraform can manage existing and popular service providers as well as custom in-house solutions. • Configuration files describe to Terraform the components needed to run a single application or your entire datacenter. Terraform generates an execution plan describing what it will do to reach the desired state, and then executes it to build the described infrastructure. As the configuration changes, Terraform is able to determine what changed and create incremental execution plans which can be applied. • The infrastructure Terraform can manage includes low-level components such as compute instances, storage, and networking, as well as high-level components such as DNS entries, SaaS features, etc. @2020 copyright KalKey training
  • 6. Key Features: Infrastructure as Code Infrastructure is described using a high-level configuration syntax. This allows a blueprint of your datacenter to be versioned and treated as you would any other code. Additionally, infrastructure can be shared and re-used. Execution Plans Terraform has a "planning" step where it generates an execution plan. The execution plan shows what Terraform will do when you call apply. This lets you avoid any surprises when Terraform manipulates infrastructure. Change Automation Complex changesets can be applied to your infrastructure with minimal human interaction. With the previously mentioned execution plan and resource graph, you know exactly what Terraform will change and in what order, avoiding many possible human errors. @2020 copyright KalKey training
  • 10. B. INSTALLATION & SETTING UP LAB • yum update • yum install wget unzip • sudo wget https://releases.hashicorp.com/terraform/0.12.2/terraform_0.12.2_linux_amd64.zip • mv terraform_0.12.2_linux_amd64.zip /usr/local/bin/ • cd /usr/local/bin/ • unzip ./terraform_0.12.2_linux_amd64.zip • terraform –v @2020 copyright KalKey training
  • 12. C. Deploying Infrastructure with Terraform • Creating First EC2 Instance with Terraform 1. Go to AWS console and launch an ec2 instance to manage or create the infrastructure . Install terraform on that and configure the environment path. 2. Now create a file with terraform code with .tf extension to launch an ec2-instance . 3. It can be written in HCL (Hashicorp Configuration Language) or JSON. @2020 copyright KalKey training
  • 13. Authentication with AWS @2020 copyright KalKey training
  • 14. • Creating and Configuring IAM User @2020 copyright KalKey training
  • 15. • Example: provider "aws" { region = "us-west-2" access_key = "PUT-YOUR-ACCESS-KEY-HERE" secret_key = "PUT-YOUR-SECRET-KEY-HERE" } resource "aws_instance" "myec2" { ami = "ami-082b5a644766e0e6f" instance_type = "t2.micro" } @2020 copyright KalKey training
  • 16. • Commands : 1. $ terraform init // initializing and installing the plugins 2. $ terraform validate // validating the terraform files 3. $ terraform plan //testing the configuration files before run 4. $ terraform apply //applying and running the code mentioned inside the terraform files @2020 copyright KalKey training
  • 18. • Destroying Infrastructure with Terraform terraform destroy // destroy all resources mention in the .tf file terraform destroy -target aws_instance.myec2 // destroy the target only => After destroying the resources do comment out the resources inside terraform file. Otherwise it will recreate again Infrastructure managed by Terraform will be destroyed. This will ask for confirmation before destroying. The terraform destroy command terminates resources defined in your Terraform configuration. This command is the reverse of terraform apply in that it terminates all the resources specified by the configuration. It does not destroy resources running elsewhere that are not described in the current configuration. @2020 copyright KalKey training
  • 19. • Terraform State Terraform must store state about your managed infrastructure and configuration. This state is used by Terraform to map real world resources to your configuration, keep track of metadata, and to improve performance for large infrastructures. This state is stored by default in a local file named "terraform. Desired State: It is the state where you have defined in your configuration, with the actual state of your existing resources. Current State: Current configuration which is running in the environment and mentioned in the local file. @2020 copyright KalKey training
  • 21. To refresh the current state: terraform refresh  Scenario: If you change a parameter manually in any services inside AWS and then you want to roll back to previous value then it is mandatory to have it inside the desired state files. @2020 copyright KalKey training