github.com/tetrafolium/tflint@v0.8.0/tflint/test-fixtures/v0.11.0_module/.terraform/modules/75f06b5c36dd1be566ec9e32e6aca4b5/alb.tf (about) 1 resource "aws_security_group" "ecs_alb" { 2 description = "Balancer for ${var.app_name}" 3 4 vpc_id = "${var.vpc}" 5 name = "${var.app_name}-alb-sg" 6 7 ingress { 8 protocol = "tcp" 9 from_port = "${var.app_port}" 10 to_port = "${var.app_port}" 11 cidr_blocks = ["0.0.0.0/0"] 12 } 13 14 egress { 15 from_port = 0 16 to_port = 0 17 protocol = "-1" 18 cidr_blocks = ["0.0.0.0/0"] 19 } 20 } 21 22 resource "aws_alb" "main" { 23 name = "${var.app_name}" 24 subnets = "${var.subnets}" 25 security_groups = ["${aws_security_group.ecs_alb.id}"] 26 } 27 28 resource "aws_alb_target_group" "main" { 29 name = "${var.app_name}" 30 port = "${var.app_port}" 31 protocol = "HTTP" 32 vpc_id = "${var.vpc}" 33 34 depends_on = [ 35 "aws_alb.main" 36 ] 37 } 38 39 resource "aws_alb_listener" "https" { 40 count = "${var.https ? 1 : 0}" 41 load_balancer_arn = "${aws_alb.main.id}" 42 port = "443" 43 protocol = "HTTPS" 44 ssl_policy = "${var.app_ssl_policy}" 45 certificate_arn = "${var.app_certificate_arn}" 46 47 default_action { 48 target_group_arn = "${aws_alb_target_group.main.id}" 49 type = "forward" 50 } 51 } 52 53 resource "aws_alb_listener" "http" { 54 count = "${var.https ? 0 : 1}" 55 load_balancer_arn = "${aws_alb.main.id}" 56 port = "80" 57 protocol = "HTTP" 58 59 default_action { 60 target_group_arn = "${aws_alb_target_group.main.id}" 61 type = "forward" 62 } 63 }