Created
August 19, 2015 10:06
-
-
Save robmorgan/c05405befb6f6df5cd45 to your computer and use it in GitHub Desktop.
Use Terraform to create a droplet on Digital Ocean
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "do_token" {} | |
variable "pub_key" {} | |
variable "pvt_key" {} | |
variable "ssh_fingerprint" {} | |
provider "digitalocean" { | |
token = "${var.do_token}" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "digitalocean_droplet" "www-1" { | |
image = "ubuntu-14-04-x64" | |
name = "www-1" | |
region = "fra1" | |
size = "512mb" | |
private_networking = true | |
ssh_keys = [ | |
"${var.ssh_fingerprint}" | |
] | |
provisioner "remote-exec" { | |
connection { | |
user = "root" | |
type = "ssh" | |
key_file = "${var.pvt_key}" | |
timeout = "2m" | |
} | |
inline = [ | |
"export PATH=$PATH:/usr/bin", | |
# install nginx | |
"sudo apt-get update", | |
"sudo apt-get -y install nginx" | |
# install php | |
"sudo apt-get install php5-fpm", | |
# cgi.fix_pathinfo=0 | |
"sudo sed -i 's/HAPROXY_PUBLIC_IP/${digitalocean_droplet.haproxy-www.ipv4_address}/g' /etc/haproxy/haproxy.cfg", | |
# install composer | |
service nginx restart | |
# restart nginx to load changes | |
# restart php5-fpm | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add comma after this command
"sudo apt-get -y install nginx",