UNPKG

@pulumi/consul

Version:

A Pulumi package for creating and managing consul resources.

153 lines 6.2 kB
"use strict"; // *** 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.Service = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = 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, Object.assign(Object.assign({}, opts), { id: id })); } /** * 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 ? state.address : undefined; resourceInputs["checks"] = state ? state.checks : undefined; resourceInputs["datacenter"] = state ? state.datacenter : undefined; resourceInputs["enableTagOverride"] = state ? state.enableTagOverride : undefined; resourceInputs["external"] = state ? state.external : undefined; resourceInputs["meta"] = state ? state.meta : undefined; resourceInputs["name"] = state ? state.name : undefined; resourceInputs["namespace"] = state ? state.namespace : undefined; resourceInputs["node"] = state ? state.node : undefined; resourceInputs["partition"] = state ? state.partition : undefined; resourceInputs["port"] = state ? state.port : undefined; resourceInputs["serviceId"] = state ? state.serviceId : undefined; resourceInputs["tags"] = state ? state.tags : undefined; } else { const args = argsOrState; if ((!args || args.node === undefined) && !opts.urn) { throw new Error("Missing required property 'node'"); } resourceInputs["address"] = args ? args.address : undefined; resourceInputs["checks"] = args ? args.checks : undefined; resourceInputs["datacenter"] = args ? args.datacenter : undefined; resourceInputs["enableTagOverride"] = args ? args.enableTagOverride : undefined; resourceInputs["external"] = args ? args.external : undefined; resourceInputs["meta"] = args ? args.meta : undefined; resourceInputs["name"] = args ? args.name : undefined; resourceInputs["namespace"] = args ? args.namespace : undefined; resourceInputs["node"] = args ? args.node : undefined; resourceInputs["partition"] = args ? args.partition : undefined; resourceInputs["port"] = args ? args.port : undefined; resourceInputs["serviceId"] = args ? args.serviceId : undefined; resourceInputs["tags"] = args ? args.tags : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Service.__pulumiType, name, resourceInputs, opts); } } exports.Service = Service; /** @internal */ Service.__pulumiType = 'consul:index/service:Service'; //# sourceMappingURL=service.js.map