variable "user" {}
variable "password" {}

# Terraform backends cannot contain interpolations
terraform {
  backend "s3" {
    bucket  = "orcd-terraform-state"
    key     = "prod/prod-avl-t0-backup01/terraform.tfstate"
    region  = "us-east-1"
    encrypt = "true"
  }
}

provider "vsphere" {
  user           = "${var.user}"
  password       = "${var.password}"
  vsphere_server = "t0-vcenter-appliance01.avl.theorchard.com"

  # If you have a self-signed cert
  allow_unverified_ssl = true
}

module "backup_vm" {
  source = "git@github.com:theorchard/terraform-vmware.git"

  vsphere_user     = "${var.user}"
  vsphere_password = "${var.password}"
  vsphere_server   = "t0-vcenter-appliance01.avl.theorchard.com"

  vm_hostnames = [
    "prod-avl-t0-backup01",
  ]

  vm_domain                    = "avl.theorchard"
  vsphere_datacenter_name      = "t0-avl-datacenter"
  vsphere_datastore_name       = "t0-nimble02-vol1"
  vsphere_compute_cluster_name = "t0-avl-cluster"
  vsphere_network_name         = "Tier0"
  chef_client_version          = "14.10.9"
  chef_bootstrap_script_path   = "~/chef-repo/t0_knife_bootstrap_host.sh"
}

resource "vsphere_virtual_disk" "t0_backup_disk" {
  size       = 8000
  vmdk_path  = "t0_backup_disk.vmdk"
  datacenter = "t0-avl-datacenter"
  datastore  = "t0-nimble02-backup01"
  type       = "eagerZeroedThick"
}
