-
Notifications
You must be signed in to change notification settings - Fork 5
/
variables.tf
92 lines (77 loc) · 2.41 KB
/
variables.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
variable "name" {
description = "Name of load balancer. Also used in security group name."
type = string
}
variable "internal" {
description = "Type of LoadBalancer"
type = bool
default = false
}
variable "public_subnets" {
description = "List of AWS public subnet ids"
type = list(string)
}
variable "target_cidr_blocks" {
description = "List of AWS private target subnet CIDR"
type = list(string)
}
variable "http_ports" {
description = "List of plain http ports"
default = [80]
}
variable "https_ports" {
description = "List of encrypted https ports"
default = [443]
}
variable "certificate_arn" {
description = "Certificate for ALB that should contains "
default = ""
}
variable "access_log_bucket" {
description = "Bucket to setore ALB access log"
default = ""
}
variable "access_log_prefix" {
description = "Enable ALB access log"
default = ""
}
variable "idle_timeout" {
description = "Connection idle timeout"
default = 60
}
data "aws_subnet" "public_1" {
id = local.public_subnets[0]
}
variable "tags" {
description = "Tags."
type = map(string)
default = {}
}
locals {
name = var.name
internal = var.internal
alb_name = replace(local.name, " ", "-")
public_subnets = var.public_subnets
http_ports = var.http_ports
https_ports = var.https_ports
all_ports = concat(local.https_ports, local.http_ports)
vpc_id = data.aws_subnet.public_1.vpc_id
target_cidr_blocks = var.target_cidr_blocks
alb_certificate_arn = var.certificate_arn
idle_timeout = var.idle_timeout
// magic to get map of port to listener arn pairs
listener_http_ports = aws_alb_listener.http.*.port
listener_http_arn = aws_alb_listener.http.*.arn
listener_https_ports = aws_alb_listener.https.*.port
listener_https_arn = aws_alb_listener.https.*.arn
listener_http_map = zipmap(local.listener_http_ports, local.listener_http_arn)
listener_https_map = zipmap(local.listener_https_ports, local.listener_https_arn)
listeners = merge(local.listener_http_map, local.listener_https_map)
access_logs_enable = var.access_log_bucket == "" ? false : true
access_logs_bucket = var.access_log_bucket
access_logs_prefix = var.access_log_prefix
tags = merge({
Name = var.name,
Module = "ALB"
}, var.tags)
}