Created
August 3, 2018 16:47
-
-
Save gambtho/6a392b1fe13e440d3ab6f31443fd6f6c to your computer and use it in GitHub Desktop.
terraform for ecs lb using cert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_lb" "app" { | |
name = "${var.api_name}-${var.environment}" | |
internal = false | |
security_groups = ["${var.lb_security_groups}"] | |
subnets = ["${var.public_subnets}"] | |
idle_timeout = "${var.idle_timeout}" | |
tags = "${var.tags}" | |
} | |
resource "aws_alb_target_group" "http" { | |
depends_on = ["aws_lb.app"] | |
name = "${var.api_name}-${var.environment}" | |
tags = "${var.tags}" | |
port = "8081" | |
protocol = "HTTP" | |
vpc_id = "${var.vpc_id}" | |
target_type = "ip" | |
health_check { | |
path = "/ping" | |
matcher = "200" | |
} | |
} | |
resource "aws_alb_listener" "http" { | |
load_balancer_arn = "${aws_lb.app.arn}" | |
port = "443" | |
protocol = "HTTPS" | |
ssl_policy = "ELBSecurityPolicy-2016-08" | |
certificate_arn = "${var.api_cert_arn}" | |
default_action { | |
target_group_arn = "${aws_alb_target_group.http.arn}" | |
type = "forward" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment