@pulumi/consul
Version:
A Pulumi package for creating and managing consul resources.
126 lines • 5.59 kB
JavaScript
;
// *** 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.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, Object.assign(Object.assign({}, 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 ? state.action : undefined;
resourceInputs["datacenter"] = state ? state.datacenter : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["destinationName"] = state ? state.destinationName : undefined;
resourceInputs["destinationNamespace"] = state ? state.destinationNamespace : undefined;
resourceInputs["meta"] = state ? state.meta : undefined;
resourceInputs["sourceName"] = state ? state.sourceName : undefined;
resourceInputs["sourceNamespace"] = state ? state.sourceNamespace : undefined;
}
else {
const args = argsOrState;
if ((!args || args.action === undefined) && !opts.urn) {
throw new Error("Missing required property 'action'");
}
if ((!args || args.destinationName === undefined) && !opts.urn) {
throw new Error("Missing required property 'destinationName'");
}
if ((!args || args.sourceName === undefined) && !opts.urn) {
throw new Error("Missing required property 'sourceName'");
}
resourceInputs["action"] = args ? args.action : undefined;
resourceInputs["datacenter"] = args ? args.datacenter : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["destinationName"] = args ? args.destinationName : undefined;
resourceInputs["destinationNamespace"] = args ? args.destinationNamespace : undefined;
resourceInputs["meta"] = args ? args.meta : undefined;
resourceInputs["sourceName"] = args ? args.sourceName : undefined;
resourceInputs["sourceNamespace"] = args ? args.sourceNamespace : undefined;
}
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