From c75fbb0164427cbe92fe67c942140afba5936d2c Mon Sep 17 00:00:00 2001 From: "Thierno IB. BARRY" Date: Mon, 12 Oct 2020 21:50:22 +0200 Subject: [PATCH] fix: Fix cycle error during the destroy phase when we change workers order (#1043) NOTES: Keep in mind that changing the order of workers group is a destructive operation. All workers group are destroyed and recreated. If you want to do this safely, you should move then in state with `terraform state mv` until we manage workers groups as maps. --- workers.tf | 8 ++++++++ workers_launch_template.tf | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/workers.tf b/workers.tf index c6618a8..a20b7d6 100644 --- a/workers.tf +++ b/workers.tf @@ -295,6 +295,10 @@ resource "random_pet" "workers" { keepers = { lc_name = aws_launch_configuration.workers[count.index].name } + + lifecycle { + create_before_destroy = true + } } resource "aws_security_group" "workers" { @@ -409,6 +413,10 @@ resource "aws_iam_instance_profile" "workers" { ) path = var.iam_path + + lifecycle { + create_before_destroy = true + } } resource "aws_iam_role_policy_attachment" "workers_AmazonEKSWorkerNodePolicy" { diff --git a/workers_launch_template.tf b/workers_launch_template.tf index 2546393..9d1ed28 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -492,6 +492,7 @@ resource "random_pet" "workers_launch_template" { ) ) } + lifecycle { create_before_destroy = true } @@ -506,4 +507,8 @@ resource "aws_iam_instance_profile" "workers_launch_template" { local.default_iam_role_id, ) path = var.iam_path + + lifecycle { + create_before_destroy = true + } }