-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
32 lines (28 loc) · 940 Bytes
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
data "aws_acm_certificate" "cert" {
count = var.run_data ? 1 : 0
domain = var.certificate_domain_name
statuses = ["ISSUED"]
key_types = ["RSA_4096", "RSA_2048"]
}
resource "aws_alb" "alb" {
name = replace(replace(var.name, "/(.{0,32}).*/", "$1"), "/^-+|-+$/", "")
internal = var.internal
security_groups = concat([aws_security_group.default.id], var.extra_security_groups)
subnets = var.subnet_ids
tags = var.tags
idle_timeout = var.idle_timeout
access_logs {
bucket = var.access_logs_bucket
enabled = var.access_logs_enabled
}
}
resource "aws_alb_listener" "https" {
load_balancer_arn = aws_alb.alb.arn
port = "443"
protocol = "HTTPS"
certificate_arn = element(concat(data.aws_acm_certificate.cert.*.arn, [""]), 0)
default_action {
target_group_arn = var.default_target_group_arn
type = "forward"
}
}