@pulumi/consul
Version:
A Pulumi package for creating and managing consul resources.
352 lines • 11 kB
JavaScript
"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! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigEntry = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* The [Configuration Entry](https://www.consul.io/docs/agent/config_entries.html)
* resource can be used to provide cluster-wide defaults for various aspects of
* Consul.
*
* > **NOTE:** Because the schema in a `consul.ConfigEntry` resource can vary
* widely between the various configuration entry kinds, it is necessary to explicitly
* define every attribute to avoid Terraform reporting a diff on the resource.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* const proxyDefaults = new consul.ConfigEntry("proxy_defaults", {
* kind: "proxy-defaults",
* name: "global",
* configJson: JSON.stringify({
* Config: {
* local_connect_timeout_ms: 1000,
* handshake_timeout_ms: 10000,
* },
* }),
* });
* const web = new consul.ConfigEntry("web", {
* name: "web",
* kind: "service-defaults",
* configJson: JSON.stringify({
* Protocol: "http",
* }),
* });
* const admin = new consul.ConfigEntry("admin", {
* name: "admin",
* kind: "service-defaults",
* configJson: JSON.stringify({
* Protocol: "http",
* }),
* });
* const serviceResolver = new consul.ConfigEntry("service_resolver", {
* kind: "service-resolver",
* name: web.name,
* configJson: JSON.stringify({
* DefaultSubset: "v1",
* Subsets: {
* v1: {
* Filter: "Service.Meta.version == v1",
* },
* v2: {
* Filter: "Service.Meta.version == v2",
* },
* },
* }),
* });
* const serviceSplitter = new consul.ConfigEntry("service_splitter", {
* kind: "service-splitter",
* name: serviceResolver.name,
* configJson: JSON.stringify({
* Splits: [
* {
* Weight: 90,
* ServiceSubset: "v1",
* },
* {
* Weight: 10,
* ServiceSubset: "v2",
* },
* ],
* }),
* });
* const serviceRouter = new consul.ConfigEntry("service_router", {
* kind: "service-router",
* name: "web",
* configJson: JSON.stringify({
* Routes: [{
* Match: {
* HTTP: {
* PathPrefix: "/admin",
* },
* },
* Destination: {
* Service: "admin",
* },
* }],
* }),
* });
* const ingressGateway = new consul.ConfigEntry("ingress_gateway", {
* name: "us-east-ingress",
* kind: "ingress-gateway",
* configJson: JSON.stringify({
* TLS: {
* Enabled: true,
* },
* Listeners: [{
* Port: 8000,
* Protocol: "http",
* Services: [{
* Name: "*",
* }],
* }],
* }),
* });
* const terminatingGateway = new consul.ConfigEntry("terminating_gateway", {
* name: "us-west-gateway",
* kind: "terminating-gateway",
* configJson: JSON.stringify({
* Services: [{
* Name: "billing",
* }],
* }),
* });
* ```
*
* ### `service-intentions` config entry
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* const serviceIntentions = new consul.ConfigEntry("service_intentions", {
* name: "api-service",
* kind: "service-intentions",
* configJson: JSON.stringify({
* Sources: [
* {
* Action: "allow",
* Name: "frontend-webapp",
* Precedence: 9,
* Type: "consul",
* },
* {
* Action: "allow",
* Name: "nightly-cronjob",
* Precedence: 9,
* Type: "consul",
* },
* ],
* }),
* });
* ```
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* const sd = new consul.ConfigEntry("sd", {
* name: "fort-knox",
* kind: "service-defaults",
* configJson: JSON.stringify({
* Protocol: "http",
* }),
* });
* const jwtProvider = new consul.ConfigEntry("jwt_provider", {
* name: "test-provider",
* kind: "jwt-provider",
* configJson: JSON.stringify({
* Issuer: "test-issuer",
* JSONWebKeySet: {
* Remote: {
* URI: "https://127.0.0.1:9091",
* FetchAsynchronously: true,
* },
* },
* Forwarding: {
* HeaderName: "test-token",
* },
* }),
* });
* const serviceIntentions = new consul.ConfigEntry("service_intentions", {
* name: sd.name,
* kind: "service-intentions",
* configJson: pulumi.jsonStringify({
* Sources: [
* {
* Name: "contractor-webapp",
* Permissions: [{
* Action: "allow",
* HTTP: {
* Methods: [
* "GET",
* "HEAD",
* ],
* PathExact: "/healtz",
* },
* JWT: {
* Providers: [{
* Name: jwtProvider.name,
* }],
* },
* }],
* Precedence: 9,
* Type: "consul",
* },
* {
* Name: "admin-dashboard-webapp",
* Permissions: [
* {
* Action: "deny",
* HTTP: {
* PathPrefix: "/debugz",
* },
* },
* {
* Action: "allow",
* HTTP: {
* PathPrefix: "/",
* },
* },
* ],
* Precedence: 9,
* Type: "consul",
* },
* ],
* }),
* });
* ```
*
* ### `exported-services` config entry
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* const exportedServices = new consul.ConfigEntry("exported_services", {
* name: "test",
* kind: "exported-services",
* configJson: JSON.stringify({
* Services: [{
* Name: "test",
* Namespace: "default",
* Consumers: [{
* Partition: "default",
* }],
* }],
* }),
* });
* ```
*
* ### `mesh` config entry
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* const mesh = new consul.ConfigEntry("mesh", {
* name: "mesh",
* kind: "mesh",
* partition: "default",
* configJson: JSON.stringify({
* TransparentProxy: {
* MeshDestinationsOnly: true,
* },
* }),
* });
* ```
*
* ### `jwt-provider` config entry
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* const jwtProvider = new consul.ConfigEntry("jwt_provider", {
* name: "provider-name",
* kind: "jwt-provider",
* configJson: JSON.stringify({
* Issuer: "https://your.issuer.com",
* JSONWebKeySet: {
* Remote: {
* URI: "https://your-remote.jwks.com",
* FetchAsynchronously: true,
* CacheDuration: "10s",
* },
* },
* Forwarding: {
* HeaderName: "test-token",
* },
* }),
* });
* ```
*
* ## Import
*
* `consul.ConfigEntry` can be imported using the syntax `<kind>/<name>` if the
* config entry is in the default partition and default namespace, or
* `<partition>/<namespace>/<kind>/<name>` for config entries in a non-default
* partition or namespace:
*
* ```sh
* $ pulumi import consul:index/configEntry:ConfigEntry service_splitter 816a195f-6cb1-2e8d-92af-3011ae706318
* ```
*/
class ConfigEntry extends pulumi.CustomResource {
/**
* Get an existing ConfigEntry 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 ConfigEntry(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of ConfigEntry. 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'] === ConfigEntry.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["configJson"] = state?.configJson;
resourceInputs["kind"] = state?.kind;
resourceInputs["name"] = state?.name;
resourceInputs["namespace"] = state?.namespace;
resourceInputs["partition"] = state?.partition;
}
else {
const args = argsOrState;
if (args?.kind === undefined && !opts.urn) {
throw new Error("Missing required property 'kind'");
}
resourceInputs["configJson"] = args?.configJson;
resourceInputs["kind"] = args?.kind;
resourceInputs["name"] = args?.name;
resourceInputs["namespace"] = args?.namespace;
resourceInputs["partition"] = args?.partition;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ConfigEntry.__pulumiType, name, resourceInputs, opts);
}
}
exports.ConfigEntry = ConfigEntry;
/** @internal */
ConfigEntry.__pulumiType = 'consul:index/configEntry:ConfigEntry';
//# sourceMappingURL=configEntry.js.map