greyhoundforty
12/2/2015 - 5:24 PM

Digital Ocean Terraform file

Digital Ocean Terraform file

variable "do_token" {}
variable "ssh_keys" {}
variable "key_file" {}
variable "size" {
  default = "1gb"
}
variable "dnsimple_email" {}
variable "dnsimple_token" {}


provider "digitalocean" {
  token = "${var.do_token}"
}

resource "digitalocean_droplet" "ozone" {
  name = "ozone"
  image = "ubuntu-14-04-x64"
  private_networking = true
  region = "nyc2"
  size = "${var.size}"
  ssh_keys = ["${var.ssh_keys}"]

  provisioner "file" {
    connection {
      user = "root"
      key_file = "${var.key_file}"
    }

    source = "vars.txt"
    destination = "/root/vars.txt"
  }

  provisioner "remote-exec" {
    connection {
      user = "root"
      key_file = "${var.key_file}"
    }

    inline = [
      "curl -sL -O https://dl.dropboxusercontent.com/u/131462/do_provisioner.sh",
      "bash -l -i do_provisioner.sh"
    ]
  }
}

resource "digitalocean_droplet" "deploy2" {
  name = "deploy2"
  image = "ubuntu-14-04-x64"
  private_networking = true
  region = "nyc2"
  size = "${var.size}"
  ssh_keys = ["${var.ssh_keys}"]

  provisioner "file" {
    connection {
      user = "root"
      key_file = "${var.key_file}"
    }

    source = "vars.txt"
    destination = "/root/vars.txt"
  }

  provisioner "remote-exec" {
    connection {
      user = "root"
      key_file = "${var.key_file}"
    }

    inline = [
      "curl -sL -O https://dl.dropboxusercontent.com/u/131462/do_provisioner.sh",
      "bash -l -i do_provisioner.sh"
    ]
  }
}


# Configure the DNSimple provider
provider "dnsimple" {
    token = "${var.dnsimple_token}"
    email = "${var.dnsimple_email}"
}

resource "dnsimple_record" "ozone" {
      domain = "tinybot.io"
      name = "ozone"
      value = "${digitalocean_droplet.ozone.ipv4_address}"
      type = "A"
}

output "address_ozone" {
  value = "${digitalocean_droplet.ozone.ipv4_address}"
}

resource "dnsimple_record" "deploy2" {
      domain = "tinybot.io"
      name = "deploy2"
      value = "${digitalocean_droplet.deploy2.ipv4_address}"
      type = "A"
}

output "deploy2" {
  value = "${digitalocean_droplet.deploy2.ipv4_address}"
}