aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/digitalocean/server/main.tf
blob: 37ed3f19336f39d8b0b4d43c952c1a9051461f75 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
        
                                                                      












                                        
                                                                       

















                                                       
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
}