-
Notifications
You must be signed in to change notification settings - Fork 5
/
ec2_alb.tf
60 lines (47 loc) · 1.59 KB
/
ec2_alb.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
resource "aws_lb_target_group" "concourse" {
name = "${var.prefix}-concourse-backend"
port = 8080
protocol = "HTTP"
vpc_id = var.vpc_id
tags = merge({ Name = "${var.prefix}-concourse-backend" }, var.alb_tags)
}
resource "aws_lb_target_group_attachment" "concourse" {
target_group_arn = aws_lb_target_group.concourse.arn
target_id = aws_instance.ec2_docker_instance.id
port = 8080
}
resource "aws_lb" "concourse" {
name = "${var.prefix}-concourse-alb"
internal = false
security_groups = flatten([aws_security_group.GroupLB[*].id, var.alb_sg_id])
subnets = var.public_sn
access_logs {
enabled = var.enable_alb_access_logs #default = false
bucket = var.s3_log_bucket_name
prefix = var.s3_log_bucket_Key_name
}
enable_deletion_protection = false
tags = merge({ Name = "${var.prefix}-concourse-alb" }, var.alb_tags)
}
resource "aws_lb_listener" "concource_http" {
load_balancer_arn = aws_lb.concourse.arn
port = "80"
protocol = "HTTP"
default_action {
target_group_arn = aws_lb_target_group.concourse.arn
type = "forward"
}
count = var.certificate_arn == "" ? 1 : 0
}
resource "aws_lb_listener" "concource_https" {
load_balancer_arn = aws_lb.concourse.arn
port = "443"
protocol = "HTTPS"
ssl_policy = "ELBSecurityPolicy-2015-05"
certificate_arn = var.certificate_arn
default_action {
target_group_arn = aws_lb_target_group.concourse.arn
type = "forward"
}
count = var.certificate_arn == "" ? 0 : 1
}