Introduction to Terraform: IaC
Jay Kim
Nov 28, 2019
class 101
101.1 What is Terraform?

101.2 Key Features of Terraform

101.3 Pros and Cons

101.4 Providers

101.5 Basic of Infrastructure

101.6 Getting Started
Samsung Electronics, Staff Engineer
Global Service Reliability Engineer
Jay Kim
class 101
class 101
101.1 What is Terraform?
class 101 101.1 What is Terraform?
Use Infrastructure as Code(IaC) to provision and manage any cloud, infrastructure, or service
class 101 101.1 What is Terraform?
Terraform
Infrastructure
creation
DEV
STG
Prod
Use Infrastructure as Code(IaC) to provision and manage any cloud, infrastructure, or service
class 101 101.1 What is Terraform?
Use Infrastructure as Code(IaC) to provision and manage any cloud, infrastructure, or service
class 101 101.1 What is Terraform?
HCL
(Hashicorp Configuration Language (HCL))
Use Infrastructure as Code(IaC) to provision and manage any cloud, infrastructure, or service
class 101 101.1 What is Terraform?
class 101 101.1 What is Terraform?
class 101 101.1 What is Terraform?
class 101 101.1 What is Terraform?
class 101 101.1 What is Terraform?
class 101 101.1 What is Terraform?
class 101 101.1 What is Terraform?
Armon Dadgar(24)
co-founder and CTO
Mitchell Hashimoto(26)
co-founder and CEO
class 101 101.1 What is Terraform?
Armon Dadgar(24)
co-founder and CTO
Mitchell Hashimoto(26)
co-founder and CEO
class 101 101.1 What is Terraform?
Armon Dadgar(24)
co-founder and CTO
http://mitchellh.com/automation-obsessed
Mitchell Hashimoto(26)
co-founder and CEO
class 101 101.1 What is Terraform?
Mitchell Hashimoto(26)
co-founder and CEO
http://mitchellh.com/automation-obsessed
class 101 101.1 What is Terraform?
Terraform is, the result of
“Engineering Thinking”
Do Coding For Everything
(Automation)
Summary
class 101
101.2 Key Features of Terraform
class 101 101.2 Key Features of Terraform
class 101 101.2 Key Features of Terraform
class 101 101.2 Key Features of Terraform
class 101 101.2 Key Features of Terraform
class 101 101.2 Key Features of Terraform
class 101 101.2 Key Features of Terraform
These features are very similar with
class 101 101.2 Key Features of Terraform
These features are very similar with React
class 101 101.2 Key Features of Terraform
Terraform is an infrastructure provisioning tool 

but the concepts aren’t only for SysOps Engineer.
class 101 101.2 Key Features of Terraform
*.examples of declarative
class 101
101.2 Key Features of Terraform
class 101 101.2 Key Features of Terraform
class 101 101.2 Key Features of Terraform
class 101 101.2 Key Features of Terraform
class 101 101.2 Key Features of Terraform
class 101 101.2 Key Features of Terraform
class 101 101.2 Key Features of Terraform
These features are very similar with
class 101 101.2 Key Features of Terraform
These features are very similar with React
class 101 101.2 Key Features of Terraform
Terraform is an infrastructure provisioning tool 

but the concepts aren’t only for SysOps Engineer.

Summary
class 101 101.2 Key Features of Terraform
*.examples of declarative
class 101
101.3 Pros and Cons
class 101 101.3 Pros and Cons
Pros Cons
Problem Solving

w/Engineer’s way

Reusable

Resources

Productivity

High Entry Barrier

(Especially, non-coder) 

Reduce

Human Error
Everyone

Should do Terraform

