variable "digitalocean_key" {}

variable "region" {
  default = "nyc1"
}
variable "image" {
  default = "ubuntu-16-04-x64"
}
variable "sql-size" {
	default = "2gb"
}
variable "web-size" {
	default = "2gb"
}
variable "home-ssh-key" {
	default = "14:17:41:55:1e:be:39:31:3d:f7:99:75:36:fd:23:21"
}

# Configure the DigitalOcean Provider
provider "digitalocean" {
  token = "${var.digitalocean_key}"
}

# Server tags
resource "digitalocean_tag" "web" {
  name = "web"
}
resource "digitalocean_tag" "prod" {
  name = "prod"
}
resource "digitalocean_tag" "sql" {
  name = "sql"
}

# Create a web server
resource "digitalocean_droplet" "web" {
  name               = "wimermedia-web"
  size               = "${var.web-size}"
  image              = "${var.image}"
  region             = "${var.region}"
  ipv6               = true
  private_networking = true
  ssh_keys			 = ["${var.home-ssh-key}"]
  tags = ["${digitalocean_tag.web.id}","${digitalocean_tag.prod.id}"]
}

#resource "digitalocean_floating_ip" "web" {
#  droplet_id = "${digitalocean_droplet.web.id}"
#  region     = "${digitalocean_droplet.web.region}"
#}

# Create a sql server
resource "digitalocean_droplet" "sql" {
  name               = "wimermedia-sql"
  size               = "${var.sql-size}"
  image              = "${var.image}"
  region             = "${var.region}"
  ipv6               = true
  private_networking = true
  ssh_keys			 = ["${var.home-ssh-key}"]
  tags = ["${digitalocean_tag.sql.id}","${digitalocean_tag.prod.id}"]
}