Skip to content

Commit

Permalink
fix: terraform destroy dependency graph fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Soham Kalghatgi committed Nov 22, 2024
1 parent f8dbf65 commit d1d1e34
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 40 deletions.
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,17 +306,7 @@ foreach ($bucket in $buckets) {
}
```

The remaining infrastructure resources can be deleted via Terraform.
Due to a bug, Terraform is not able to properly [plan the removal of resources in the right order](https://github.com/aws-ia/terraform-aws-eks-blueprints/issues/353) which leads to a deadlock.
To workaround the bug, you need to need to remove the `eks-addons` module at first:

```sh
terraform destroy -target="module.eks-addons"
```

:warning: **It is important that you have completed the preceding steps. Otherwise, the following command will not finish completly, leaving you in a deadlock state.**

To delete the remaining resources, run the following command:
The remaining infrastructure resources can be deleted via Terraform by running the following command.

```sh
terraform destroy
Expand Down
2 changes: 1 addition & 1 deletion k8s-eks-addons.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ module "k8s_eks_addons" {
tags = var.tags
}

depends_on = [module.eks.eks_cluster_arn]
depends_on = [module.eks.eks_cluster_arn, module.vpc]
}
20 changes: 0 additions & 20 deletions k8s.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,6 @@ module "eks" {
managed_node_groups = merge(local.default_managed_node_pools, var.gpuNodePool ? local.gpu_node_pool : {}, var.ivsGpuNodePool ? local.ivsgpu_node_pool : {})
}


module "eks-addons" {
source = "git::https://github.com/aws-ia/terraform-aws-eks-blueprints.git//modules/kubernetes-addons?ref=v4.32.1"
eks_cluster_id = module.eks.eks_cluster_id
enable_aws_load_balancer_controller = false
enable_aws_for_fluentbit = var.enable_aws_for_fluentbit
tags = var.tags

aws_for_fluentbit_helm_config = {
values = [templatefile("${path.module}/templates/fluentbit_values.yaml", {
aws_region = data.aws_region.current.name,
log_group_name = local.log_group_name,
service_account_name = "aws-for-fluent-bit-sa"
})]
dependency_update = true
}

#depends_on = [module.eks.managed_node_groups]
}

data "aws_eks_node_group" "default" {
cluster_name = local.infrastructurename
node_group_name = replace(module.eks.managed_node_groups[0]["default"]["managed_nodegroup_id"][0], "${local.infrastructurename}:", "")
Expand Down
3 changes: 2 additions & 1 deletion modules/k8s_eks_addons/ingress-nginx.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ resource "helm_release" "ingress_nginx" {
}),
var.aws_load_balancer_controller_config.enable ? var.aws_load_balancer_controller_config.chart_values : var.ingress_nginx_config.chart_values
]
timeout = 1200
timeout = 1200
depends_on = [helm_release.aws_load_balancer_controller, kubernetes_namespace_v1.ingress_nginx]
}
4 changes: 2 additions & 2 deletions modules/k8s_eks_addons/load-balancer-controller.tf
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ resource "aws_iam_role_policy_attachment" "aws_load_balancer_controller" {
}


resource "helm_release" "aws-load-balancer-controller" {
resource "helm_release" "aws_load_balancer_controller" {
count = var.aws_load_balancer_controller_config.enable ? 1 : 0

name = local.aws_load_balancer_controller_name
Expand All @@ -423,5 +423,5 @@ resource "helm_release" "aws-load-balancer-controller" {
description = "AWS load balancer controller helm chart deployment configuration for ingress resources"
dependency_update = true

depends_on = [aws_iam_role.aws_load_balancer_controller]
depends_on = [helm_release.cluster_autoscaler]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ clusterName: ${eks_cluster_id}
region: ${aws_region}
image:
repository: ${repository}
rbac:
serviceAccount:
name: ${service_account}
create: false

serviceAccount:
create: false
name: ${service_account}

0 comments on commit d1d1e34

Please sign in to comment.