Skip to content

Commit cd85d6a

Browse files
authored
Refactor code (#7)
* Refactor code * Fixing error
1 parent 3093b13 commit cd85d6a

File tree

1 file changed

+40
-42
lines changed

1 file changed

+40
-42
lines changed

variables.tf

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -86,67 +86,65 @@ variable "ip_address_type" {
8686
# ACCESS CONTROL TO APPLICATION LOAD BALANCER
8787
#------------------------------------------------------------------------------
8888
variable "http_ports" {
89-
description = "Map containing objects with two fields, listener_port and the target_group_port to redirect HTTP requests"
89+
description = "Map containing objects to define listeners behaviour based on type field. If type field is `forward`, include listener_port and the target_group_port. For `redirect` type, include listener port, host, path, port, protocol, query and status_code. For `fixed-response`, include listener_port, content_type, message_body and status_code"
9090
type = map(any)
9191
default = {
9292
default_http = {
93+
type = "forward"
9394
listener_port = 80
9495
target_group_port = 80
9596
}
9697
}
9798
}
9899

99-
/*
100-
101-
Other options for listeners (The same are valid also for https_ports variable):
102-
103-
Redirect (Force HTTPS):
104-
105-
variable "http_ports" {
106-
description = "Map containing objects with two fields, listener_port and the target_group_port to redirect HTTP requests"
107-
type = map
108-
default = {
109-
force_https = {
110-
type = "redirect"
111-
listener_port = 80
112-
host = "#{host}"
113-
path = "/#{path}"
114-
port = "443"
115-
protocol = "https"
116-
query = "#{query}"
117-
status_code = "HTTP_301"
118-
}
119-
}
120-
}
121-
122-
variable "http_ports" {
123-
description = "Map containing objects with two fields, listener_port and the target_group_port to redirect HTTP requests"
124-
type = map
125-
default = {
126-
fixed_response = {
127-
type = "fixed-response"
128-
listener_port = 80
129-
content_type = "text/plain"
130-
message_body = "Server error"
131-
status_code = "500"
132-
}
133-
}
134-
}
135-
136-
*/
137-
138-
139100
variable "https_ports" {
140-
description = "Map containing objects with two fields, listener_port and the target_group_port to redirect HTTPS requests"
101+
description = "Map containing objects to define listeners behaviour based on type field. If type field is `forward`, include listener_port and the target_group_port. For `redirect` type, include listener port, host, path, port, protocol, query and status_code. For `fixed-response`, include listener_port, content_type, message_body and status_code"
141102
type = map(any)
142103
default = {
143104
default_http = {
105+
type = "forward"
144106
listener_port = 443
145107
target_group_port = 443
146108
}
147109
}
148110
}
149111

112+
/*
113+
Other options for listeners (The same are valid also for https_ports variable):
114+
115+
Redirect (Force HTTPS):
116+
variable "http_ports" {
117+
description = "Map containing objects with two fields, listener_port and the target_group_port to redirect HTTP requests"
118+
type = map
119+
default = {
120+
force_https = {
121+
type = "redirect"
122+
listener_port = 80
123+
host = "#{host}"
124+
path = "/#{path}"
125+
port = "443"
126+
protocol = "https"
127+
query = "#{query}"
128+
status_code = "HTTP_301"
129+
}
130+
}
131+
}
132+
Fixed response:
133+
variable "http_ports" {
134+
description = "Map containing objects with two fields, listener_port and the target_group_port to redirect HTTP requests"
135+
type = map
136+
default = {
137+
fixed_response = {
138+
type = "fixed-response"
139+
listener_port = 80
140+
content_type = "text/plain"
141+
message_body = "Server error"
142+
status_code = "500"
143+
}
144+
}
145+
}
146+
*/
147+
150148
variable "http_ingress_cidr_blocks" {
151149
description = "List of CIDR blocks to allowed to access the Load Balancer through HTTP"
152150
type = list(string)

0 commit comments

Comments
 (0)