-
Notifications
You must be signed in to change notification settings - Fork 7
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
Modules for ALB, NLB & corresponding listeners #13
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
31179e8
WIP: introduce alb_listener module between alb and alb_rule_target. M…
ringods be76b93
Using the new AWS `lb` resources.
ringods 2a18086
Adding the NLB and NLB listener modules.
ringods ad27759
Adding documentation.
ringods 5a23a5e
Mentioning the upcoming work for additional certificates.
ringods 06af644
Use `name_prefix` instead of `name`
ringods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,29 @@ | ||
output "id" { | ||
description = "ID of the ALB" | ||
value = "${aws_alb.alb.id}" | ||
value = "${aws_lb.alb.id}" | ||
} | ||
|
||
output "arn" { | ||
description = "ARN of the ALB" | ||
value = "${aws_alb.alb.arn}" | ||
value = "${aws_lb.alb.arn}" | ||
} | ||
|
||
output "name" { | ||
description = "Name of the ALB" | ||
value = "${aws_alb.alb.name}" | ||
value = "${aws_lb.alb.name}" | ||
} | ||
|
||
output "dns_name" { | ||
description = "DNS name of the ALB" | ||
value = "${aws_alb.alb.dns_name}" | ||
value = "${aws_lb.alb.dns_name}" | ||
} | ||
|
||
output "zone_id" { | ||
description = "DNS zone ID of the ALB" | ||
value = "${aws_alb.alb.zone_id}" | ||
value = "${aws_lb.alb.zone_id}" | ||
} | ||
|
||
output "sg_id" { | ||
description = "ID of the ALB security group" | ||
value = "${aws_security_group.sg_alb.id}" | ||
} | ||
|
||
output "http_listener_id" { | ||
description = "ID of the ALB HTTP listener" | ||
value = "${aws_alb_listener.https.id}" | ||
} | ||
|
||
output "https_listener_id" { | ||
description = "ID of the ALB HTTPS listener" | ||
value = "${aws_alb_listener.https.id}" | ||
} | ||
|
||
output "target_group_arn" { | ||
description = "ID of the default target group" | ||
value = "${aws_alb_target_group.default.arn}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
resource "aws_lb_target_group" "default" { | ||
count = "${var.default_target_group_arn == "" ? 1 : 0}" | ||
|
||
# target group name can't be longer than 32 chars, and terraform autogenerated name is 26 characters long | ||
# so `name_prefix` can't be longer than 6 characters. Resource is tagged in any case for a clear identification in AWS | ||
name_prefix = "${var.name_prefix}" | ||
|
||
port = "${var.target_port}" | ||
protocol = "${var.target_protocol}" | ||
vpc_id = "${var.vpc_id}" | ||
deregistration_delay = "${var.target_deregistration_delay}" | ||
stickiness = ["${var.target_stickiness}"] | ||
|
||
health_check { | ||
interval = "${var.target_health_interval}" | ||
path = "${var.target_health_path}" | ||
timeout = "${var.target_health_timeout}" | ||
healthy_threshold = "${var.target_health_healthy_threshold}" | ||
unhealthy_threshold = "${var.target_health_unhealthy_threshold}" | ||
matcher = "${var.target_health_matcher}" | ||
protocol = "${var.target_health_protocol}" | ||
} | ||
|
||
tags = "${merge("${var.tags}", | ||
map("Name", "${var.project}-${var.environment}-${var.name_prefix}-target-group", | ||
"Environment", "${var.environment}", | ||
"Project", "${var.project}")) | ||
}" | ||
} | ||
|
||
resource "aws_lb_listener" "listener" { | ||
load_balancer_arn = "${var.alb_arn}" | ||
port = "${var.ingress_port == -1 ? (var.https_certificate_arn == "" ? 80 : 443) : var.ingress_port }" | ||
protocol = "${var.https_certificate_arn == "" ? "HTTP" : "HTTPS"}" | ||
certificate_arn = "${var.https_certificate_arn}" | ||
|
||
default_action { | ||
# Using join with resource.* as workaround for https://github.com/hashicorp/hil/issues/50 | ||
target_group_arn = "${var.default_target_group_arn == "" ? join(" ", aws_lb_target_group.default.*.arn) : var.default_target_group_arn}" | ||
type = "forward" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
output "listener_id" { | ||
description = "ID of the ALB HTTP/HTTPS listener" | ||
value = "${aws_lb_listener.listener.id}" | ||
} | ||
|
||
output "target_group_arn" { | ||
description = "ID of the default target group" | ||
value = "${join(" ", aws_lb_target_group.default.*.arn)}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resource "aws_security_group_rule" "sg_alb_ingress" { | ||
security_group_id = "${var.alb_sg_id}" | ||
type = "ingress" | ||
from_port = "${var.ingress_port == -1 ? (var.https_certificate_arn == "" ? 80 : 443) : var.ingress_port }" | ||
to_port = "${var.ingress_port == -1 ? (var.https_certificate_arn == "" ? 80 : 443) : var.ingress_port }" | ||
protocol = "tcp" | ||
cidr_blocks = "${var.source_subnet_cidrs}" | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use
name_prefix