@pulumi/consul
Version:
A Pulumi package for creating and managing consul resources.
149 lines • 6.28 kB
JavaScript
;
// *** 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.Intention = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("./utilities"));
/**
* [Intentions](https://www.consul.io/docs/connect/intentions.html) are used to define
* rules for which services may connect to one another when using [Consul Connect](https://www.consul.io/docs/connect/index.html).
*
* > **NOTE:** This resource is appropriate for managing legacy intentions in
* Consul version 1.8 and earlier. As of Consul 1.9, intentions should be managed
* using the [`service-intentions`](https://www.consul.io/docs/connect/intentions)
* configuration entry. It is recommended to migrate from the `consul.Intention`
* resource to `consul.ConfigEntry` when running Consul 1.9 and later.
*
* It is appropriate to either reference existing services, or specify non-existent services
* that will be created in the future when creating intentions. This resource can be used
* in conjunction with the `consul.Service` datasource when referencing services
* registered on nodes that have a running Consul agent.
*
* ## Example Usage
*
* Create a simplest intention with static service names:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* const database = new consul.Intention("database", {
* sourceName: "api",
* destinationName: "db",
* action: "allow",
* });
* ```
*
* Referencing a known service via a datasource:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* const database = new consul.Intention("database", {
* sourceName: "api",
* destinationName: pgConsulService.name,
* action: "allow",
* });
* const pg = consul.getService({
* name: "postgresql",
* });
* ```
*
* ## Import
*
* `consul.Intention` can be imported:
*
* ```sh
* $ pulumi import consul:index/intention:Intention database 657a57d6-0d56-57e2-31cb-e9f1ed3c18dd
* ```
*/
class Intention extends pulumi.CustomResource {
/**
* Get an existing Intention 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 Intention(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'consul:index/intention:Intention';
/**
* Returns true if the given object is an instance of Intention. 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'] === Intention.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["action"] = state?.action;
resourceInputs["datacenter"] = state?.datacenter;
resourceInputs["description"] = state?.description;
resourceInputs["destinationName"] = state?.destinationName;
resourceInputs["destinationNamespace"] = state?.destinationNamespace;
resourceInputs["meta"] = state?.meta;
resourceInputs["sourceName"] = state?.sourceName;
resourceInputs["sourceNamespace"] = state?.sourceNamespace;
}
else {
const args = argsOrState;
if (args?.action === undefined && !opts.urn) {
throw new Error("Missing required property 'action'");
}
if (args?.destinationName === undefined && !opts.urn) {
throw new Error("Missing required property 'destinationName'");
}
if (args?.sourceName === undefined && !opts.urn) {
throw new Error("Missing required property 'sourceName'");
}
resourceInputs["action"] = args?.action;
resourceInputs["datacenter"] = args?.datacenter;
resourceInputs["description"] = args?.description;
resourceInputs["destinationName"] = args?.destinationName;
resourceInputs["destinationNamespace"] = args?.destinationNamespace;
resourceInputs["meta"] = args?.meta;
resourceInputs["sourceName"] = args?.sourceName;
resourceInputs["sourceNamespace"] = args?.sourceNamespace;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Intention.__pulumiType, name, resourceInputs, opts);
}
}
exports.Intention = Intention;
//# sourceMappingURL=intention.js.map