Skip to content

Instantly share code, notes, and snippets.

@sherzberg
Last active June 22, 2016 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sherzberg/f8004fe83afe0d23d2b1efc8e04d455c to your computer and use it in GitHub Desktop.
Save sherzberg/f8004fe83afe0d23d2b1efc8e04d455c to your computer and use it in GitHub Desktop.
DevopsDSM Workshop
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