Terraform
Digital Ocean example
resource "digitalocean_droplet" "web" {
image = "ubuntu-14-04-x64"
name = "web-1"
region = "nyc2"
size = "512mb"
}
DevOps Consultancy
Slide 7
Slide 7 text
Terraform
AWS security group example
# Security group for web server
!
resource "aws_security_group" "hello_web" {
name = "hello-elb-sg"
description = "Security Group for web servers"
!
# HTTP access from anywhere
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
}
DevOps Consultancy
Slide 8
Slide 8 text
Terraform
AWS security group example
$ terraform plan
!
+ aws_security_group.hello_web
description: "" => "Security Group for web servers"
ingress.#: "" => "1"
ingress.0.cidr_blocks.#: "" => "1"
ingress.0.cidr_blocks.0: "" => "0.0.0.0/0"
ingress.0.from_port: "" => "80"
ingress.0.protocol: "" => "tcp"
ingress.0.to_port: "" => "80"
name: "" => "hello-elb-sg"
owner_id: "" => ""
!
DevOps Consultancy
resource "aws_instance" "web" {
!
connection {
user = "ubuntu"
key_file = "${var.key_path}"
}
!
instance_type = "t2.micro"
ami = "${lookup(var.amis, var.region)}"
!
key_name = "${var.key_name}"
!
security_groups = ["${aws_security_group.hello_web.name}"]
!
provisioner "local-exec" {
command = "knife bootstrap ${aws_instance.example.public_ip}"
}
}
}
DevOps Consultancy
Using with Chef
Slide 20
Slide 20 text
Packer
• Terraform works well with AMIs generated by
Packer
• http://www.packer.io/
DevOps Consultancy
Slide 21
Slide 21 text
Terraform
• Amazon autoscaling groups, RDS, ELB, EIP, S3, VPC
• Cloudflare DNS
• Consul
• Digital Ocean DNS
• Google Cloud
• Herkou
• Mailgun
DevOps Consultancy
What else can you do