This repository was archived by the owner on Jan 13, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathservice-tg.tf
More file actions
100 lines (77 loc) · 2.34 KB
/
service-tg.tf
File metadata and controls
100 lines (77 loc) · 2.34 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
module "service_custom_tg" {
source = "../../"
environment = var.environment
project = var.project
ecs_cluster_id = module.ecs_cluster.id
ecs_cluster_name = module.ecs_cluster.name
docker_image = "nginx"
docker_image_tag = "stable"
service_name = "service_custom_tg"
ecs_service_role = module.ecs_cluster.service_role_name
vpc_id = module.vpc.vpc_id
container_ssl_enabled = false
container_ports = ["80"]
alb_container_port = 80
enable_target_group_connection = true
target_group_arn = aws_alb_target_group.target_group.arn
ecs_services_dependencies = concat(aws_lb_listener_rule.default.*.arn, [])
// Monitoring settings, disabled
enable_monitoring = false
// Enables logging to other targets (default is STDOUT)
// For CloudWatch logging, make sure the awslogs-group exists
docker_logging_config = <<EOF
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${var.environment}",
"awslogs-region": "${var.aws_region}",
"awslogs-stream-prefix": "${var.service_name}"
}
}
EOF
}
module "lb_service_custom_tg" {
source = "git::https://github.com/philips-software/terraform-aws-ecs-service-load-balancer.git?ref=terraform012"
environment = var.environment
project = var.project
name_suffix = "basic-lb"
vpc_id = module.vpc.vpc_id
vpc_cidr = module.vpc.vpc_cidr
subnets = module.vpc.public_subnets
type = "application"
port = 80
create_listener = true
internal = false
}
data "aws_lb" "lb_service_custom_tg" {
arn = module.lb_service_custom_tg.arn
}
output "lb_service_custom_tg_dns" {
value = "http://${data.aws_lb.lb_service_custom_tg.dns_name}/"
}
resource "aws_alb_target_group" "target_group" {
port = "80"
protocol = "HTTP"
vpc_id = module.vpc.vpc_id
health_check {
protocol = "HTTP"
path = "/"
matcher = "200-399"
interval = "30"
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_lb_listener_rule" "default" {
listener_arn = module.lb_service_custom_tg.listener_arn
priority = 100
action {
type = "forward"
target_group_arn = aws_alb_target_group.target_group.arn
}
condition {
field = "path-pattern"
values = ["/*"]
}
}