aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/digitalocean/server/main.tf
blob: 78298f4f18b7773e5f711bf1553a34c0923c965f (plain) (tree)

































                                                                 
locals {
  sshd_config = templatefile("${path.module}/etc/sshd_config", {
    port  = var.ssh_port
    users = [var.user]
  })
}

resource "digitalocean_droplet" "this" {
  image      = var.image
  name       = var.name
  region     = var.region
  size       = var.size
  monitoring = true
  ipv6       = false
  vpc_uuid   = var.vpc_id
  user_data = templatefile("${path.module}/etc/cloud-init.cfg", {
    user        = var.user
    ssh_keys    = var.ssh_keys
    sshd_config = local.sshd_config
  })
  volume_ids        = var.volume_ids
  droplet_agent     = false
  graceful_shutdown = true
}

resource "digitalocean_project_resources" "this" {
  project   = var.project_id
  resources = [digitalocean_droplet.this.urn]
}

resource "digitalocean_floating_ip_assignment" "this" {
  ip_address = var.ip_address
  droplet_id = digitalocean_droplet.this.id
}