Skip to content
main
Switch branches/tags
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

terraform-hashicorp-cts-alb_listener-nia

The Consul-Terraform-Sync (CTS) module creates a listener rule and target group for an Application Load Balancer. When the rule condition is met, traffic is forwarded to a Consul ingress gateway.

Authors

  • Rosemary Wang

Prerequisites

Usage

The module primarily uses Consul-Terraform-Sync user metadata to build the listener rule conditions to the Consul ingress gateway target group.

You can use this module in Consul-Terraform-Sync with a service configuration for the Consul ingress gateway, any of its services for routing, and a task definition.

service {
  name        = "ingress-gateway"
  datacenter  = "cloud"
  description = "all instances of the service ingress-gateway in datacenter cloud"
  cts_user_defined_meta = {}
}

service {
  name        = "my-application"
  datacenter  = "cloud"
  description = "all instances of the service my-application in datacenter cloud"
  cts_user_defined_meta = {
    host_header = "[\"test.hello-world.com\"]"
  }
}

task {
  name        = "ingress"
  description = "send traffic to ingress gateway for my-application"
  providers   = ["aws"]
  services    = ["my-application", "ingress-gateway"]
  source      = "aws-quickstart/alb_listener_rule/aws"
  version     = "0.1.0" # insert version
  variable_files = [] # define file with required variables
}

Exactly one of the following must be set per listener rule conditions:

  • Host header
  • HTTP request method
  • HTTP header
  • Path pattern
  • Query string
  • Source IP

The services behind the ingress gateway should include cts_user_defined_meta](https://www.consul.io/docs/nia/configuration#cts_user_defined_meta). The metadata fields use a map of strings. For example, in Consul-Terraform-Sync configuration, you can set the conditions for my-application service.

service {
  name        = "my-application"
  datacenter  = "cloud"
  description = "all instances of the service my-application in datacenter cloud"
  cts_user_defined_meta = {
    # You must set exactly one of the following:
    host_header = "[\"test.hello-world.com\"]"
    # path_pattern = "[\"/test\"]"
    # source_ip    = "[\"10.0.0.4/32\"]"
    # http_request_method = "[\"POST\"]"
    # http_header_name   = "X-Forwarded-For"
    # http_header_values = "[\"192.168.1.*\"]"
    # query_string = "key,value"
  }
}

Requirements

Name Version
Terraform 0.14 or later
AWS provider for Terraform 3.32 or later

Inputs

Name Description Type Default Required
listener_arn Listener ARN on Application Load Balancer for Consul ingress gateway listener rule. string n/a yes
listener_rule_priority Priority of listener rule, between 1 and 50000. number 1 no
services Consul services monitored by CTS.
map(
object({
id = string
name = string
kind = string
address = string
port = number
meta = map(string)
tags = list(string)
namespace = string
status = string

node = string
node_id = string
node_address = string
node_datacenter = string
node_tagged_addresses = map(string)
node_meta = map(string)

cts_user_defined_meta = map(string)
})
)
n/a yes
target_group_health_check Health check attributes for target group. CTS sets port based on ingress gateway service metadata. For additional parameters, see Resource: aws_lb_target_group.
object({
enabled = bool
interval = number
path = string
timeout = number
healthy_threshold = number
unhealthy_threshold = number
matcher = string
})
n/a yes
vpc_id VPC ID to attach a target group for Consul ingress gateway. string n/a yes

Outputs

Name Description
consul_ingress_listener_rule_arn Amazon Resource Number (ARN) of the listener rule for Consul ingress gateway.
consul_ingress_target_group_arn Target group ARN for Consul ingress gateway.

About

No description, website, or topics provided.

Resources

License

Packages

No packages published

Languages