@pulumi/kong
Version:
A Pulumi package for creating and managing Kong resources.
160 lines • 5.63 kB
JavaScript
;
// *** 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.Plugin = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* ## # kong.Plugin
*
* The plugin resource maps directly onto the json for the API endpoint in Kong. For more information on the parameters [see the Kong Api create documentation](https://docs.konghq.com/gateway-oss/2.5.x/admin-api/#plugin-object).
* The `configJson` is passed through to the plugin to configure it as is.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as kong from "@pulumi/kong";
*
* const rateLimit = new kong.Plugin("rate_limit", {
* name: "rate-limiting",
* configJson: `\x09{
* \x09\x09"second": 5,
* \x09\x09"hour" : 1000
* \x09}
* `,
* });
* ```
* To apply a plugin to a consumer use the `consumerId` property, for example:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as kong from "@pulumi/kong";
*
* const pluginConsumer = new kong.Consumer("plugin_consumer", {
* username: "PluginUser",
* customId: "567",
* });
* const rateLimit = new kong.Plugin("rate_limit", {
* name: "rate-limiting",
* consumerId: pluginConsumer.id,
* configJson: `\x09{
* \x09\x09"second": 5,
* \x09\x09"hour" : 1000
* \x09}
* `,
* });
* ```
*
* To apply a plugin to a service use the `serviceId` property, for example:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as kong from "@pulumi/kong";
*
* const service = new kong.Service("service", {
* name: "test",
* protocol: "http",
* host: "test.org",
* });
* const rateLimit = new kong.Plugin("rate_limit", {
* name: "rate-limiting",
* serviceId: service.id,
* configJson: `\x09{
* \x09\x09"second": 10,
* \x09\x09"hour" : 2000
* \x09}
* `,
* });
* ```
*
* To apply a plugin to a route use the `routeId` property, for example:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as kong from "@pulumi/kong";
*
* const service = new kong.Service("service", {
* name: "test",
* protocol: "http",
* host: "test.org",
* });
* const rateLimit = new kong.Plugin("rate_limit", {
* name: "rate-limiting",
* enabled: true,
* serviceId: service.id,
* configJson: `\x09{
* \x09\x09"second": 11,
* \x09\x09"hour" : 4000
* \x09}
* `,
* });
* ```
*
* ## Import
*
* To import a plugin:
*
* ```sh
* $ pulumi import kong:index/plugin:Plugin <plugin_identifier> <plugin_id>
* ```
*/
class Plugin extends pulumi.CustomResource {
/**
* Get an existing Plugin 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 Plugin(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Plugin. 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'] === Plugin.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["computedConfig"] = state ? state.computedConfig : undefined;
resourceInputs["configJson"] = state ? state.configJson : undefined;
resourceInputs["consumerId"] = state ? state.consumerId : undefined;
resourceInputs["enabled"] = state ? state.enabled : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["routeId"] = state ? state.routeId : undefined;
resourceInputs["serviceId"] = state ? state.serviceId : undefined;
resourceInputs["strictMatch"] = state ? state.strictMatch : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
}
else {
const args = argsOrState;
resourceInputs["configJson"] = args ? args.configJson : undefined;
resourceInputs["consumerId"] = args ? args.consumerId : undefined;
resourceInputs["enabled"] = args ? args.enabled : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["routeId"] = args ? args.routeId : undefined;
resourceInputs["serviceId"] = args ? args.serviceId : undefined;
resourceInputs["strictMatch"] = args ? args.strictMatch : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["computedConfig"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Plugin.__pulumiType, name, resourceInputs, opts);
}
}
exports.Plugin = Plugin;
/** @internal */
Plugin.__pulumiType = 'kong:index/plugin:Plugin';
//# sourceMappingURL=plugin.js.map