How can I add domain names to my terraform configuration

505 views Asked by At

I want to Add domain to listener rule in addition to paths. What arguments should I use for the same.

resource "aws_alb_listener_rule" "service" {
  listener_arn = var.alb_listener_arn
  action {
    type             = "forward"
    target_group_arn = aws_alb_target_group.service.arn
  }
  condition {
    path_pattern {
      values = ["/login", "/logout"]
    }
  }

Thank you.

2

There are 2 answers

0
Tanu On BEST ANSWER

Thanks. This worked.

condition {
    path_pattern {
      values = ["/login", "/logout"]
    }
}
condition {
    host_header {
      values = ["my-service.*.terraform.io"]
    }
  }

0
Marcin On

The domain name is specified using host_header:

Contains a single values item which is a list of host header patterns to match.

An example usage from the docs:

  condition {
    host_header {
      values = ["my-service.*.terraform.io"]
    }
  }