using terraform.io (human talks montpellier, epitech, 2014/09/09)
DESCRIPTION
How to build an infrastructure & handle change with Hashicorp's Terraform. The talk was "distributed teams" oriented.TRANSCRIPT
![Page 1: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/1.jpg)
Using Terraform.ioBuild & Change an Infrastructure with Terraform 2014/09/09
![Page 2: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/2.jpg)
`whoami`
@sjourdan
@greenalto
![Page 3: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/3.jpg)
Vagrant?
![Page 4: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/4.jpg)
Vagrant
For development environments
![Page 5: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/5.jpg)
Vagrant
Mimic production environments
![Page 6: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/6.jpg)
Vagrant
!sharing
!durability
!evolution
!services
!production
![Page 7: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/7.jpg)
Terraform
![Page 8: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/8.jpg)
Terraform
Infrastructure?
servers, VMs (EC2, DigitalOcean…)
services (Heroku, ELB, EIP…)
DNS (DNSimple,…)
email (Mailgun…)
![Page 9: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/9.jpg)
Terraform
![Page 10: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/10.jpg)
Terraform
![Page 11: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/11.jpg)
Terraform
APIs
![Page 12: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/12.jpg)
Terraform
![Page 13: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/13.jpg)
Terraform
Launch infrastructure
Change infrastructure
![Page 14: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/14.jpg)
Terraform
Simple file based configuration
![Page 15: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/15.jpg)
5 days since CoreOS on DO
![Page 16: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/16.jpg)
Terraform
resource "digitalocean_droplet" "coreos-1" {
}
![Page 17: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/17.jpg)
Terraform
resource "digitalocean_droplet" "coreos-1" {
name = “coreos-1”
}
![Page 18: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/18.jpg)
Terraform
resource "digitalocean_droplet" "coreos-1" {
name = “coreos-1”
size = "512mb"
}
![Page 19: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/19.jpg)
Terraform
resource "digitalocean_droplet" "coreos-1" {
name = “coreos-1”
size = “512mb"
image = "coreos-alpha"
}
![Page 20: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/20.jpg)
Terraform
resource "digitalocean_droplet" "coreos-1" {
name = “coreos-1”
size = “512mb"
image = “coreos-alpha"
region = "nyc3"
}
![Page 21: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/21.jpg)
Terraformresource "digitalocean_droplet" "coreos-1" {
name = “coreos-1”
size = “512mb"
image = “coreos-alpha"
region = “nyc3"
private_networking = true
}
![Page 22: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/22.jpg)
Terraformresource "digitalocean_droplet" "coreos-1" {
name = “coreos-1”
size = “512mb"
image = “coreos-alpha"
region = “nyc3"
private_networking = true
ssh_keys = [ "131228" ]
}
![Page 23: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/23.jpg)
Terraform
$ terraform apply
![Page 24: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/24.jpg)
Terraform$ terraform apply digitalocean_droplet.ht-coreos-1: Creating... image: "" => "coreos-alpha" name: "" => "ht-coreos-1" private_networking: "" => "true" region: "" => "nyc3" size: "" => "512mb" ssh_keys.#: "" => "1" ssh_keys.0: "" => "131228" digitalocean_droplet.ht-coreos-1: Creation complete !Apply complete! Resources: 1 added, 0 changed, 0 destroyed. !The state of your infrastructure has been saved to the path below. This state is required to modify and destroy your infrastructure, so keep it safe. To inspect the complete state use the `terraform show` command. !State path: terraform.tfstate
![Page 25: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/25.jpg)
Terraform
$ terraform show terraform.tfstate
![Page 26: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/26.jpg)
Terraform$ terraform show terraform.tfstate digitalocean_droplet.ht-coreos-1: id = 2574081 image = coreos-alpha ipv4_address = 104.131.47.30 ipv4_address_private = 10.132.241.137 locked = false name = ht-coreos-1 private_networking = true region = nyc3 size = 512mb ssh_keys.# = 1 ssh_keys.0 = 131228 status = active
![Page 27: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/27.jpg)
Terraform
![Page 28: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/28.jpg)
Terraform
Scale? Handle Change?
![Page 29: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/29.jpg)
Terraform
![Page 30: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/30.jpg)
Terraform
$ terraform plan
![Page 31: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/31.jpg)
Terraform
$ terraform plan -out=terraform.plan !
+ digitalocean_droplet.ht-coreos-2 !
[…] !
+ digitalocean_droplet.ht-coreos-3 […]
![Page 32: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/32.jpg)
Terraform$ terraform apply digitalocean_droplet.ht-coreos-1: Refreshing state... (ID: 2574081) digitalocean_droplet.ht-coreos-2: Creating... […] digitalocean_droplet.ht-coreos-3: Creating... […] digitalocean_droplet.ht-coreos-3: Creation complete digitalocean_droplet.ht-coreos-2: Creation complete !Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
![Page 33: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/33.jpg)
Terraform
![Page 34: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/34.jpg)
Terraform
Downscale ?
![Page 35: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/35.jpg)
Terraform
$ terraform plan -out=terraform.plan !
[…] - digitalocean_droplet.ht-coreos-1
![Page 36: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/36.jpg)
Terraform$ terraform apply digitalocean_droplet.ht-coreos-1: Refreshing state... (ID: 2574081) digitalocean_droplet.ht-coreos-3: Refreshing state... (ID: 2574214) digitalocean_droplet.ht-coreos-2: Refreshing state... (ID: 2574215) digitalocean_droplet.ht-coreos-1: Destroying... digitalocean_droplet.ht-coreos-1: Destruction complete !Apply complete! Resources: 0 added, 0 changed, 1 destroyed.
![Page 37: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/37.jpg)
Terraform
![Page 38: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/38.jpg)
Terraform
![Page 39: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/39.jpg)
Terraform
terraform.tfstate
=> git pull your infrastructure state!
![Page 40: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/40.jpg)
Terraform
![Page 41: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/41.jpg)
Terraform
![Page 42: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/42.jpg)
Terraform
Provisionners
echo, cat or grep
myapp.conf
Chef, Puppet, Ansible, whatever
![Page 43: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/43.jpg)
Terraform
provisioner "remote-exec" { inline = [ "curl -L https://www.opscode.com/chef/install.sh | sudo bash", "sudo chef-solo -j chef/node.json" ] }
![Page 44: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/44.jpg)
Terraform
resource "dnsimple_record" “cluster-1" { domain = “humantalks.com" name = "cluster-1" value = “${digitalocean_droplet.web.ipv4_address}" type = "A" }
![Page 45: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/45.jpg)
Terraform
autoscaling_group db_instance security_group eip elb instance route53 s3 …
![Page 46: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/46.jpg)
Terraform (Sept. 2014)
![Page 47: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/47.jpg)
Terraform
2014/07/28: 0.1.0
2014/08/28: 0.2.0
![Page 48: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/48.jpg)
Terraform
https://github.com/hashicorp/terraform/
http://www.terraform.io/
![Page 49: Using Terraform.io (Human Talks Montpellier, Epitech, 2014/09/09)](https://reader034.vdocuments.mx/reader034/viewer/2022042713/547e5537b37959822b8b5418/html5/thumbnails/49.jpg)
Q&A
Questions ?