SlideShare a Scribd company logo
5
Most read
10
Most read
11
Most read
TERRAFORM
3rd October 2018
Introduction to Terraform
By Sasitha Rajapaksha
Overview
● Terraform
● What is Terraform
● Why we use Terraform
● Terraform use cases
● Compare with Cloudformation
● Workflow of provisioning
● Hands on with Terraform
○ S3
○ Cloudfront
○ EC2
Terraform
● Open source
● Mozilla public licence 2.0
● Created by Hashicorp
● Started in 2014
● Written in GO
● Pluggable
Terraform is a tool to BUILD, CHANGE and VERSION
CONTROL your infrastructure.
Terraform can work with multiple cloud infrastructure at the
same time and ensure creation and consistency.
Terraform Remote State
● There is default local state
Which making sure that developer doesn’t do any changes to the same infrastructure at the
same time
● Remote state
○ Work same as the local state but it is useful when working with a team. This remote state will share with each
other and block the concurrent changes to the same infrastructure.
Terraform use cases
● Apply incremental changes
● Destroy infrastructure at any time we want
● Preview changes
● Scale easily
● Version control
Terraform vs. Cloudformation
resource "aws_s3_bucket" "bucket" {
bucket = "my-tf-test-bucket"
acl = "private"
}
{
"Resources": {
"my-cf-test-bucket":{
"Type": "AWS::S3::Bucket",
"Properties":{
"AccessControl":"Private",
},
},
}
}
Terraform Cloudformation
How Terraform works
● Terraform takes variables as a inputs
○ JSON
○ HCL
○ CLI
● Output ip address, texts and etc..
○ JSON
○ CLI
Let's start
AWS Provider
provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "us-east-1"
}
Azure Provider
provider "azurerm" {
subscription_id = "${var.subscription_id }"
client_id = "${var.client_id }"
client_secret = "${var.client_secret }"
tenant_id = "${var.tenant_id }"
}
Workflow of provisioning
1. First start with “terraform init” to setup initial aws or azure providers
2. Then “terraform plan” command to see than plan of what will provision
3. Finally “terraform apply” command to provision all the infrastructure
4. Okay, then you can use “terraform apply” at any time to do any changes to the
provisioned infrastructure.
S3 Bucket to store static website
resource "aws_s3_bucket" "b" {
bucket = "mybucket"
acl = "private"
tags {
Name = "My bucket"
}
}
locals {
s3_origin_id = "myS3Origin"
}
EC2 instance
provider "aws" {
region = "us-west-2"
}
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-
trusty-14.04-amd64-server-*"]
}
filter {
name = "virtualization-type"
values = ["hvm"]
}
owners = ["099720109477"] # Canonical
}
resource "aws_instance" "web" {
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "t2.micro"
tags {
Name = "HelloWorld"
}
}
Creating Cloudfront
resource "aws_cloudfront_distribution" "s3_distribution" {
origin {
domain_name = "${aws_s3_bucket.b.bucket_regional_domain_name}"
origin_id = "${local.s3_origin_id}"
s3_origin_config {
origin_access_identity = "origin-access-identity/cloudfront/ABCDEFG1234567"
}
}
}

More Related Content

What's hot (20)

PPTX
Infrastructure-as-Code (IaC) using Terraform
Adin Ermie
 
PDF
Intro to Terraform
Josh Michielsen
 
PDF
Terraform
Christophe Marchal
 
PPTX
Terraform
An Nguyen
 
PDF
Best Practices of Infrastructure as Code with Terraform
DevOps.com
 
PDF
An Introduction to Kubernetes
Imesh Gunaratne
 
PDF
Getting Started Monitoring with Prometheus and Grafana
Syah Dwi Prihatmoko
 
PDF
Terraform: An Overview & Introduction
Lee Trout
 
PPTX
Terraform on Azure
Mithun Shanbhag
 
PPTX
02 terraform core concepts
zekeLabs Technologies
 
