Route

# kong.Route

The route resource maps directly onto the json for the route endpoint in Kong. For more information on the parameters see the Kong Route create documentation.

To create a tcp/tls route you set sources and destinations by repeating the corresponding element (source or destination) for each source or destination you want.

Example Usage

using Pulumi;
using Kong = Pulumi.Kong;

class MyStack : Stack
{
    public MyStack()
    {
        var route = new Kong.Route("route", new Kong.RouteArgs
        {
            Protocols = 
            {
                "http",
                "https",
            },
            Methods = 
            {
                "GET",
                "POST",
            },
            Hosts = 
            {
                "example2.com",
            },
            Paths = 
            {
                "/test",
            },
            StripPath = false,
            PreserveHost = true,
            RegexPriority = 1,
            ServiceId = kong_service.Service.Id,
            Headers = 
            {
                new Kong.Inputs.RouteHeaderArgs
                {
                    Name = "x-test-1",
                    Values = 
                    {
                        "a",
                        "b",
                    },
                },
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-kong/sdk/v4/go/kong"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := kong.NewRoute(ctx, "route", &kong.RouteArgs{
			Protocols: pulumi.StringArray{
				pulumi.String("http"),
				pulumi.String("https"),
			},
			Methods: pulumi.StringArray{
				pulumi.String("GET"),
				pulumi.String("POST"),
			},
			Hosts: pulumi.StringArray{
				pulumi.String("example2.com"),
			},
			Paths: pulumi.StringArray{
				pulumi.String("/test"),
			},
			StripPath:     pulumi.Bool(false),
			PreserveHost:  pulumi.Bool(true),
			RegexPriority: pulumi.Int(1),
			ServiceId:     pulumi.Any(kong_service.Service.Id),
			Headers: RouteHeaderArray{
				&RouteHeaderArgs{
					Name: pulumi.String("x-test-1"),
					Values: pulumi.StringArray{
						pulumi.String("a"),
						pulumi.String("b"),
					},
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_kong as kong

route = kong.Route("route",
    protocols=[
        "http",
        "https",
    ],
    methods=[
        "GET",
        "POST",
    ],
    hosts=["example2.com"],
    paths=["/test"],
    strip_path=False,
    preserve_host=True,
    regex_priority=1,
    service_id=kong_service["service"]["id"],
    headers=[kong.RouteHeaderArgs(
        name="x-test-1",
        values=[
            "a",
            "b",
        ],
    )])
import * as pulumi from "@pulumi/pulumi";
import * as kong from "@pulumi/kong";

const route = new kong.Route("route", {
    protocols: [
        "http",
        "https",
    ],
    methods: [
        "GET",
        "POST",
    ],
    hosts: ["example2.com"],
    paths: ["/test"],
    stripPath: false,
    preserveHost: true,
    regexPriority: 1,
    serviceId: kong_service.service.id,
    headers: [{
        name: "x-test-1",
        values: [
            "a",
            "b",
        ],
    }],
});

Create a Route Resource

new Route(name: string, args: RouteArgs, opts?: CustomResourceOptions);
@overload
def Route(resource_name: str,
          opts: Optional[ResourceOptions] = None,
          destinations: Optional[Sequence[RouteDestinationArgs]] = None,
          headers: Optional[Sequence[RouteHeaderArgs]] = None,
          hosts: Optional[Sequence[str]] = None,
          https_redirect_status_code: Optional[int] = None,
          methods: Optional[Sequence[str]] = None,
          name: Optional[str] = None,
          path_handling: Optional[str] = None,
          paths: Optional[Sequence[str]] = None,
          preserve_host: Optional[bool] = None,
          protocols: Optional[Sequence[str]] = None,
          regex_priority: Optional[int] = None,
          request_buffering: Optional[bool] = None,
          response_buffering: Optional[bool] = None,
          service_id: Optional[str] = None,
          snis: Optional[Sequence[str]] = None,
          sources: Optional[Sequence[RouteSourceArgs]] = None,
          strip_path: Optional[bool] = None,
          tags: Optional[Sequence[str]] = None)
@overload
def Route(resource_name: str,
          args: RouteArgs,
          opts: Optional[ResourceOptions] = None)
func NewRoute(ctx *Context, name string, args RouteArgs, opts ...ResourceOption) (*Route, error)
public Route(string name, RouteArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args RouteArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args RouteArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args RouteArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args RouteArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Route Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The Route resource accepts the following input properties:

Protocols List<string>
The list of protocols to use
ServiceId string
Service ID to map to
Destinations List<RouteDestinationArgs>
A list of destination ip and port
Headers List<RouteHeaderArgs>
One or more blocks of name to set name of header and values which is a list of string for the header values to match on. See above example of how to set. These headers will cause this Route to match if present in the request. The Host header cannot be used with this attribute: hosts should be specified using the hosts attribute.
Hosts List<string>
A list of domain names that match this Route
HttpsRedirectStatusCode int
The status code Kong responds with when all properties of a Route match except the protocol i.e. if the protocol of the request is HTTP instead of HTTPS. Location header is injected by Kong if the field is set to 301, 302, 307 or 308. Accepted values are: 426, 301, 302, 307, 308. Default: 426.
Methods List<string>
A list of HTTP methods that match this Route
Name string
The name of the route
PathHandling string
Controls how the Service path, Route path and requested path are combined when sending a request to the upstream.
Paths List<string>
A list of paths that match this Route
PreserveHost bool
When matching a Route via one of the hosts domain names, use the request Host header in the upstream request headers. If set to false, the upstream Host header will be that of the Service’s host.
RegexPriority int
A number used to choose which route resolves a given request when several routes match it using regexes simultaneously.
RequestBuffering bool
Whether to enable request body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that receive data with chunked transfer encoding. Default: true.
ResponseBuffering bool
Whether to enable response body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that send data with chunked transfer encoding. Default: true.
Snis List<string>
A list of SNIs that match this Route when using stream routing.
Sources List<RouteSourceArgs>
A list of source ip and port
StripPath bool
When matching a Route via one of the paths, strip the matching prefix from the upstream request URL. Default: true.
Tags List<string>
A list of strings associated with the Route for grouping and filtering.
Protocols []string
The list of protocols to use
ServiceId string
Service ID to map to
Destinations []RouteDestinationArgs
A list of destination ip and port
Headers []RouteHeaderArgs
One or more blocks of name to set name of header and values which is a list of string for the header values to match on. See above example of how to set. These headers will cause this Route to match if present in the request. The Host header cannot be used with this attribute: hosts should be specified using the hosts attribute.
Hosts []string
A list of domain names that match this Route
HttpsRedirectStatusCode int
The status code Kong responds with when all properties of a Route match except the protocol i.e. if the protocol of the request is HTTP instead of HTTPS. Location header is injected by Kong if the field is set to 301, 302, 307 or 308. Accepted values are: 426, 301, 302, 307, 308. Default: 426.
Methods []string
A list of HTTP methods that match this Route
Name string
The name of the route
PathHandling string
Controls how the Service path, Route path and requested path are combined when sending a request to the upstream.
Paths []string
A list of paths that match this Route
PreserveHost bool
When matching a Route via one of the hosts domain names, use the request Host header in the upstream request headers. If set to false, the upstream Host header will be that of the Service’s host.
RegexPriority int
A number used to choose which route resolves a given request when several routes match it using regexes simultaneously.
RequestBuffering bool
Whether to enable request body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that receive data with chunked transfer encoding. Default: true.
ResponseBuffering bool
Whether to enable response body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that send data with chunked transfer encoding. Default: true.
Snis []string
A list of SNIs that match this Route when using stream routing.
Sources []RouteSourceArgs
A list of source ip and port
StripPath bool
When matching a Route via one of the paths, strip the matching prefix from the upstream request URL. Default: true.
Tags []string
A list of strings associated with the Route for grouping and filtering.
protocols string[]
The list of protocols to use
serviceId string
Service ID to map to
destinations RouteDestinationArgs[]
A list of destination ip and port
headers RouteHeaderArgs[]
One or more blocks of name to set name of header and values which is a list of string for the header values to match on. See above example of how to set. These headers will cause this Route to match if present in the request. The Host header cannot be used with this attribute: hosts should be specified using the hosts attribute.
hosts string[]
A list of domain names that match this Route
httpsRedirectStatusCode number
The status code Kong responds with when all properties of a Route match except the protocol i.e. if the protocol of the request is HTTP instead of HTTPS. Location header is injected by Kong if the field is set to 301, 302, 307 or 308. Accepted values are: 426, 301, 302, 307, 308. Default: 426.
methods string[]
A list of HTTP methods that match this Route
name string
The name of the route
pathHandling string
Controls how the Service path, Route path and requested path are combined when sending a request to the upstream.
paths string[]
A list of paths that match this Route
preserveHost boolean
When matching a Route via one of the hosts domain names, use the request Host header in the upstream request headers. If set to false, the upstream Host header will be that of the Service’s host.
regexPriority number
A number used to choose which route resolves a given request when several routes match it using regexes simultaneously.
requestBuffering boolean
Whether to enable request body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that receive data with chunked transfer encoding. Default: true.
responseBuffering boolean
Whether to enable response body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that send data with chunked transfer encoding. Default: true.
snis string[]
A list of SNIs that match this Route when using stream routing.
sources RouteSourceArgs[]
A list of source ip and port
stripPath boolean
When matching a Route via one of the paths, strip the matching prefix from the upstream request URL. Default: true.
tags string[]
A list of strings associated with the Route for grouping and filtering.
protocols Sequence[str]
The list of protocols to use
service_id str
Service ID to map to
destinations Sequence[RouteDestinationArgs]
A list of destination ip and port
headers Sequence[RouteHeaderArgs]
One or more blocks of name to set name of header and values which is a list of string for the header values to match on. See above example of how to set. These headers will cause this Route to match if present in the request. The Host header cannot be used with this attribute: hosts should be specified using the hosts attribute.
hosts Sequence[str]
A list of domain names that match this Route
https_redirect_status_code int
The status code Kong responds with when all properties of a Route match except the protocol i.e. if the protocol of the request is HTTP instead of HTTPS. Location header is injected by Kong if the field is set to 301, 302, 307 or 308. Accepted values are: 426, 301, 302, 307, 308. Default: 426.
methods Sequence[str]
A list of HTTP methods that match this Route
name str
The name of the route
path_handling str
Controls how the Service path, Route path and requested path are combined when sending a request to the upstream.
paths Sequence[str]
A list of paths that match this Route
preserve_host bool
When matching a Route via one of the hosts domain names, use the request Host header in the upstream request headers. If set to false, the upstream Host header will be that of the Service’s host.
regex_priority int
A number used to choose which route resolves a given request when several routes match it using regexes simultaneously.
request_buffering bool
Whether to enable request body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that receive data with chunked transfer encoding. Default: true.
response_buffering bool
Whether to enable response body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that send data with chunked transfer encoding. Default: true.
snis Sequence[str]
A list of SNIs that match this Route when using stream routing.
sources Sequence[RouteSourceArgs]
A list of source ip and port
strip_path bool
When matching a Route via one of the paths, strip the matching prefix from the upstream request URL. Default: true.
tags Sequence[str]
A list of strings associated with the Route for grouping and filtering.

Outputs

All input properties are implicitly available as output properties. Additionally, the Route resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

Look up an Existing Route Resource

Get an existing Route resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: RouteState, opts?: CustomResourceOptions): Route
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        destinations: Optional[Sequence[RouteDestinationArgs]] = None,
        headers: Optional[Sequence[RouteHeaderArgs]] = None,
        hosts: Optional[Sequence[str]] = None,
        https_redirect_status_code: Optional[int] = None,
        methods: Optional[Sequence[str]] = None,
        name: Optional[str] = None,
        path_handling: Optional[str] = None,
        paths: Optional[Sequence[str]] = None,
        preserve_host: Optional[bool] = None,
        protocols: Optional[Sequence[str]] = None,
        regex_priority: Optional[int] = None,
        request_buffering: Optional[bool] = None,
        response_buffering: Optional[bool] = None,
        service_id: Optional[str] = None,
        snis: Optional[Sequence[str]] = None,
        sources: Optional[Sequence[RouteSourceArgs]] = None,
        strip_path: Optional[bool] = None,
        tags: Optional[Sequence[str]] = None) -> Route
func GetRoute(ctx *Context, name string, id IDInput, state *RouteState, opts ...ResourceOption) (*Route, error)
public static Route Get(string name, Input<string> id, RouteState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Destinations List<RouteDestinationArgs>
A list of destination ip and port
Headers List<RouteHeaderArgs>
One or more blocks of name to set name of header and values which is a list of string for the header values to match on. See above example of how to set. These headers will cause this Route to match if present in the request. The Host header cannot be used with this attribute: hosts should be specified using the hosts attribute.
Hosts List<string>
A list of domain names that match this Route
HttpsRedirectStatusCode int
The status code Kong responds with when all properties of a Route match except the protocol i.e. if the protocol of the request is HTTP instead of HTTPS. Location header is injected by Kong if the field is set to 301, 302, 307 or 308. Accepted values are: 426, 301, 302, 307, 308. Default: 426.
Methods List<string>
A list of HTTP methods that match this Route
Name string
The name of the route
PathHandling string
Controls how the Service path, Route path and requested path are combined when sending a request to the upstream.
Paths List<string>
A list of paths that match this Route
PreserveHost bool
When matching a Route via one of the hosts domain names, use the request Host header in the upstream request headers. If set to false, the upstream Host header will be that of the Service’s host.
Protocols List<string>
The list of protocols to use
RegexPriority int
A number used to choose which route resolves a given request when several routes match it using regexes simultaneously.
RequestBuffering bool
Whether to enable request body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that receive data with chunked transfer encoding. Default: true.
ResponseBuffering bool
Whether to enable response body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that send data with chunked transfer encoding. Default: true.
ServiceId string
Service ID to map to
Snis List<string>
A list of SNIs that match this Route when using stream routing.
Sources List<RouteSourceArgs>
A list of source ip and port
StripPath bool
When matching a Route via one of the paths, strip the matching prefix from the upstream request URL. Default: true.
Tags List<string>
A list of strings associated with the Route for grouping and filtering.
Destinations []RouteDestinationArgs
A list of destination ip and port
Headers []RouteHeaderArgs
One or more blocks of name to set name of header and values which is a list of string for the header values to match on. See above example of how to set. These headers will cause this Route to match if present in the request. The Host header cannot be used with this attribute: hosts should be specified using the hosts attribute.
Hosts []string
A list of domain names that match this Route
HttpsRedirectStatusCode int
The status code Kong responds with when all properties of a Route match except the protocol i.e. if the protocol of the request is HTTP instead of HTTPS. Location header is injected by Kong if the field is set to 301, 302, 307 or 308. Accepted values are: 426, 301, 302, 307, 308. Default: 426.
Methods []string
A list of HTTP methods that match this Route
Name string
The name of the route
PathHandling string
Controls how the Service path, Route path and requested path are combined when sending a request to the upstream.
Paths []string
A list of paths that match this Route
PreserveHost bool
When matching a Route via one of the hosts domain names, use the request Host header in the upstream request headers. If set to false, the upstream Host header will be that of the Service’s host.
Protocols []string
The list of protocols to use
RegexPriority int
A number used to choose which route resolves a given request when several routes match it using regexes simultaneously.
RequestBuffering bool
Whether to enable request body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that receive data with chunked transfer encoding. Default: true.
ResponseBuffering bool
Whether to enable response body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that send data with chunked transfer encoding. Default: true.
ServiceId string
Service ID to map to
Snis []string
A list of SNIs that match this Route when using stream routing.
Sources []RouteSourceArgs
A list of source ip and port
StripPath bool
When matching a Route via one of the paths, strip the matching prefix from the upstream request URL. Default: true.
Tags []string
A list of strings associated with the Route for grouping and filtering.
destinations RouteDestinationArgs[]
A list of destination ip and port
headers RouteHeaderArgs[]
One or more blocks of name to set name of header and values which is a list of string for the header values to match on. See above example of how to set. These headers will cause this Route to match if present in the request. The Host header cannot be used with this attribute: hosts should be specified using the hosts attribute.
hosts string[]
A list of domain names that match this Route
httpsRedirectStatusCode number
The status code Kong responds with when all properties of a Route match except the protocol i.e. if the protocol of the request is HTTP instead of HTTPS. Location header is injected by Kong if the field is set to 301, 302, 307 or 308. Accepted values are: 426, 301, 302, 307, 308. Default: 426.
methods string[]
A list of HTTP methods that match this Route
name string
The name of the route
pathHandling string
Controls how the Service path, Route path and requested path are combined when sending a request to the upstream.
paths string[]
A list of paths that match this Route
preserveHost boolean
When matching a Route via one of the hosts domain names, use the request Host header in the upstream request headers. If set to false, the upstream Host header will be that of the Service’s host.
protocols string[]
The list of protocols to use
regexPriority number
A number used to choose which route resolves a given request when several routes match it using regexes simultaneously.
requestBuffering boolean
Whether to enable request body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that receive data with chunked transfer encoding. Default: true.
responseBuffering boolean
Whether to enable response body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that send data with chunked transfer encoding. Default: true.
serviceId string
Service ID to map to
snis string[]
A list of SNIs that match this Route when using stream routing.
sources RouteSourceArgs[]
A list of source ip and port
stripPath boolean
When matching a Route via one of the paths, strip the matching prefix from the upstream request URL. Default: true.
tags string[]
A list of strings associated with the Route for grouping and filtering.
destinations Sequence[RouteDestinationArgs]
A list of destination ip and port
headers Sequence[RouteHeaderArgs]
One or more blocks of name to set name of header and values which is a list of string for the header values to match on. See above example of how to set. These headers will cause this Route to match if present in the request. The Host header cannot be used with this attribute: hosts should be specified using the hosts attribute.
hosts Sequence[str]
A list of domain names that match this Route
https_redirect_status_code int
The status code Kong responds with when all properties of a Route match except the protocol i.e. if the protocol of the request is HTTP instead of HTTPS. Location header is injected by Kong if the field is set to 301, 302, 307 or 308. Accepted values are: 426, 301, 302, 307, 308. Default: 426.
methods Sequence[str]
A list of HTTP methods that match this Route
name str
The name of the route
path_handling str
Controls how the Service path, Route path and requested path are combined when sending a request to the upstream.
paths Sequence[str]
A list of paths that match this Route
preserve_host bool
When matching a Route via one of the hosts domain names, use the request Host header in the upstream request headers. If set to false, the upstream Host header will be that of the Service’s host.
protocols Sequence[str]
The list of protocols to use
regex_priority int
A number used to choose which route resolves a given request when several routes match it using regexes simultaneously.
request_buffering bool
Whether to enable request body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that receive data with chunked transfer encoding. Default: true.
response_buffering bool
Whether to enable response body buffering or not. With HTTP 1.1, it may make sense to turn this off on services that send data with chunked transfer encoding. Default: true.
service_id str
Service ID to map to
snis Sequence[str]
A list of SNIs that match this Route when using stream routing.
sources Sequence[RouteSourceArgs]
A list of source ip and port
strip_path bool
When matching a Route via one of the paths, strip the matching prefix from the upstream request URL. Default: true.
tags Sequence[str]
A list of strings associated with the Route for grouping and filtering.

Supporting Types

RouteDestination

Ip string
Port int
Ip string
Port int
ip string
port number
ip str
port int

RouteHeader

Name string
The name of the route
Values List<string>
Name string
The name of the route
Values []string
name string
The name of the route
values string[]
name str
The name of the route
values Sequence[str]

RouteSource

Ip string
Port int
Ip string
Port int
ip string
port number
ip str
port int

Import

To import a route

 $ pulumi import kong:index/route:Route <route_identifier> <route_id>

Package Details

Repository
https://github.com/pulumi/pulumi-kong
License
Apache-2.0
Notes
This Pulumi package is based on the kong Terraform Provider.