@pulumi/consul
Version:
A Pulumi package for creating and managing consul resources.
158 lines • 6.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.PreparedQuery = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Allows Terraform to manage a Consul prepared query.
*
* Managing prepared queries is done using Consul's REST API. This resource is useful to provide a consistent and declarative way of managing prepared queries in your Consul cluster using Terraform.
*
* ## 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, { ...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?.connect;
resourceInputs["datacenter"] = state?.datacenter;
resourceInputs["dns"] = state?.dns;
resourceInputs["failover"] = state?.failover;
resourceInputs["ignoreCheckIds"] = state?.ignoreCheckIds;
resourceInputs["name"] = state?.name;
resourceInputs["near"] = state?.near;
resourceInputs["nodeMeta"] = state?.nodeMeta;
resourceInputs["onlyPassing"] = state?.onlyPassing;
resourceInputs["service"] = state?.service;
resourceInputs["serviceMeta"] = state?.serviceMeta;
resourceInputs["session"] = state?.session;
resourceInputs["storedToken"] = state?.storedToken;
resourceInputs["tags"] = state?.tags;
resourceInputs["template"] = state?.template;
resourceInputs["token"] = state?.token;
}
else {
const args = argsOrState;
if (args?.service === undefined && !opts.urn) {
throw new Error("Missing required property 'service'");
}
resourceInputs["connect"] = args?.connect;
resourceInputs["datacenter"] = args?.datacenter;
resourceInputs["dns"] = args?.dns;
resourceInputs["failover"] = args?.failover;
resourceInputs["ignoreCheckIds"] = args?.ignoreCheckIds;
resourceInputs["name"] = args?.name;
resourceInputs["near"] = args?.near;
resourceInputs["nodeMeta"] = args?.nodeMeta;
resourceInputs["onlyPassing"] = args?.onlyPassing;
resourceInputs["service"] = args?.service;
resourceInputs["serviceMeta"] = args?.serviceMeta;
resourceInputs["session"] = args?.session;
resourceInputs["storedToken"] = args?.storedToken;
resourceInputs["tags"] = args?.tags;
resourceInputs["template"] = args?.template;
resourceInputs["token"] = 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