UNPKG

@pulumi/consul

Version:

A Pulumi package for creating and managing consul resources.

148 lines 6.3 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! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.KeyPrefix = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("./utilities")); /** * Allows Terraform to manage a "namespace" of Consul keys that share a common * name prefix. * * Like `consul.Keys`, this resource can write values into the Consul key/value * store, but *unlike* `consul.Keys` this resource can detect and remove extra * keys that have been added some other way, thus ensuring that rogue data * added outside of Terraform will be removed on the next run. * * This resource is thus useful in the case where Terraform is exclusively * managing a set of related keys. * * To avoid accidentally clobbering matching data that existed in Consul before * a `consul.KeyPrefix` resource was created, creation of a key prefix instance * will fail if any matching keys are already present in the key/value store. * If any conflicting data is present, you must first delete it manually or * explicitly import the prefix. * * > **Warning** After this resource is instantiated, Terraform takes control * over *all* keys with the given path prefix, and will remove any matching keys * that are not present in the configuration. It will also delete *all* keys under * the given prefix when a `consul.KeyPrefix` resource is destroyed, even if * those keys were created outside of Terraform. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as consul from "@pulumi/consul"; * * const myappConfig = new consul.KeyPrefix("myapp_config", { * datacenter: "nyc1", * token: "abcd", * pathPrefix: "myapp/config/", * subkeys: { * elb_cname: appAwsElb.dnsName, * s3_bucket_name: appAwsS3Bucket.bucket, * "database/hostname": app.address, * "database/port": app.port, * "database/username": app.username, * "database/name": app.name, * }, * subkeyCollection: [{ * path: "database/password", * value: app.password, * flags: 2, * }], * }); * ``` * * ## Import * * `consul.KeyPrefix` can be imported. This is useful when the path already exists and * you know all keys in path should be managed by Terraform. * * ```sh * $ pulumi import consul:index/keyPrefix:KeyPrefix myapp_config myapp/config/ * ``` */ class KeyPrefix extends pulumi.CustomResource { /** * Get an existing KeyPrefix 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 KeyPrefix(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'consul:index/keyPrefix:KeyPrefix'; /** * Returns true if the given object is an instance of KeyPrefix. 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'] === KeyPrefix.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["datacenter"] = state?.datacenter; resourceInputs["namespace"] = state?.namespace; resourceInputs["partition"] = state?.partition; resourceInputs["pathPrefix"] = state?.pathPrefix; resourceInputs["subkeyCollection"] = state?.subkeyCollection; resourceInputs["subkeys"] = state?.subkeys; resourceInputs["token"] = state?.token; } else { const args = argsOrState; if (args?.pathPrefix === undefined && !opts.urn) { throw new Error("Missing required property 'pathPrefix'"); } resourceInputs["datacenter"] = args?.datacenter; resourceInputs["namespace"] = args?.namespace; resourceInputs["partition"] = args?.partition; resourceInputs["pathPrefix"] = args?.pathPrefix; resourceInputs["subkeyCollection"] = args?.subkeyCollection; resourceInputs["subkeys"] = args?.subkeys; 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(KeyPrefix.__pulumiType, name, resourceInputs, opts); } } exports.KeyPrefix = KeyPrefix; //# sourceMappingURL=keyPrefix.js.map