ListenerRule class

Resource for managing an AWS VPC Lattice Listener Rule.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.vpclattice.ListenerRule("example", {
    match: {
        httpMatch: {
            pathMatch: {
                match: {
                    prefix: "/example-path",
                },
                caseSensitive: true,
            },
            headerMatches: [{
                match: {
                    exact: "example-contains",
                },
                name: "example-header",
                caseSensitive: false,
            }],
        },
    },
    action: {
        forward: {
            targetGroups: [
                {
                    targetGroupIdentifier: exampleAwsVpclatticeTargetGroup.id,
                    weight: 1,
                },
                {
                    targetGroupIdentifier: example2.id,
                    weight: 2,
                },
            ],
        },
    },
    name: "example",
    listenerIdentifier: exampleAwsVpclatticeListener.listenerId,
    serviceIdentifier: exampleAwsVpclatticeService.id,
    priority: 20,
});
import pulumi
import pulumi_aws as aws

example = aws.vpclattice.ListenerRule("example",
    match={
        "http_match": {
            "path_match": {
                "match": {
                    "prefix": "/example-path",
                },
                "case_sensitive": True,
            },
            "header_matches": [{
                "match": {
                    "exact": "example-contains",
                },
                "name": "example-header",
                "case_sensitive": False,
            }],
        },
    },
    action={
        "forward": {
            "target_groups": [
                {
                    "target_group_identifier": example_aws_vpclattice_target_group["id"],
                    "weight": 1,
                },
                {
                    "target_group_identifier": example2["id"],
                    "weight": 2,
                },
            ],
        },
    },
    name="example",
    listener_identifier=example_aws_vpclattice_listener["listenerId"],
    service_identifier=example_aws_vpclattice_service["id"],
    priority=20)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.VpcLattice.ListenerRule("example", new()
    {
        Match = new Aws.VpcLattice.Inputs.ListenerRuleMatchArgs
        {
            HttpMatch = new Aws.VpcLattice.Inputs.ListenerRuleMatchHttpMatchArgs
            {
                PathMatch = new Aws.VpcLattice.Inputs.ListenerRuleMatchHttpMatchPathMatchArgs
                {
                    Match = new Aws.VpcLattice.Inputs.ListenerRuleMatchHttpMatchPathMatchMatchArgs
                    {
                        Prefix = "/example-path",
                    },
                    CaseSensitive = true,
                },
                HeaderMatches = new[]
                {
                    new Aws.VpcLattice.Inputs.ListenerRuleMatchHttpMatchHeaderMatchArgs
                    {
                        Match = new Aws.VpcLattice.Inputs.ListenerRuleMatchHttpMatchHeaderMatchMatchArgs
                        {
                            Exact = "example-contains",
                        },
                        Name = "example-header",
                        CaseSensitive = false,
                    },
                },
            },
        },
        Action = new Aws.VpcLattice.Inputs.ListenerRuleActionArgs
        {
            Forward = new Aws.VpcLattice.Inputs.ListenerRuleActionForwardArgs
            {
                TargetGroups = new[]
                {
                    new Aws.VpcLattice.Inputs.ListenerRuleActionForwardTargetGroupArgs
                    {
                        TargetGroupIdentifier = exampleAwsVpclatticeTargetGroup.Id,
                        Weight = 1,
                    },
                    new Aws.VpcLattice.Inputs.ListenerRuleActionForwardTargetGroupArgs
                    {
                        TargetGroupIdentifier = example2.Id,
                        Weight = 2,
                    },
                },
            },
        },
        Name = "example",
        ListenerIdentifier = exampleAwsVpclatticeListener.ListenerId,
        ServiceIdentifier = exampleAwsVpclatticeService.Id,
        Priority = 20,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/vpclattice"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := vpclattice.NewListenerRule(ctx, "example", &vpclattice.ListenerRuleArgs{
			Match: &vpclattice.ListenerRuleMatchArgs{
				HttpMatch: &vpclattice.ListenerRuleMatchHttpMatchArgs{
					PathMatch: &vpclattice.ListenerRuleMatchHttpMatchPathMatchArgs{
						Match: &vpclattice.ListenerRuleMatchHttpMatchPathMatchMatchArgs{
							Prefix: pulumi.String("/example-path"),
						},
						CaseSensitive: pulumi.Bool(true),
					},
					HeaderMatches: vpclattice.ListenerRuleMatchHttpMatchHeaderMatchArray{
						&vpclattice.ListenerRuleMatchHttpMatchHeaderMatchArgs{
							Match: &vpclattice.ListenerRuleMatchHttpMatchHeaderMatchMatchArgs{
								Exact: pulumi.String("example-contains"),
							},
							Name:          pulumi.String("example-header"),
							CaseSensitive: pulumi.Bool(false),
						},
					},
				},
			},
			Action: &vpclattice.ListenerRuleActionArgs{
				Forward: &vpclattice.ListenerRuleActionForwardArgs{
					TargetGroups: vpclattice.ListenerRuleActionForwardTargetGroupArray{
						&vpclattice.ListenerRuleActionForwardTargetGroupArgs{
							TargetGroupIdentifier: pulumi.Any(exampleAwsVpclatticeTargetGroup.Id),
							Weight:                pulumi.Int(1),
						},
						&vpclattice.ListenerRuleActionForwardTargetGroupArgs{
							TargetGroupIdentifier: pulumi.Any(example2.Id),
							Weight:                pulumi.Int(2),
						},
					},
				},
			},
			Name:               pulumi.String("example"),
			ListenerIdentifier: pulumi.Any(exampleAwsVpclatticeListener.ListenerId),
			ServiceIdentifier:  pulumi.Any(exampleAwsVpclatticeService.Id),
			Priority:           pulumi.Int(20),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_vpclattice_listenerrule" "example" {
  match = {
    http_match = {
      path_match = {
        match = {
          prefix = "/example-path"
        }
        case_sensitive = true
      }
      header_matches = [{
        "match" = {
          "exact" = "example-contains"
        }
        "name"          = "example-header"
        "caseSensitive" = false
      }]
    }
  }
  action = {
    forward = {
      target_groups = [{
        "targetGroupIdentifier" = exampleAwsVpclatticeTargetGroup.id
        "weight"                = 1
        }, {
        "targetGroupIdentifier" = example2.id
        "weight"                = 2
      }]
    }
  }
  name                = "example"
  listener_identifier = exampleAwsVpclatticeListener.listenerId
  service_identifier  = exampleAwsVpclatticeService.id
  priority            = 20
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.vpclattice.ListenerRule;
import com.pulumi.aws.vpclattice.ListenerRuleArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleMatchArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleMatchHttpMatchArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleMatchHttpMatchPathMatchArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleMatchHttpMatchPathMatchMatchArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleMatchHttpMatchHeaderMatchArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleMatchHttpMatchHeaderMatchMatchArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleActionArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleActionForwardArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleActionForwardTargetGroupArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new ListenerRule("example", ListenerRuleArgs.builder()
            .match(ListenerRuleMatchArgs.builder()
                .httpMatch(ListenerRuleMatchHttpMatchArgs.builder()
                    .pathMatch(ListenerRuleMatchHttpMatchPathMatchArgs.builder()
                        .match(ListenerRuleMatchHttpMatchPathMatchMatchArgs.builder()
                            .prefix("/example-path")
                            .build())
                        .caseSensitive(true)
                        .build())
                    .headerMatches(ListenerRuleMatchHttpMatchHeaderMatchArgs.builder()
                        .match(ListenerRuleMatchHttpMatchHeaderMatchMatchArgs.builder()
                            .exact("example-contains")
                            .build())
                        .name("example-header")
                        .caseSensitive(false)
                        .build())
                    .build())
                .build())
            .action(ListenerRuleActionArgs.builder()
                .forward(ListenerRuleActionForwardArgs.builder()
                    .targetGroups(
                        ListenerRuleActionForwardTargetGroupArgs.builder()
                            .targetGroupIdentifier(exampleAwsVpclatticeTargetGroup.id())
                            .weight(1)
                            .build(),
                        ListenerRuleActionForwardTargetGroupArgs.builder()
                            .targetGroupIdentifier(example2.id())
                            .weight(2)
                            .build())
                    .build())
                .build())
            .name("example")
            .listenerIdentifier(exampleAwsVpclatticeListener.listenerId())
            .serviceIdentifier(exampleAwsVpclatticeService.id())
            .priority(20)
            .build());

    }
}
resources:
  example:
    type: aws:vpclattice:ListenerRule
    properties:
      match:
        httpMatch:
          pathMatch:
            match:
              prefix: /example-path
            caseSensitive: true
          headerMatches:
            - match:
                exact: example-contains
              name: example-header
              caseSensitive: false
      action:
        forward:
          targetGroups:
            - targetGroupIdentifier: ${exampleAwsVpclatticeTargetGroup.id}
              weight: 1
            - targetGroupIdentifier: ${example2.id}
              weight: 2
      name: example
      listenerIdentifier: ${exampleAwsVpclatticeListener.listenerId}
      serviceIdentifier: ${exampleAwsVpclatticeService.id}
      priority: 20

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.vpclattice.ListenerRule("example", {
    match: {
        httpMatch: {
            pathMatch: {
                match: {
                    exact: "/example-path",
                },
                caseSensitive: false,
            },
        },
    },
    action: {
        fixedResponse: {
            statusCode: 404,
        },
    },
    name: "example",
    listenerIdentifier: exampleAwsVpclatticeListener.listenerId,
    serviceIdentifier: exampleAwsVpclatticeService.id,
    priority: 10,
});
import pulumi
import pulumi_aws as aws

