SlideShare a Scribd company logo
Building infrastructure
with Terraform
Radek Simko
$ whoami
radeksimko
}
twitter.com/
google.com/+
linkedin.com/in/
github.com/
Building infrastructure with Terraform (Google)
Provisioning of the past
● manual
● Shell, Perl
● extra knowledge required
○ bottleneck for team growth
● pure-ops task
○ devs & ops talking over a wall
Building infrastructure with Terraform (Google)
Provisioning today
● Chef, Puppet, Salt, Ansible
● knowledge codified
● de facto serves as documentation
● faster
● less error prone
● brings devs and ops closer
Infrastructure today
Hashicorp
Vagrant
● Virtualbox
● VMWare
● Docker
● AWS
● Google Cloud
● ...
Terraform
● AWS
● Azure
● Digital Ocean
● Google Cloud
● Docker
● OpenStack
● ...
Other solutions
● AWS CloudFormation
● Google Deployment Manager
● Heat (OpenStack)
● Puppet Cloud Provisioner
● Ansible
● SaltStack
● ...
XML
JSON
YAML
- states:
- QC: Quebec
- ON: Ontario
- BC: British Columbia
- YT: Yukon Territory
[
{
"states": [
{
"QC": "Quebec"
},
{
"true": "Ontario"
},
{
"BC": "British Columbia"
},
{
"YT": "Yukon Territory"
YAML
#cloud-config
_discovery_url: &ETCD_DISCOVERY_URL
url: "https://discovery.etcd.io/5416cf2db"
coreos:
fleet:
<<: *FLEET_METADATA
public-ip: $private_ipv4
etcd:
<<: *ETCD_DISCOVERY_URL
addr: $private_ipv4:4001
peer-addr: $private_ipv4:7001
Building infrastructure with Terraform (Google)
Building infrastructure with Terraform (Google)
jsonnet
● 20% project of Dave Cunningham
● Turing-complete language
● allows building more abstraction layers
● compatible w/ Terraform
DSL
● referencing
● reusability (DRY)
● human-readability
Demo 1
Basic two-tier app (POC)
https://github.com/radeksimko/terraform-examples/tree/master/google-two-tier-simple
DSL
● provider
● resource (ID + reference name)
● count attribute
● variable
● output
● provisioner
● Reference: ${TYPE.NAME.ATTRIBUTE}
● Expansion: ${TYPE.NAME.*.ATTRIBUTE}
Provisioners
● local-exec
● remote-exec
● chef
● …
Demo 2
Two-tier app (Scalable)
https://github.com/radeksimko/terraform-examples/tree/master/google-two-tier-scalable
DSL - built-in functions
● file(path)
● format("web-%03d", count.index+1)
● formatlist("https://%s:%s/", aws_instance.
foo.*.public_dns, var.port)
● lookup(map, key)
● ...
How does it work?
Why Terraform? (overview)
● Provider-agnostic
● DSL (yet JSON-compatible)
Why Terraform?
● open to community
○ missing feature or bug != support ticket
Why Terraform?
● doesn’t “own” your whole account or resource “type”
Why Terraform?
● core features
○ aware of dependency graph between resources
○ transparent state (pros/cons)
■ resources import (in the future)
■ detailed plan
■ maintenance & atomicity & sharing in the team
State
...
"google_compute_firewall.consul_admin_node": {
"type": "google_compute_firewall",
"primary": {
"id": "consul-admin-firewall",
"attributes": {
"allow.#": "1",
"allow.803338340.ports.#": "1",
"allow.803338340.ports.1685985038": "22",
"allow.803338340.protocol": "tcp",
"id": "consul-admin-firewall",
"name": "consul-admin-firewall",
"network": "default",
"self_link": "https://www.googleapis.com/compute/v1/projects/skilled-bee-777/global/firewalls/consul-
admin-firewall",
"source_tags.#": "1",
"source_tags.3928264908": "consul-web-ui",
"target_tags.#": "1",
"target_tags.1747926572": "consul-node"
}
}
},
...
State
● terraform.tfstate (default)
● Atlas
● S3
● Consul
● HTTP
● OpenStack’ Swift
State - setup
terraform remote config 
-backend=consul 
-backend-config="address=demo.consul.io:80" 
-backend-config="path=tf"
State - referencing
resource "terraform_remote_state" "network" {
backend = "atlas"
config {
name = "timeinc/network-prod"
}
}
resource "google_compute_firewall" "default" {
network = "${terraform_remote_state.network.network-name}"
...
Modules
module "consul" {
source = "github.com/hashicorp/consul/terraform/aws"
servers = 3
}
variable "servers" {
default = 2
}
$ terraform get
Modules
./module/outputs.tf
output "ip" {
value = "${google_compute_instance.default.public_ip}"
}
./main.tf
module "consul" {
…
${module.consul.ip}
Demo 3
Consul cluster
https://github.com/radeksimko/terraform-examples/tree/master/google-consul-module
New provider?
~/.terraformrc:
providers {
privatecloud = "/path/to/privatecloud"
}
Custom provider?
package main
import (
"github.com/hashicorp/terraform/plugin"
)
func main() {
plugin.Serve(new(MyPlugin))
}
Under the hood - provider
● helper/schema
What’s next?
● Kubernetes provider
● Google backend service (HTTP LB)
● …
↓ SLIDES ↓
$ whoami
radeksimko
}
twitter.com/
google.com/+
linkedin.com/in/
github.com/
slideshare.net/

More Related Content

PDF
Terraform in action
PDF
Terraform: Configuration Management for Cloud Services
PDF
Terraforming the Kubernetes Land
PDF
Infrastructure as Code in Google Cloud
PDF
Declarative & workflow based infrastructure with Terraform
PDF
Terraform 0.9 + good practices
PDF
Everything as Code with Terraform
PPTX
Effective terraform
Terraform in action
Terraform: Configuration Management for Cloud Services
Terraforming the Kubernetes Land
Infrastructure as Code in Google Cloud
Declarative & workflow based infrastructure with Terraform
Terraform 0.9 + good practices
Everything as Code with Terraform
Effective terraform

What's hot (20)

PDF
Terraform: Cloud Configuration Management (WTC/IPC'16)
PDF
Infrastructure as Code with Terraform
PPTX
Infrastructure as Code: Introduction to Terraform
PDF
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
PDF
Terraform: An Overview & Introduction
PPTX
Terraform
PDF
Terraform and cloud.ca
PPTX
"Continuously delivering infrastructure using Terraform and Packer" training ...
PPTX
Terraform Modules and Continuous Deployment
PDF
Infrastructure as code with Terraform
PPTX
Terraform at Scale
PDF
Case Study: Using Terraform and Packer to deploy go applications to AWS
PDF
Terraform – Infrastructure as Code (Kielux'18)
PDF
Rapid Infrastructure Provisioning
PDF
Best Practices of Infrastructure as Code with Terraform
PPTX
Scaling terraform environments infracoders sydney 30 nov 2017
PDF
Building infrastructure as code using Terraform - DevOps Krakow
PDF
Ground Control to Nomad Job Dispatch
PDF
Refactoring terraform
PDF
Terraform Introduction
Terraform: Cloud Configuration Management (WTC/IPC'16)
Infrastructure as Code with Terraform
Infrastructure as Code: Introduction to Terraform
Hashidays London 2017 - Evolving your Infrastructure with Terraform By Nicki ...
Terraform: An Overview & Introduction
Terraform
Terraform and cloud.ca
"Continuously delivering infrastructure using Terraform and Packer" training ...
Terraform Modules and Continuous Deployment
Infrastructure as code with Terraform
Terraform at Scale
Case Study: Using Terraform and Packer to deploy go applications to AWS
Terraform – Infrastructure as Code (Kielux'18)
Rapid Infrastructure Provisioning
Best Practices of Infrastructure as Code with Terraform
Scaling terraform environments infracoders sydney 30 nov 2017
Building infrastructure as code using Terraform - DevOps Krakow
Ground Control to Nomad Job Dispatch
Refactoring terraform
Terraform Introduction
Ad

Viewers also liked (20)

PPTX
An intro to Docker, Terraform, and Amazon ECS
PPTX
Comprehensive Terraform Training
PDF
Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)
PPTX
Managing AWS infrastructure using CloudFormation
PPTX
Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto
PPTX
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
PDF
PDF
CloudFormation vs Terraform vs Ansible
PDF
Startup DNA: Speed Wins
PDF
Rapid prototyping
PPTX
Orchestration tool roundup kubernetes vs. docker vs. heat vs. terra form vs...
PPTX
Startup Ideas and Validation
PDF
Build Features, Not Apps
PDF
Infrastructure as code: Cloud-Umgebungen mit Terraform verwalten
PDF
PPTX
Enabling Microservices Frameworks to Solve Business Problems
PDF
Rooting Out Root: User namespaces in Docker
PDF
Terraform始めました
PPTX
PDF
ContainerDays Boston 2016: "Autopilot: Running Real-world Applications in Con...
An intro to Docker, Terraform, and Amazon ECS
Comprehensive Terraform Training
Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)
Managing AWS infrastructure using CloudFormation
Orchestrating Docker with Terraform and Consul by Mitchell Hashimoto
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
CloudFormation vs Terraform vs Ansible
Startup DNA: Speed Wins
Rapid prototyping
Orchestration tool roundup kubernetes vs. docker vs. heat vs. terra form vs...
Startup Ideas and Validation
Build Features, Not Apps
Infrastructure as code: Cloud-Umgebungen mit Terraform verwalten
Enabling Microservices Frameworks to Solve Business Problems
Rooting Out Root: User namespaces in Docker
Terraform始めました
ContainerDays Boston 2016: "Autopilot: Running Real-world Applications in Con...
Ad

Similar to Building infrastructure with Terraform (Google) (20)

PDF
Infrastructure as Code with Terraform
PDF
Infrastructure as Code with Terraform
PDF
Terraform at Scale - All Day DevOps 2017
PDF
Terraform introduction
PDF
Workshop Infrastructure as Code - Suestra
PDF
Infrastructure as Code - Terraform - Devfest 2018
PDF
Terraforming your Infrastructure on GCP
PDF
Terraform - Taming Modern Clouds
PDF
Infrastructure as Code with Terraform
PDF
Understanding AWS with Terraform
PDF
TIAD : Automating the modern datacenter
PDF
Infrastructure as code terraformujeme cloud
PDF
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
PDF
DevOps Braga #9: Introdução ao Terraform
PDF
PDF
Agiles Peru 2019 - Infrastructure As Code
PPTX
Infrastructure as Code with Terraform.pptx
PDF
A case study why Zoominfo uses Terraform Cloud in high-scale environment.
PDF
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
PDF
Terraform-2.pdf
Infrastructure as Code with Terraform
Infrastructure as Code with Terraform
Terraform at Scale - All Day DevOps 2017
Terraform introduction
Workshop Infrastructure as Code - Suestra
Infrastructure as Code - Terraform - Devfest 2018
Terraforming your Infrastructure on GCP
Terraform - Taming Modern Clouds
Infrastructure as Code with Terraform
Understanding AWS with Terraform
TIAD : Automating the modern datacenter
Infrastructure as code terraformujeme cloud
OSDC 2015: Mitchell Hashimoto | Automating the Modern Datacenter, Development...
DevOps Braga #9: Introdução ao Terraform
Agiles Peru 2019 - Infrastructure As Code
Infrastructure as Code with Terraform.pptx
A case study why Zoominfo uses Terraform Cloud in high-scale environment.
Hashicorp-Terraform-Deep-Dive-with-no-Fear-Victor-Turbinsky-Texuna.pdf
Terraform-2.pdf

Recently uploaded (20)

PDF
NewMind AI Monthly Chronicles - July 2025
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Empathic Computing: Creating Shared Understanding
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
Cloud computing and distributed systems.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Machine learning based COVID-19 study performance prediction
PDF
KodekX | Application Modernization Development
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
NewMind AI Monthly Chronicles - July 2025
The AUB Centre for AI in Media Proposal.docx
Understanding_Digital_Forensics_Presentation.pptx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Spectral efficient network and resource selection model in 5G networks
Empathic Computing: Creating Shared Understanding
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Encapsulation theory and applications.pdf
Cloud computing and distributed systems.
Reach Out and Touch Someone: Haptics and Empathic Computing
Network Security Unit 5.pdf for BCA BBA.
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Weekly Chronicles - August'25 Week I
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Machine learning based COVID-19 study performance prediction
KodekX | Application Modernization Development
Diabetes mellitus diagnosis method based random forest with bat algorithm
Mobile App Security Testing_ A Comprehensive Guide.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation

Building infrastructure with Terraform (Google)