forked from zoitech/terraform-aws-concourse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ec2_alb.tf
56 lines (45 loc) · 1.45 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
resource "aws_lb_target_group" "concourse" {
name = "${var.prefix}-concourse-backend"
port = 8080
protocol = "HTTP"
vpc_id = var.vpc_id
}
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
}
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
}