UNPKG

@pulumi/consul

Version:

A Pulumi package for creating and managing consul resources.

178 lines 6.83 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.Service = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("./utilities")); /** * A high-level resource for creating a Service in Consul in the Consul catalog. This * is appropriate for registering [external services](https://www.consul.io/docs/guides/external.html) and * can be used to create services addressable by Consul that cannot be registered * with a [local agent](https://www.consul.io/docs/agent/basics.html). * * > **NOTE:** If a Consul agent is running on the node where this service is * registered, it is not recommended to use this resource as the service will be * removed during the next [anti-entropy synchronization](https://www.consul.io/docs/architecture/anti-entropy). * * ## Example Usage * * Creating a new node with the service: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as consul from "@pulumi/consul"; * * const compute = new consul.Node("compute", { * name: "compute-google", * address: "www.google.com", * }); * const google = new consul.Service("google", { * name: "google", * node: compute.name, * port: 80, * tags: ["tag0"], * }); * ``` * * Utilizing an existing known node: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as consul from "@pulumi/consul"; * * const google = new consul.Service("google", { * name: "google", * node: "google", * port: 443, * }); * ``` * * Register a health-check: * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as consul from "@pulumi/consul"; * * const redis = new consul.Service("redis", { * name: "redis", * node: "redis", * port: 6379, * checks: [{ * checkId: "service:redis1", * name: "Redis health check", * status: "passing", * http: "https://www.hashicorptest.com", * tlsSkipVerify: false, * method: "PUT", * interval: "5s", * timeout: "1s", * deregisterCriticalServiceAfter: "30s", * headers: [ * { * name: "foo", * values: ["test"], * }, * { * name: "bar", * values: ["test"], * }, * ], * }], * }); * ``` */ class Service extends pulumi.CustomResource { /** * Get an existing Service 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 Service(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'consul:index/service:Service'; /** * Returns true if the given object is an instance of Service. 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'] === Service.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["address"] = state?.address; resourceInputs["checks"] = state?.checks; resourceInputs["datacenter"] = state?.datacenter; resourceInputs["enableTagOverride"] = state?.enableTagOverride; resourceInputs["external"] = state?.external; resourceInputs["meta"] = state?.meta; resourceInputs["name"] = state?.name; resourceInputs["namespace"] = state?.namespace; resourceInputs["node"] = state?.node; resourceInputs["partition"] = state?.partition; resourceInputs["port"] = state?.port; resourceInputs["serviceId"] = state?.serviceId; resourceInputs["tags"] = state?.tags; resourceInputs["weights"] = state?.weights; } else { const args = argsOrState; if (args?.node === undefined && !opts.urn) { throw new Error("Missing required property 'node'"); } resourceInputs["address"] = args?.address; resourceInputs["checks"] = args?.checks; resourceInputs["datacenter"] = args?.datacenter; resourceInputs["enableTagOverride"] = args?.enableTagOverride; resourceInputs["external"] = args?.external; resourceInputs["meta"] = args?.meta; resourceInputs["name"] = args?.name; resourceInputs["namespace"] = args?.namespace; resourceInputs["node"] = args?.node; resourceInputs["partition"] = args?.partition; resourceInputs["port"] = args?.port; resourceInputs["serviceId"] = args?.serviceId; resourceInputs["tags"] = args?.tags; resourceInputs["weights"] = args?.weights; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Service.__pulumiType, name, resourceInputs, opts); } } exports.Service = Service; //# sourceMappingURL=service.js.map