Skip to content

Commit

Permalink
fix: Fix cycle error during the destroy phase when we change workers …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
barryib authored Oct 12, 2020
1 parent c54ce91 commit c75fbb0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions workers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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" {
Expand Down
5 changes: 5 additions & 0 deletions workers_launch_template.tf
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ resource "random_pet" "workers_launch_template" {
)
)
}

lifecycle {
create_before_destroy = true
}
Expand All @@ -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
}
}

0 comments on commit c75fbb0

Please sign in to comment.