Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[terraform-aws] Improve terraform aws teardown dependencies #982

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "aws_eks_cluster" "kubernetes_cluster" {
name = var.cluster_name
role_arn = aws_iam_role.dss-cluster.arn

vpc_config {
subnet_ids = aws_subnet.dss[*].id
endpoint_public_access = true
Expand All @@ -13,8 +13,14 @@ resource "aws_eks_cluster" "kubernetes_cluster" {
# Ensure that IAM Role permissions are created before and deleted after EKS Cluster handling.
# Otherwise, EKS will not be able to properly delete EKS managed EC2 infrastructure such as Security Groups.
depends_on = [
aws_iam_role.dss-cluster-node-group,
aws_iam_role_policy_attachment.dss-cluster-service,
aws_internet_gateway.dss
aws_iam_role_policy_attachment.AmazonEKSWorkerNodePolicy,
aws_iam_role_policy_attachment.AmazonEKS_CNI_Policy,
aws_iam_role_policy_attachment.AWSLoadBalancerControllerPolicy,
aws_internet_gateway.dss,
aws_eip.gateway,
aws_eip.ip_crdb
]

version = "1.24"
Expand All @@ -39,4 +45,9 @@ resource "aws_eks_node_group" "eks_node_group" {
lifecycle {
create_before_destroy = true
}

depends_on = [
aws_eip.gateway,
aws_eip.ip_crdb
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ output "generated_files_location" {
value = <<-EOT
Workspace location with generated files: ${local.workspace_location}
EOT
}
}

output "workspace_location" {
value = local.workspace_location
}
1 change: 0 additions & 1 deletion deploy/infrastructure/modules/terraform-aws-dss/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module "terraform-aws-kubernetes" {
crdb_hostname_suffix = var.crdb_hostname_suffix
aws_instance_type = var.aws_instance_type
aws_route53_zone_id = var.aws_route53_zone_id
aws_iam_path = var.aws_iam_path
aws_iam_permissions_boundary = var.aws_iam_permissions_boundary
node_count = var.node_count

Expand Down
11 changes: 10 additions & 1 deletion deploy/infrastructure/modules/terraform-aws-dss/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@ output "gateway_address" {
value = module.terraform-aws-kubernetes.gateway_address
}

output "iam_role_node_group_arn" {
value = module.terraform-aws-kubernetes.iam_role_node_group_arn
}

output "generated_files_location" {
value = module.terraform-commons-dss.generated_files_location
}

output "workspace_location" {
value = module.terraform-commons-dss.workspace_location
}

output "cluster_context" {
value = module.terraform-aws-kubernetes.kubernetes_context_name
}
}

Loading