resource "aws_lb_target_group" "toclerbe" { name = "${var.app_name}-${substr(uuid(), 0, 2)}" port = 80 protocol = "HTTP" target_type = "instance" vpc_id = data.terraform_remote_state.jdbsoft.outputs.aws_vpc_jdbsoft.id health_check { enabled = true matcher = "200" path = "/version" } lifecycle { create_before_destroy = true ignore_changes = [name] } tags = { Name = var.app_name } } resource "aws_lb_listener_rule" "toclerbe" { listener_arn = data.terraform_remote_state.jdbsoft.outputs.aws_lb_listener_https.arn action { type = "forward" target_group_arn = aws_lb_target_group.toclerbe.arn } condition { host_header { values = [ var.app_domain ] } } tags = { Name = "${var.app_domain} HTTPS" } } resource "aws_lb_listener_certificate" "toclerbe" { listener_arn = data.terraform_remote_state.jdbsoft.outputs.aws_lb_listener_https.arn certificate_arn = data.terraform_remote_state.jdbsoft.outputs.aws_acm_certificate_clerbe_arn }