Difficult to train
Difficult to design
class 101
101.4 Providers
class 101
major cloud
101.4 Providers
class 101
major cloud
Infrastructure Software
VCS
Monitoring & System Management
101.4 Providers
class 101
Community
101.4 Providers
class 101 101.4 Providers Summary
Code For Everything
Not only for the infrastructure
class 101
101.5 Basic Infrastructure
class 101 101.5 Basic of Infrastructure
Customer
Mobile App
Web Browser
WebServer
Backend
LB
LB
LB
DB
VPC
class 101 101.5 Basic of Infrastructure
Customer
Mobile App
Web Browser
DB
WebServer
Backend
LB
LB
LB
Public Subnet Private Subnet DB Subnet
VPC
class 101 101.5 Basic of Infrastructure
Customer
Mobile App
Web Browser
DB
WebServer
Backend
LB
LB
LB
Public Subnet Private Subnet DB Subnet
IGW
NAT
Internet VPC
class 101
101.6 Getting Started
class 101 101.6 Getting Started
DEMO Public Subnet Private Subnet DB Subnet
IGW
NAT
Internet VPC
class 101 101.6 Getting Started
Terraform Install
https://www.terraform.io/downloads.html
After download the package,
$ mv terraform terraform_v0.12.0
$ mv terraform_v0.12.0 /usr/local/bin/terraform_v0.12.0
$ ln -s /usr/local/bin/terraform_v0.12.0 /usr/local/bin/tf
class 101 101.6 Getting Started
HCL(Hashicorp Configuration Language)
1. Providers

2. Resources

3. Input Variables. (TBD)

4. Output Values. (TBD)

5. Local Values

6. Modules. (TBD)

7. Data Sources (TBD)

8. Functions(Interpolation). (TBD)

9. State (TBD)

10.Backend (TBD)
Commands
1. Init

2. plan (w/target)

3. apply

4. destroy
class 101 101.6 Getting Started
DEMO Public Subnet Private Subnet DB Subnet
IGW
NAT
Internet VPC
class 101 101.6 Getting Started
2. AWS Profile Setup
1. AWS Programmable Key Creation
AWS Admin Console -> User -> Security Credentials -> Access Keys -> Create access key
$ vi ~/.aws/credentials
[dev]

aws_access_key_id={{ access_key }}

aws_secret_access_key={{ secret_access_key }}
DEMO
class 101 101.6 Getting Started
3. TF Demo Folder Creation
4. aws.tf file creation
5. Search “terraform was provider” in Google
DEMO
class 101 101.6 Getting Started
6. Copy & Paste
7. Add profile = “dev"
DEMO
class 101 101.6 Getting Started
8. “tf init”
DEMO
class 101 101.6 Getting Started
9. Search “terraform aws vpc” in google
DEMO
class 101 101.6 Getting Started
9. Search “terraform aws vpc” in google
DEMO
class 101 101.6 Getting Started
9. Search “terraform aws vpc” in google
DEMO
class 101 101.6 Getting Started
10. create “vpc.tf” file
DEMO
class 101 101.6 Getting Started
11. Execute “tf plan”
DEMO
class 101 101.6 Getting Started
DEMO
11. Execute “tf apply”
12. Checking “VPC Creation” in AWS Console
class 101 101.6 Getting Started
13. Change “Name” Tag Value & “tf plan” & “tf apply”
14. Checking the “VPC Name Change” on AWS Console
15. Add “local” variable
DEMO
class 101 101.6 Getting Started
16. Search “terraform aws subnet”
DEMO
17.Add “aws_subnet” “private”, “public”, “db” with cidrs
class 101 101.6 Getting Started
DEMO
17.Add “aws_subnet” “private”, “public”, “db” with cidrs
* Interpolation Warning
${aws_vpc.main.id}
Terraform Version < 0.12.x
aws_vpc.main.id
Terraform Version > 0.12.x
18.plan / apply
class 101 101.6 Getting Started
DEMO
19. igw, route table, nat, nat_eip
class 101 101.6 Getting Started
DEMO
19. igw, route table, nat, nat_eip