example = aws.vpclattice.ListenerRule("example",
    match={
        "http_match": {
            "path_match": {
                "match": {
                    "exact": "/example-path",
                },
                "case_sensitive": False,
            },
        },
    },
    action={
        "fixed_response": {
            "status_code": 404,
        },
    },
    name="example",
    listener_identifier=example_aws_vpclattice_listener["listenerId"],
    service_identifier=example_aws_vpclattice_service["id"],
    priority=10)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.VpcLattice.ListenerRule("example", new()
    {
        Match = new Aws.VpcLattice.Inputs.ListenerRuleMatchArgs
        {
            HttpMatch = new Aws.VpcLattice.Inputs.ListenerRuleMatchHttpMatchArgs
            {
                PathMatch = new Aws.VpcLattice.Inputs.ListenerRuleMatchHttpMatchPathMatchArgs
                {
                    Match = new Aws.VpcLattice.Inputs.ListenerRuleMatchHttpMatchPathMatchMatchArgs
                    {
                        Exact = "/example-path",
                    },
                    CaseSensitive = false,
                },
            },
        },
        Action = new Aws.VpcLattice.Inputs.ListenerRuleActionArgs
        {
            FixedResponse = new Aws.VpcLattice.Inputs.ListenerRuleActionFixedResponseArgs
            {
                StatusCode = 404,
            },
        },
        Name = "example",
        ListenerIdentifier = exampleAwsVpclatticeListener.ListenerId,
        ServiceIdentifier = exampleAwsVpclatticeService.Id,
        Priority = 10,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/vpclattice"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := vpclattice.NewListenerRule(ctx, "example", &vpclattice.ListenerRuleArgs{
			Match: &vpclattice.ListenerRuleMatchArgs{
				HttpMatch: &vpclattice.ListenerRuleMatchHttpMatchArgs{
					PathMatch: &vpclattice.ListenerRuleMatchHttpMatchPathMatchArgs{
						Match: &vpclattice.ListenerRuleMatchHttpMatchPathMatchMatchArgs{
							Exact: pulumi.String("/example-path"),
						},
						CaseSensitive: pulumi.Bool(false),
					},
				},
			},
			Action: &vpclattice.ListenerRuleActionArgs{
				FixedResponse: &vpclattice.ListenerRuleActionFixedResponseArgs{
					StatusCode: pulumi.Int(404),
				},
			},
			Name:               pulumi.String("example"),
			ListenerIdentifier: pulumi.Any(exampleAwsVpclatticeListener.ListenerId),
			ServiceIdentifier:  pulumi.Any(exampleAwsVpclatticeService.Id),
			Priority:           pulumi.Int(10),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_vpclattice_listenerrule" "example" {
  match = {
    http_match = {
      path_match = {
        match = {
          exact = "/example-path"
        }
        case_sensitive = false
      }
    }
  }
  action = {
    fixed_response = {
      status_code = 404
    }
  }
  name                = "example"
  listener_identifier = exampleAwsVpclatticeListener.listenerId
  service_identifier  = exampleAwsVpclatticeService.id
  priority            = 10
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.vpclattice.ListenerRule;
import com.pulumi.aws.vpclattice.ListenerRuleArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleMatchArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleMatchHttpMatchArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleMatchHttpMatchPathMatchArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleMatchHttpMatchPathMatchMatchArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleActionArgs;
import com.pulumi.aws.vpclattice.inputs.ListenerRuleActionFixedResponseArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new ListenerRule("example", ListenerRuleArgs.builder()
            .match(ListenerRuleMatchArgs.builder()
                .httpMatch(ListenerRuleMatchHttpMatchArgs.builder()
                    .pathMatch(ListenerRuleMatchHttpMatchPathMatchArgs.builder()
                        .match(ListenerRuleMatchHttpMatchPathMatchMatchArgs.builder()
                            .exact("/example-path")
                            .build())
                        .caseSensitive(false)
                        .build())
                    .build())
                .build())
            .action(ListenerRuleActionArgs.builder()
                .fixedResponse(ListenerRuleActionFixedResponseArgs.builder()
                    .statusCode(404)
                    .build())
                .build())
            .name("example")
            .listenerIdentifier(exampleAwsVpclatticeListener.listenerId())
            .serviceIdentifier(exampleAwsVpclatticeService.id())
            .priority(10)
            .build());

    }
}
resources:
  example:
    type: aws:vpclattice:ListenerRule
    properties:
      match:
        httpMatch:
          pathMatch:
            match:
              exact: /example-path
            caseSensitive: false
      action:
        fixedResponse:
          statusCode: 404
      name: example
      listenerIdentifier: ${exampleAwsVpclatticeListener.listenerId}
      serviceIdentifier: ${exampleAwsVpclatticeService.id}
      priority: 10