PPTX
A brief introduction to IaC with Terraform by Kenton Robbins (codeHarbour May...
Alex Cachia
 
PDF
Introduction to Kubernetes Workshop
Bob Killen
 
PPTX
Terraform on Azure
Julien Corioland
 
PPTX
Terraform
Pathum Fernando ☁
 
PDF
Kubernetes Basics
Eueung Mulyana
 
PPTX
Terraform
Harish Kumar
 
PDF
Monitoring with prometheus
Kasper Nissen
 
PPTX
Terraform modules restructured
Ami Mahloof
 
PDF
Terraform
Otto Jongerius
 
PPTX
Microsoft Azure IaaS and Terraform
Alex Mags
 
Infrastructure-as-Code (IaC) using Terraform
Adin Ermie
 
Intro to Terraform
Josh Michielsen
 
Terraform
An Nguyen
 
Best Practices of Infrastructure as Code with Terraform
DevOps.com
 
An Introduction to Kubernetes
Imesh Gunaratne
 
Getting Started Monitoring with Prometheus and Grafana
Syah Dwi Prihatmoko
 
Terraform: An Overview & Introduction
Lee Trout
 
Terraform on Azure
Mithun Shanbhag
 
02 terraform core concepts
zekeLabs Technologies
 
A brief introduction to IaC with Terraform by Kenton Robbins (codeHarbour May...
Alex Cachia
 
Introduction to Kubernetes Workshop
Bob Killen
 
Terraform on Azure
Julien Corioland
 
Kubernetes Basics
Eueung Mulyana
 
Terraform
Harish Kumar
 
Monitoring with prometheus
Kasper Nissen
 
Terraform modules restructured
Ami Mahloof
 
Terraform
Otto Jongerius
 
Microsoft Azure IaaS and Terraform
Alex Mags
 

Similar to Introduction To Terraform (20)

PDF
Infrastructure as Code with Terraform
Pedro J. Molina
 
PDF
Provisioning infrastructure to AWS using Terraform – Exove
Exove
 
PPTX
Aprovisionamiento multi-proveedor con Terraform - Plain Concepts DevOps day
Plain Concepts
 
PDF
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
ssuser705051
 
PDF
Terraform-2.pdf
rutiksankapal21
 
PDF
Infrastructure as Code with Terraform
Tim Berry
 
PPTX
Infrastructure as Code with Terraform.pptx
Samuel862293
 
PPTX
Infrastructure as code with terraform and packer
Alex Landa
 
PPTX
Terraform: Taming the Machines Through Continuous Integration
Justin Rice
 
PDF
Instant download Terraform in Depth (MEAP V01) Robert Hafner pdf all chapter
akceyohros
 
PDF
Terraform In Action Meap V10 Meap Scott Winkler
heyenpardis0
 
PDF
Workshop Infrastructure as Code - Suestra
Mario IC
 
PDF
Terraforming your Infrastructure on GCP
Samuel Chow
 
PPTX
Terraform day1
Gourav Varma
 
PPTX
Infrastructure as code, using Terraform
Harkamal Singh
 
PDF
OracleBeer_Terraform_soe.pdf
Stefan Oehrli
 
PPTX
Terraform Automation in Azure Cloud Online Training in Hyderabad.pptx
sivavisualpath
 
PDF
DevOps Braga #9: Introdução ao Terraform
DevOps Braga
 
PDF
Infrastructure as Code - Terraform - Devfest 2018
Mathieu Herbert
 
PPTX
"Continuously delivering infrastructure using Terraform and Packer" training ...
Anton Babenko
 
Infrastructure as Code with Terraform
Pedro J. Molina
 
Provisioning infrastructure to AWS using Terraform – Exove
Exove
 
Aprovisionamiento multi-proveedor con Terraform - Plain Concepts DevOps day
Plain Concepts
 
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
ssuser705051
 
Terraform-2.pdf
rutiksankapal21
 
Infrastructure as Code with Terraform
Tim Berry
 
Infrastructure as Code with Terraform.pptx
Samuel862293
 
Infrastructure as code with terraform and packer
Alex Landa
 
Terraform: Taming the Machines Through Continuous Integration
Justin Rice
 
Instant download Terraform in Depth (MEAP V01) Robert Hafner pdf all chapter
akceyohros
 
Terraform In Action Meap V10 Meap Scott Winkler
heyenpardis0
 
Workshop Infrastructure as Code - Suestra
Mario IC
 
Terraforming your Infrastructure on GCP
Samuel Chow
 
Terraform day1
Gourav Varma
 
Infrastructure as code, using Terraform
Harkamal Singh
 
OracleBeer_Terraform_soe.pdf
Stefan Oehrli
 
Terraform Automation in Azure Cloud Online Training in Hyderabad.pptx
sivavisualpath
 
DevOps Braga #9: Introdução ao Terraform
DevOps Braga
 
Infrastructure as Code - Terraform - Devfest 2018
Mathieu Herbert
 
"Continuously delivering infrastructure using Terraform and Packer" training ...
Anton Babenko
 
Ad

Recently uploaded (20)

PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Women's Health: Essential Tips for Every Stage.pdf
Iftikhar Ahmed
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Ad

Introduction To Terraform

  • 1. TERRAFORM 3rd October 2018 Introduction to Terraform By Sasitha Rajapaksha
  • 2. Overview ● Terraform ● What is Terraform ● Why we use Terraform ● Terraform use cases ● Compare with Cloudformation ● Workflow of provisioning ● Hands on with Terraform ○ S3 ○ Cloudfront ○ EC2
  • 3. Terraform ● Open source ● Mozilla public licence 2.0 ● Created by Hashicorp ● Started in 2014 ● Written in GO ● Pluggable
  • 4. Terraform is a tool to BUILD, CHANGE and VERSION CONTROL your infrastructure. Terraform can work with multiple cloud infrastructure at the same time and ensure creation and consistency.
  • 5. Terraform Remote State ● There is default local state Which making sure that developer doesn’t do any changes to the same infrastructure at the same time ● Remote state ○ Work same as the local state but it is useful when working with a team. This remote state will share with each other and block the concurrent changes to the same infrastructure.
  • 6. Terraform use cases ● Apply incremental changes ● Destroy infrastructure at any time we want ● Preview changes ● Scale easily ● Version control
  • 7. Terraform vs. Cloudformation resource "aws_s3_bucket" "bucket" { bucket = "my-tf-test-bucket" acl = "private" } { "Resources": { "my-cf-test-bucket":{ "Type": "AWS::S3::Bucket", "Properties":{ "AccessControl":"Private", }, }, } } Terraform Cloudformation
  • 8. How Terraform works ● Terraform takes variables as a inputs ○ JSON ○ HCL ○ CLI ● Output ip address, texts and etc.. ○ JSON ○ CLI
  • 10. AWS Provider provider "aws" { access_key = "${var.aws_access_key}" secret_key = "${var.aws_secret_key}" region = "us-east-1" } Azure Provider provider "azurerm" { subscription_id = "${var.subscription_id }" client_id = "${var.client_id }" client_secret = "${var.client_secret }" tenant_id = "${var.tenant_id }" }
  • 11. Workflow of provisioning 1. First start with “terraform init” to setup initial aws or azure providers 2. Then “terraform plan” command to see than plan of what will provision 3. Finally “terraform apply” command to provision all the infrastructure 4. Okay, then you can use “terraform apply” at any time to do any changes to the provisioned infrastructure.
  • 12. S3 Bucket to store static website resource "aws_s3_bucket" "b" { bucket = "mybucket" acl = "private" tags { Name = "My bucket" } } locals { s3_origin_id = "myS3Origin" }
  • 13. EC2 instance provider "aws" { region = "us-west-2" } data "aws_ami" "ubuntu" { most_recent = true filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu- trusty-14.04-amd64-server-*"] } filter { name = "virtualization-type" values = ["hvm"] } owners = ["099720109477"] # Canonical } resource "aws_instance" "web" { ami = "${data.aws_ami.ubuntu.id}" instance_type = "t2.micro" tags { Name = "HelloWorld" } }
  • 14. Creating Cloudfront resource "aws_cloudfront_distribution" "s3_distribution" { origin { domain_name = "${aws_s3_bucket.b.bucket_regional_domain_name}" origin_id = "${local.s3_origin_id}" s3_origin_config { origin_access_identity = "origin-access-identity/cloudfront/ABCDEFG1234567" } } }