Introduce to Terraform

  • 1.
    Introduction to Terraform:IaC Jay Kim Nov 28, 2019 class 101 101.1 What is Terraform? 101.2 Key Features of Terraform 101.3 Pros and Cons 101.4 Providers 101.5 Basic of Infrastructure 101.6 Getting Started
  • 2.
    Samsung Electronics, StaffEngineer Global Service Reliability Engineer Jay Kim class 101
  • 3.
    class 101 101.1 Whatis Terraform?
  • 4.
    class 101 101.1What is Terraform? Use Infrastructure as Code(IaC) to provision and manage any cloud, infrastructure, or service
  • 5.
    class 101 101.1What is Terraform? Terraform Infrastructure creation DEV STG Prod Use Infrastructure as Code(IaC) to provision and manage any cloud, infrastructure, or service
  • 6.
    class 101 101.1What is Terraform? Use Infrastructure as Code(IaC) to provision and manage any cloud, infrastructure, or service
  • 7.
    class 101 101.1What is Terraform? HCL (Hashicorp Configuration Language (HCL)) Use Infrastructure as Code(IaC) to provision and manage any cloud, infrastructure, or service
  • 8.
    class 101 101.1What is Terraform?
  • 9.
    class 101 101.1What is Terraform?
  • 10.
    class 101 101.1What is Terraform?
  • 11.
    class 101 101.1What is Terraform?
  • 12.
    class 101 101.1What is Terraform?
  • 13.
    class 101 101.1What is Terraform?
  • 14.
    class 101 101.1What is Terraform? Armon Dadgar(24) co-founder and CTO Mitchell Hashimoto(26) co-founder and CEO
  • 15.
    class 101 101.1What is Terraform? Armon Dadgar(24) co-founder and CTO Mitchell Hashimoto(26) co-founder and CEO
  • 16.
    class 101 101.1What is Terraform? Armon Dadgar(24) co-founder and CTO http://mitchellh.com/automation-obsessed Mitchell Hashimoto(26) co-founder and CEO
  • 17.
    class 101 101.1What is Terraform? Mitchell Hashimoto(26) co-founder and CEO http://mitchellh.com/automation-obsessed
  • 18.
    class 101 101.1What is Terraform? Terraform is, the result of “Engineering Thinking” Do Coding For Everything (Automation) Summary
  • 19.
    class 101 101.2 KeyFeatures of Terraform
  • 20.
    class 101 101.2Key Features of Terraform
  • 21.
    class 101 101.2Key Features of Terraform
  • 22.
    class 101 101.2Key Features of Terraform
  • 23.
    class 101 101.2Key Features of Terraform
  • 24.
    class 101 101.2Key Features of Terraform
  • 25.
    class 101 101.2Key Features of Terraform These features are very similar with
  • 26.
    class 101 101.2Key Features of Terraform These features are very similar with React
  • 27.
    class 101 101.2Key Features of Terraform Terraform is an infrastructure provisioning tool but the concepts aren’t only for SysOps Engineer.
  • 28.
    class 101 101.2Key Features of Terraform *.examples of declarative
  • 29.
    class 101 101.2 KeyFeatures of Terraform
  • 30.
    class 101 101.2Key Features of Terraform
  • 31.
    class 101 101.2Key Features of Terraform
  • 32.
    class 101 101.2Key Features of Terraform
  • 33.
    class 101 101.2Key Features of Terraform
  • 34.
    class 101 101.2Key Features of Terraform
  • 35.
    class 101 101.2Key Features of Terraform These features are very similar with
  • 36.
    class 101 101.2Key Features of Terraform These features are very similar with React
  • 37.
    class 101 101.2Key Features of Terraform Terraform is an infrastructure provisioning tool but the concepts aren’t only for SysOps Engineer. Summary
  • 38.
    class 101 101.2Key Features of Terraform *.examples of declarative
  • 39.
  • 40.
    class 101 101.3Pros and Cons Pros Cons Problem Solving w/Engineer’s way Reusable Resources Productivity High Entry Barrier (Especially, non-coder) Reduce Human Error Everyone Should do Terraform Difficult to train Difficult to design
  • 41.
  • 42.
  • 43.
    class 101 major cloud InfrastructureSoftware VCS Monitoring & System Management 101.4 Providers
  • 44.
  • 45.
    class 101 101.4Providers Summary Code For Everything Not only for the infrastructure
  • 46.
    class 101 101.5 BasicInfrastructure
  • 47.
    class 101 101.5Basic of Infrastructure Customer Mobile App Web Browser WebServer Backend LB LB LB DB VPC
  • 48.
    class 101 101.5Basic of Infrastructure Customer Mobile App Web Browser DB WebServer Backend LB LB LB Public Subnet Private Subnet DB Subnet VPC
  • 49.
    class 101 101.5Basic of Infrastructure Customer Mobile App Web Browser DB WebServer Backend LB LB LB Public Subnet Private Subnet DB Subnet IGW NAT Internet VPC
  • 50.
  • 51.
    class 101 101.6Getting Started DEMO Public Subnet Private Subnet DB Subnet IGW NAT Internet VPC
  • 52.
    class 101 101.6Getting Started Terraform Install https://www.terraform.io/downloads.html After download the package, $ mv terraform terraform_v0.12.0 $ mv terraform_v0.12.0 /usr/local/bin/terraform_v0.12.0 $ ln -s /usr/local/bin/terraform_v0.12.0 /usr/local/bin/tf
  • 53.
    class 101 101.6Getting Started HCL(Hashicorp Configuration Language) 1. Providers 2. Resources 3. Input Variables. (TBD) 4. Output Values. (TBD) 5. Local Values 6. Modules. (TBD) 7. Data Sources (TBD) 8. Functions(Interpolation). (TBD) 9. State (TBD) 10.Backend (TBD) Commands 1. Init 2. plan (w/target) 3. apply 4. destroy
  • 54.
    class 101 101.6Getting Started DEMO Public Subnet Private Subnet DB Subnet IGW NAT Internet VPC
  • 55.
    class 101 101.6Getting Started 2. AWS Profile Setup 1. AWS Programmable Key Creation AWS Admin Console -> User -> Security Credentials -> Access Keys -> Create access key $ vi ~/.aws/credentials [dev] aws_access_key_id={{ access_key }} aws_secret_access_key={{ secret_access_key }} DEMO
  • 56.
    class 101 101.6Getting Started 3. TF Demo Folder Creation 4. aws.tf file creation 5. Search “terraform was provider” in Google DEMO
  • 57.
    class 101 101.6Getting Started 6. Copy & Paste 7. Add profile = “dev" DEMO
  • 58.
    class 101 101.6Getting Started 8. “tf init” DEMO
  • 59.
    class 101 101.6Getting Started 9. Search “terraform aws vpc” in google DEMO
  • 60.
    class 101 101.6Getting Started 9. Search “terraform aws vpc” in google DEMO
  • 61.
    class 101 101.6Getting Started 9. Search “terraform aws vpc” in google DEMO
  • 62.
    class 101 101.6Getting Started 10. create “vpc.tf” file DEMO
  • 63.
    class 101 101.6Getting Started 11. Execute “tf plan” DEMO
  • 64.
    class 101 101.6Getting Started DEMO 11. Execute “tf apply” 12. Checking “VPC Creation” in AWS Console
  • 65.
    class 101 101.6Getting Started 13. Change “Name” Tag Value & “tf plan” & “tf apply” 14. Checking the “VPC Name Change” on AWS Console 15. Add “local” variable DEMO
  • 66.
    class 101 101.6Getting Started 16. Search “terraform aws subnet” DEMO 17.Add “aws_subnet” “private”, “public”, “db” with cidrs
  • 67.
    class 101 101.6Getting Started DEMO 17.Add “aws_subnet” “private”, “public”, “db” with cidrs * Interpolation Warning ${aws_vpc.main.id} Terraform Version < 0.12.x aws_vpc.main.id Terraform Version > 0.12.x 18.plan / apply
  • 68.
    class 101 101.6Getting Started DEMO 19. igw, route table, nat, nat_eip
  • 69.
    class 101 101.6Getting Started DEMO 19. igw, route table, nat, nat_eip