@pulumi/consul
Version:
A Pulumi package for creating and managing consul resources.
154 lines • 6.56 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.PreparedQuery = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* // Creates a prepared query myquery.query.consul that finds the nearest
* // healthy myapp.service.consul instance that has the active tag and not
* // the standby tag.
* const myapp_query = new consul.PreparedQuery("myapp-query", {
* name: "myquery",
* datacenter: "us-central1",
* token: "abcd",
* storedToken: "wxyz",
* onlyPassing: true,
* near: "_agent",
* service: "myapp",
* tags: [
* "active",
* "!standby",
* ],
* failover: {
* nearestN: 3,
* datacenters: [
* "us-west1",
* "us-east-2",
* "asia-east1",
* ],
* },
* dns: {
* ttl: "30s",
* },
* });
* // Creates a Prepared Query Template that matches *-near-self.query.consul
* // and finds the nearest service that matches the glob character (e.g.
* // foo-near-self.query.consul will find the nearest healthy foo.service.consul).
* const service_near_self = new consul.PreparedQuery("service-near-self", {
* datacenter: "nyc1",
* token: "abcd",
* storedToken: "wxyz",
* name: "",
* onlyPassing: true,
* connect: true,
* near: "_agent",
* template: {
* type: "name_prefix_match",
* regexp: "^(.*)-near-self$",
* },
* service: "${match(1)}",
* failover: {
* nearestN: 3,
* datacenters: [
* "dc2",
* "dc3",
* "dc4",
* ],
* },
* dns: {
* ttl: "5m",
* },
* });
* ```
*
* ## Import
*
* ```sh
* $ pulumi import consul:index/preparedQuery:PreparedQuery my_service 71ecfb82-717a-4258-b4b6-2fb75144d856
* ```
*/
class PreparedQuery extends pulumi.CustomResource {
/**
* Get an existing PreparedQuery 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 PreparedQuery(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of PreparedQuery. 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'] === PreparedQuery.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["connect"] = state ? state.connect : undefined;
resourceInputs["datacenter"] = state ? state.datacenter : undefined;
resourceInputs["dns"] = state ? state.dns : undefined;
resourceInputs["failover"] = state ? state.failover : undefined;
resourceInputs["ignoreCheckIds"] = state ? state.ignoreCheckIds : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["near"] = state ? state.near : undefined;
resourceInputs["nodeMeta"] = state ? state.nodeMeta : undefined;
resourceInputs["onlyPassing"] = state ? state.onlyPassing : undefined;
resourceInputs["service"] = state ? state.service : undefined;
resourceInputs["serviceMeta"] = state ? state.serviceMeta : undefined;
resourceInputs["session"] = state ? state.session : undefined;
resourceInputs["storedToken"] = state ? state.storedToken : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["template"] = state ? state.template : undefined;
resourceInputs["token"] = state ? state.token : undefined;
}
else {
const args = argsOrState;
if ((!args || args.service === undefined) && !opts.urn) {
throw new Error("Missing required property 'service'");
}
resourceInputs["connect"] = args ? args.connect : undefined;
resourceInputs["datacenter"] = args ? args.datacenter : undefined;
resourceInputs["dns"] = args ? args.dns : undefined;
resourceInputs["failover"] = args ? args.failover : undefined;
resourceInputs["ignoreCheckIds"] = args ? args.ignoreCheckIds : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["near"] = args ? args.near : undefined;
resourceInputs["nodeMeta"] = args ? args.nodeMeta : undefined;
resourceInputs["onlyPassing"] = args ? args.onlyPassing : undefined;
resourceInputs["service"] = args ? args.service : undefined;
resourceInputs["serviceMeta"] = args ? args.serviceMeta : undefined;
resourceInputs["session"] = args ? args.session : undefined;
resourceInputs["storedToken"] = args ? args.storedToken : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["template"] = args ? args.template : undefined;
resourceInputs["token"] = (args === null || args === void 0 ? void 0 : args.token) ? pulumi.secret(args.token) : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
const secretOpts = { additionalSecretOutputs: ["token"] };
opts = pulumi.mergeOptions(opts, secretOpts);
super(PreparedQuery.__pulumiType, name, resourceInputs, opts);
}
}
exports.PreparedQuery = PreparedQuery;
/** @internal */
PreparedQuery.__pulumiType = 'consul:index/preparedQuery:PreparedQuery';
//# sourceMappingURL=preparedQuery.js.map