Skip to content

Commit

Permalink
Workaround for terraform destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
mejedi committed Feb 7, 2020
1 parent ac67073 commit 6fe96ca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions deployments/modules/backend/main.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
data "digitalocean_image" "base_image" {
count = (var.app_version == "" ? 0 : 1)
name = "image-${var.app_version}"
}

# terraform destroy workaround
locals {
image_id = var.app_version == "" ? 0 : data.digitalocean_image.base_image[0].id
}

resource "digitalocean_droplet" "web" {
count = var.web_cluster_size
lifecycle { create_before_destroy = true }
tags = [ "luajit-me" ]

image = data.digitalocean_image.base_image.id
image = local.image_id
name = "${var.prefix}web-${count.index+1}"
region = "ams3"
size = "s-1vcpu-1gb"
Expand Down Expand Up @@ -47,7 +53,7 @@ resource "digitalocean_droplet" "compute_amd64" {
lifecycle { create_before_destroy = true }
tags = [ "luajit-me" ]

image = data.digitalocean_image.base_image.id
image = local.image_id
name = "${var.prefix}compute-amd64-${each.key}"
region = "ams3"
size = "s-1vcpu-1gb"
Expand Down

0 comments on commit 6fe96ca

Please sign in to comment.