Import

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

$ pulumi import aws:vpclattice/listenerRule:ListenerRule example service123/listener456/rule789

Constructors

ListenerRule(String name, {ListenerRuleArgs? args, CustomResourceOptions? options})
Creates a new ListenerRule. name The Pulumi resource name. args Arguments used to configure this ListenerRule. The set of arguments for ListenerRule. options Resource options controlling this resource's behavior.
ListenerRule.reference(String urn)
Creates a typed reference to an existing ListenerRule resource.

Properties

action ↔ Output<ListenerRuleAction>
Action for the listener rule. See action Block for details.
latefinal
arn ↔ Output<String>
ARN for the listener rule.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
listenerIdentifier ↔ Output<String>
ID or ARN of the listener.
latefinal
match ↔ Output<ListenerRuleMatch>
Rule match. See match Block for details.
latefinal
name ↔ Output<String>
Name of the rule. Must be unique within the listener. Valid characters are a-z, 0-9, and hyphens (-). You can't use a hyphen as the first or last character, or immediately after another hyphen.
latefinal
priority ↔ Output<int>
Priority assigned to the rule. Each rule for a specific listener must have a unique priority. The lower the priority number the higher the priority.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
ruleId ↔ Output<String>
Unique identifier for the listener rule.
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
serviceIdentifier ↔ Output<String>
ID or ARN of the service.
latefinal
tags ↔ Output<Map<String, String>?>
Key-value mapping of resource tags. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
latefinal
tagsAll ↔ Output<Map<String, String>>
Map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {ListenerRuleState? state, CustomResourceOptions? options}) → ListenerRule
Gets an existing ListenerRule resource's state with the given name and id.