UNPKG

@pulumi/kong

Version:

A Pulumi package for creating and managing Kong resources.

164 lines 6.99 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.Route = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * ## # 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](https://docs.konghq.com/gateway-oss/2.5.x/admin-api/#route-object). * * 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 * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as kong from "@pulumi/kong"; * * const route = new kong.Route("route", { * name: "MyRoute", * protocols: [ * "http", * "https", * ], * methods: [ * "GET", * "POST", * ], * hosts: ["example2.com"], * paths: ["/test"], * stripPath: false, * preserveHost: true, * regexPriority: 1, * serviceId: service.id, * headers: [{ * name: "x-test-1", * values: [ * "a", * "b", * ], * }], * }); * ``` * * 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, for example: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as kong from "@pulumi/kong"; * * const route = new kong.Route("route", { * protocols: ["tcp"], * stripPath: true, * preserveHost: false, * sources: [ * { * ip: "192.168.1.1", * port: 80, * }, * { * ip: "192.168.1.2", * }, * ], * destinations: [{ * ip: "172.10.1.1", * port: 81, * }], * snis: ["foo.com"], * serviceId: service.id, * }); * ``` * * ## Import * * To import a route: * * ```sh * $ pulumi import kong:index/route:Route <route_identifier> <route_id> * ``` */ class Route extends pulumi.CustomResource { /** * Get an existing Route resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new Route(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of Route. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === Route.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["destinations"] = state ? state.destinations : undefined; resourceInputs["headers"] = state ? state.headers : undefined; resourceInputs["hosts"] = state ? state.hosts : undefined; resourceInputs["httpsRedirectStatusCode"] = state ? state.httpsRedirectStatusCode : undefined; resourceInputs["methods"] = state ? state.methods : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["pathHandling"] = state ? state.pathHandling : undefined; resourceInputs["paths"] = state ? state.paths : undefined; resourceInputs["preserveHost"] = state ? state.preserveHost : undefined; resourceInputs["protocols"] = state ? state.protocols : undefined; resourceInputs["regexPriority"] = state ? state.regexPriority : undefined; resourceInputs["requestBuffering"] = state ? state.requestBuffering : undefined; resourceInputs["responseBuffering"] = state ? state.responseBuffering : undefined; resourceInputs["serviceId"] = state ? state.serviceId : undefined; resourceInputs["snis"] = state ? state.snis : undefined; resourceInputs["sources"] = state ? state.sources : undefined; resourceInputs["stripPath"] = state ? state.stripPath : undefined; resourceInputs["tags"] = state ? state.tags : undefined; } else { const args = argsOrState; if ((!args || args.protocols === undefined) && !opts.urn) { throw new Error("Missing required property 'protocols'"); } if ((!args || args.serviceId === undefined) && !opts.urn) { throw new Error("Missing required property 'serviceId'"); } resourceInputs["destinations"] = args ? args.destinations : undefined; resourceInputs["headers"] = args ? args.headers : undefined; resourceInputs["hosts"] = args ? args.hosts : undefined; resourceInputs["httpsRedirectStatusCode"] = args ? args.httpsRedirectStatusCode : undefined; resourceInputs["methods"] = args ? args.methods : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["pathHandling"] = args ? args.pathHandling : undefined; resourceInputs["paths"] = args ? args.paths : undefined; resourceInputs["preserveHost"] = args ? args.preserveHost : undefined; resourceInputs["protocols"] = args ? args.protocols : undefined; resourceInputs["regexPriority"] = args ? args.regexPriority : undefined; resourceInputs["requestBuffering"] = args ? args.requestBuffering : undefined; resourceInputs["responseBuffering"] = args ? args.responseBuffering : undefined; resourceInputs["serviceId"] = args ? args.serviceId : undefined; resourceInputs["snis"] = args ? args.snis : undefined; resourceInputs["sources"] = args ? args.sources : undefined; resourceInputs["stripPath"] = args ? args.stripPath : undefined; resourceInputs["tags"] = args ? args.tags : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Route.__pulumiType, name, resourceInputs, opts); } } exports.Route = Route; /** @internal */ Route.__pulumiType = 'kong:index/route:Route'; //# sourceMappingURL=route.js.map