From 6fe96cacb6c0b0639fc6890afeb7fdbd15341a01 Mon Sep 17 00:00:00 2001 From: Nick Zavaritsky Date: Fri, 7 Feb 2020 09:07:45 +0000 Subject: [PATCH] Workaround for terraform destroy --- deployments/modules/backend/main.tf | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/deployments/modules/backend/main.tf b/deployments/modules/backend/main.tf index 5cb32d8..b1640a6 100644 --- a/deployments/modules/backend/main.tf +++ b/deployments/modules/backend/main.tf @@ -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" @@ -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"