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

HOTFIX: When setting enabled = false, also destroy ALB #5

Merged
merged 1 commit into from
Oct 6, 2023
Merged
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
18 changes: 9 additions & 9 deletions elb.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
resource "aws_security_group" "alb" {
count = var.alb_enabled ? 1 : 0
count = local.enabled && var.alb_enabled ? 1 : 0
description = "Controls access to the ${var.use_wrong_loadbalancer_name ? "" : "Kylin "}ALB (HTTP/HTTPS)"
vpc_id = var.vpc_id
name = module.label_alb.id
tags = module.label_alb.tags
}

resource "aws_security_group_rule" "alb_egress" {
count = var.alb_enabled ? 1 : 0
count = local.enabled && var.alb_enabled ? 1 : 0
type = "egress"
from_port = "0"
to_port = "0"
Expand All @@ -28,7 +28,7 @@ resource "aws_security_group_rule" "alb_http_ingress" {
}

resource "aws_security_group_rule" "alb_https_ingress" {
count = var.alb_enabled && var.alb_allow_https_access ? 1 : 0
count = local.enabled && var.alb_enabled && var.alb_allow_https_access ? 1 : 0
type = "ingress"
from_port = 443
to_port = 443
Expand All @@ -39,7 +39,7 @@ resource "aws_security_group_rule" "alb_https_ingress" {
}

resource "aws_lb" "default" {
count = var.alb_enabled ? 1 : 0
count = local.enabled && var.alb_enabled ? 1 : 0
name = module.label_alb.id
tags = module.label_alb.tags
internal = var.alb_internal
Expand All @@ -56,7 +56,7 @@ resource "aws_lb" "default" {
}

resource "aws_route53_record" "default" {
count = var.alb_enabled ? 1 : 0
count = local.enabled && var.alb_enabled ? 1 : 0
zone_id = var.zone_id
name = var.master_dns_name
type = "A"
Expand All @@ -69,7 +69,7 @@ resource "aws_route53_record" "default" {
}

resource "aws_lb_target_group" "default" {
count = var.alb_enabled ? 1 : 0
count = local.enabled && var.alb_enabled ? 1 : 0
name = module.label_alb.id
port = var.alb_target_group_port
protocol = var.alb_target_group_protocol
Expand Down Expand Up @@ -102,7 +102,7 @@ resource "aws_lb_target_group" "default" {
}

resource "aws_lb_target_group_attachment" "default" {
count = var.alb_enabled && var.master_instance_group_instance_count > 0 ? var.master_instance_group_instance_count : 0
count = local.enabled && var.alb_enabled && var.master_instance_group_instance_count > 0 ? var.master_instance_group_instance_count : 0
target_group_arn = aws_lb_target_group.default[0].arn
target_id = element(data.aws_instances.emr_master_instances.ids, count.index)
port = var.alb_target_group_port
Expand All @@ -114,7 +114,7 @@ resource "aws_lb_target_group_attachment" "default" {
}

resource "aws_lb_listener" "http_redirect" {
count = var.alb_enabled && var.alb_allow_http_access ? 1 : 0
count = local.enabled && var.alb_enabled && var.alb_allow_http_access ? 1 : 0
load_balancer_arn = aws_lb.default[0].arn
port = 80
protocol = "HTTP"
Expand All @@ -132,7 +132,7 @@ resource "aws_lb_listener" "http_redirect" {
}

resource "aws_lb_listener" "https" {
count = var.alb_enabled && var.alb_allow_https_access ? 1 : 0
count = local.enabled && var.alb_enabled && var.alb_allow_https_access ? 1 : 0
load_balancer_arn = aws_lb.default[0].arn

port = 443
Expand Down