Resource: aws_vpclattice_listener_rule

Terraform resource for managing an AWS VPC Lattice Listener Rule.

Example Usage

resource "aws_vpclattice_listener_rule" "test" {
  name                = "example"
  listener_identifier = aws_vpclattice_listener.example.listener_id
  service_identifier  = aws_vpclattice_service.example.id
  priority            = 20
  match {
    http_match {

      header_matches {
        name           = "example-header"
        case_sensitive = false

        match {
          exact = "example-contains"
        }
      }

      path_match {
        case_sensitive = true
        match {
          prefix = "/example-path"
        }
      }
    }
  }
  action {
    forward {
      target_groups {
        target_group_identifier = aws_vpclattice_target_group.example.id
        weight                  = 1
      }
      target_groups {
        target_group_identifier = aws_vpclattice_target_group.example2.id
        weight                  = 2
      }
    }

  }
}

Basic Usage

resource "aws_vpclattice_listener_rule" "test" {
  name                = "example"
  listener_identifier = aws_vpclattice_listener.example.listener_id
  service_identifier  = aws_vpclattice_service.example.id
  priority            = 10
  match {
    http_match {
      path_match {
        case_sensitive = false
        match {
          exact = "/example-path"
        }
      }
    }
  }
  action {
    fixed_response {
      status_code = 404
    }
  }
}

Argument Reference

The following arguments are required:

The following arguments are optional:

action (action) supports the following:

fixed response (fixed_response) supports the following:

forward (forward) supports the following:

The default value is 1 with maximum number of 2. If only one target group is provided, there is no need to set the weight; 100% of traffic will go to that target group.

action (match) supports the following:

http match (http_match) supports the following:

header matches (header_matches) supports the following:

header matches match (match) supports the following:

path match (path_match) supports the following:

path match match (match) supports the following:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Timeouts

Configuration options:

Import

In Terraform v1.5.0 and later, use an import block to import VPC Lattice Listener Rule using the id. For example:

import {
  to = aws_vpclattice_listener_rule.example
  id = "service123/listener456/rule789"
}

Using terraform import, import VPC Lattice Listener Rule using the id. For example:

% terraform import aws_vpclattice_listener_rule.example service123/listener456/rule789