-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal_accelerator.tf
More file actions
78 lines (63 loc) · 2.17 KB
/
global_accelerator.tf
File metadata and controls
78 lines (63 loc) · 2.17 KB
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
resource "aws_globalaccelerator_accelerator" "this" {
count = var.enable_global_accelerator ? 1 : 0
name = local.resource_name
ip_address_type = "IPV4"
enabled = true
tags = local.tags
attributes {
flow_logs_enabled = true
flow_logs_s3_bucket = module.logs_bucket.bucket_id
flow_logs_s3_prefix = "accelerator-flow-logs/"
}
}
locals {
ga_arn = var.enable_global_accelerator ? aws_globalaccelerator_accelerator.this[0].arn : ""
ga_dns_name = var.enable_global_accelerator ? aws_globalaccelerator_accelerator.this[0].dns_name : ""
ga_zone_id = var.enable_global_accelerator ? aws_globalaccelerator_accelerator.this[0].hosted_zone_id : ""
}
resource "aws_globalaccelerator_listener" "this_http" {
count = var.enable_global_accelerator ? 1 : 0
accelerator_arn = local.ga_arn
client_affinity = "NONE"
protocol = "TCP"
port_range {
from_port = 80
to_port = 80
}
}
resource "aws_globalaccelerator_endpoint_group" "this_http" {
count = var.enable_global_accelerator ? 1 : 0
listener_arn = aws_globalaccelerator_listener.this_http[count.index].arn
traffic_dial_percentage = 100
health_check_protocol = "TCP"
health_check_port = 80
health_check_interval_seconds = 30
threshold_count = 3
endpoint_configuration {
endpoint_id = aws_lb.this.arn
weight = 100
}
}
resource "aws_globalaccelerator_listener" "this_https" {
count = var.enable_global_accelerator && var.enable_https ? 1 : 0
accelerator_arn = local.ga_arn
client_affinity = "NONE"
protocol = "TCP"
port_range {
from_port = 443
to_port = 443
}
}
resource "aws_globalaccelerator_endpoint_group" "this_https" {
count = var.enable_global_accelerator && var.enable_https ? 1 : 0
listener_arn = aws_globalaccelerator_listener.this_https[count.index].arn
traffic_dial_percentage = 100
health_check_protocol = "TCP"
health_check_port = 443
health_check_interval_seconds = 30
threshold_count = 3
endpoint_configuration {
endpoint_id = aws_lb.this.arn
weight = 100
}
}