@pulumi/consul
Version:
A Pulumi package for creating and managing consul resources.
144 lines • 5.14 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.ConfigEntryServiceSplitter = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* The `consul.ConfigEntryServiceSplitter` resource configures a [service splitter](https://developer.hashicorp.com/consul/docs/connect/config-entries/service-splitter) that will redirect a percentage of incoming traffic requests for a service to one or more specific service instances.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* const web = new consul.ConfigEntry("web", {
* name: "web",
* kind: "service-defaults",
* configJson: JSON.stringify({
* Protocol: "http",
* Expose: {},
* MeshGateway: {},
* TransparentProxy: {},
* }),
* });
* const serviceResolver = new consul.ConfigEntryServiceResolver("service_resolver", {
* name: "service-resolver",
* defaultSubset: "v1",
* subsets: [
* {
* name: "v1",
* filter: "Service.Meta.version == v1",
* },
* {
* name: "v2",
* filter: "Service.Meta.version == v2",
* },
* ],
* });
* const foo = new consul.ConfigEntryServiceSplitter("foo", {
* name: serviceResolver.name,
* meta: {
* key: "value",
* },
* splits: [
* {
* weight: 80,
* service: "web",
* serviceSubset: "v1",
* requestHeaders: {
* set: {
* "x-web-version": "from-v1",
* },
* },
* responseHeaders: {
* set: {
* "x-web-version": "to-v1",
* },
* },
* },
* {
* weight: 10,
* service: "web",
* serviceSubset: "v2",
* requestHeaders: {
* set: {
* "x-web-version": "from-v2",
* },
* },
* responseHeaders: {
* set: {
* "x-web-version": "to-v2",
* },
* },
* },
* {
* weight: 10,
* service: "web",
* serviceSubset: "v2",
* },
* ],
* });
* ```
*
* ## Import
*
* ```sh
* $ pulumi import consul:index/configEntryServiceSplitter:ConfigEntryServiceSplitter foo web
* ```
*/
class ConfigEntryServiceSplitter extends pulumi.CustomResource {
/**
* Get an existing ConfigEntryServiceSplitter 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 ConfigEntryServiceSplitter(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of ConfigEntryServiceSplitter. 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'] === ConfigEntryServiceSplitter.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["meta"] = state?.meta;
resourceInputs["name"] = state?.name;
resourceInputs["namespace"] = state?.namespace;
resourceInputs["partition"] = state?.partition;
resourceInputs["splits"] = state?.splits;
}
else {
const args = argsOrState;
if (args?.splits === undefined && !opts.urn) {
throw new Error("Missing required property 'splits'");
}
resourceInputs["meta"] = args?.meta;
resourceInputs["name"] = args?.name;
resourceInputs["namespace"] = args?.namespace;
resourceInputs["partition"] = args?.partition;
resourceInputs["splits"] = args?.splits;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ConfigEntryServiceSplitter.__pulumiType, name, resourceInputs, opts);
}
}
exports.ConfigEntryServiceSplitter = ConfigEntryServiceSplitter;
/** @internal */
ConfigEntryServiceSplitter.__pulumiType = 'consul:index/configEntryServiceSplitter:ConfigEntryServiceSplitter';
//# sourceMappingURL=configEntryServiceSplitter.js.map