@pulumi/consul
Version:
A Pulumi package for creating and managing consul resources.
126 lines • 5.22 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! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Intention = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = 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 });
}
/**
* 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;
/** @internal */
Intention.__pulumiType = 'consul:index/intention:Intention';
//# sourceMappingURL=intention.js.map