Last active
June 22, 2016 22:49
-
-
Save sherzberg/f8004fe83afe0d23d2b1efc8e04d455c to your computer and use it in GitHub Desktop.
DevopsDSM Workshop
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_ssh_key" "default" { | |
name = "devbox" | |
public_key = "${file("id_rsa.pub")}" | |
} | |
resource "digitalocean_droplet" "devbox" { | |
image = "ubuntu-16-04-x64" | |
name = "dev-spencer" | |
region = "nyc3" | |
size = "4gb" | |
ssh_keys = ["${digitalocean_ssh_key.default.id}"] | |
} | |
resource "null_resource" "ssh" { | |
connection { | |
user = "root" | |
host = "${digitalocean_droplet.devbox.ipv4_address}" | |
key_file = "id_rsa" | |
timeout = "10m" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"apt-get update", | |
"apt-get install -y cowsay", | |
"cowsay All Done!", | |
] | |
} | |
} | |
resource "digitalocean_floating_ip" "default" { | |
droplet_id = "${digitalocean_droplet.devbox.id}" | |
region = "${digitalocean_droplet.devbox.region}" | |
} | |
output "ips" { | |
value = "${digitalocean_droplet.devbox.ipv4_address}" | |
} | |
output "floating-ip" { | |
value = "${digitalocean_floating_ip.default.ip_address}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment