@pulumi/consul
Version:
A Pulumi package for creating and managing consul resources.
269 lines (268 loc) • 8.91 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "./types/input";
import * as outputs from "./types/output";
/**
* 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"],
* },
* ],
* }],
* });
* ```
*/
export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: ServiceState, opts?: pulumi.CustomResourceOptions): 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: any): obj is Service;
/**
* The address of the service. Defaults to the address of the node.
*/
readonly address: pulumi.Output<string>;
readonly checks: pulumi.Output<outputs.ServiceCheck[] | undefined>;
/**
* The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
*/
readonly datacenter: pulumi.Output<string>;
/**
* Specifies to disable the anti-entropy feature for this service's tags. Defaults to `false`.
*/
readonly enableTagOverride: pulumi.Output<boolean | undefined>;
/**
* @deprecated The external field has been deprecated and does nothing.
*/
readonly external: pulumi.Output<boolean | undefined>;
/**
* A map of arbitrary KV metadata linked to the service instance.
*/
readonly meta: pulumi.Output<{
[key: string]: string;
} | undefined>;
/**
* The name of the service.
*/
readonly name: pulumi.Output<string>;
/**
* The namespace to create the service within.
*/
readonly namespace: pulumi.Output<string | undefined>;
/**
* The name of the node the to register the service on.
*/
readonly node: pulumi.Output<string>;
/**
* The partition the service is associated with.
*/
readonly partition: pulumi.Output<string | undefined>;
/**
* The port of the service.
*/
readonly port: pulumi.Output<number | undefined>;
/**
* If the service ID is not provided, it will be defaulted to the value of the `name` attribute.
*/
readonly serviceId: pulumi.Output<string>;
/**
* A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
*/
readonly tags: pulumi.Output<string[] | undefined>;
/**
* Create a Service resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: ServiceArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering Service resources.
*/
export interface ServiceState {
/**
* The address of the service. Defaults to the address of the node.
*/
address?: pulumi.Input<string>;
checks?: pulumi.Input<pulumi.Input<inputs.ServiceCheck>[]>;
/**
* The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
*/
datacenter?: pulumi.Input<string>;
/**
* Specifies to disable the anti-entropy feature for this service's tags. Defaults to `false`.
*/
enableTagOverride?: pulumi.Input<boolean>;
/**
* @deprecated The external field has been deprecated and does nothing.
*/
external?: pulumi.Input<boolean>;
/**
* A map of arbitrary KV metadata linked to the service instance.
*/
meta?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}>;
/**
* The name of the service.
*/
name?: pulumi.Input<string>;
/**
* The namespace to create the service within.
*/
namespace?: pulumi.Input<string>;
/**
* The name of the node the to register the service on.
*/
node?: pulumi.Input<string>;
/**
* The partition the service is associated with.
*/
partition?: pulumi.Input<string>;
/**
* The port of the service.
*/
port?: pulumi.Input<number>;
/**
* If the service ID is not provided, it will be defaulted to the value of the `name` attribute.
*/
serviceId?: pulumi.Input<string>;
/**
* A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
*/
tags?: pulumi.Input<pulumi.Input<string>[]>;
}
/**
* The set of arguments for constructing a Service resource.
*/
export interface ServiceArgs {
/**
* The address of the service. Defaults to the address of the node.
*/
address?: pulumi.Input<string>;
checks?: pulumi.Input<pulumi.Input<inputs.ServiceCheck>[]>;
/**
* The datacenter to use. This overrides the agent's default datacenter and the datacenter in the provider setup.
*/
datacenter?: pulumi.Input<string>;
/**
* Specifies to disable the anti-entropy feature for this service's tags. Defaults to `false`.
*/
enableTagOverride?: pulumi.Input<boolean>;
/**
* @deprecated The external field has been deprecated and does nothing.
*/
external?: pulumi.Input<boolean>;
/**
* A map of arbitrary KV metadata linked to the service instance.
*/
meta?: pulumi.Input<{
[key: string]: pulumi.Input<string>;
}>;
/**
* The name of the service.
*/
name?: pulumi.Input<string>;
/**
* The namespace to create the service within.
*/
namespace?: pulumi.Input<string>;
/**
* The name of the node the to register the service on.
*/
node: pulumi.Input<string>;
/**
* The partition the service is associated with.
*/
partition?: pulumi.Input<string>;
/**
* The port of the service.
*/
port?: pulumi.Input<number>;
/**
* If the service ID is not provided, it will be defaulted to the value of the `name` attribute.
*/
serviceId?: pulumi.Input<string>;
/**
* A list of values that are opaque to Consul, but can be used to distinguish between services or nodes.
*/
tags?: pulumi.Input<pulumi.Input<string>[]>;
}