@pulumi/consul
Version:
A Pulumi package for creating and managing consul resources.
158 lines • 6.2 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.AclTokenRoleAttachment = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("./utilities"));
/**
* The `consul.AclTokenRoleAttachment` resource links a Consul Token and an ACL
* role. The link is implemented through an update to the Consul ACL token.
*
* > **NOTE:** This resource is only useful to attach roles to an ACL token
* that has been created outside the current Terraform configuration, like the
* anonymous or the master token. If the token you need to attach a policy to has
* been created in the current Terraform configuration and will only be used in it,
* you should use the `roles` attribute of [`consul.AclToken`](https://www.terraform.io/docs/providers/consul/r/acl_token.html).
*
* ## Example Usage
*
* ### Attach a role to the anonymous token
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* const role = new consul.AclRole("role", {
* name: "foo",
* description: "Foo",
* serviceIdentities: [{
* serviceName: "foo",
* }],
* });
* const attachment = new consul.AclTokenRoleAttachment("attachment", {
* tokenId: "00000000-0000-0000-0000-000000000002",
* roleId: role.id,
* });
* ```
*
* ### Attach a policy to a token created in another Terraform configuration
*
* ### In `first_configuration/main.tf`
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* const test = new consul.AclToken("test", {
* accessorId: "5914ee49-eb8d-4837-9767-9299ec155000",
* description: "my test token",
* local: true,
* });
* ```
*
* ### In `second_configuration/main.tf`
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as consul from "@pulumi/consul";
*
* const role = new consul.AclRole("role", {
* name: "foo",
* description: "Foo",
* serviceIdentities: [{
* serviceName: "foo",
* }],
* });
* const attachment = new consul.AclTokenRoleAttachment("attachment", {
* tokenId: "00000000-0000-0000-0000-000000000002",
* roleId: role.id,
* });
* ```
* **NOTE**: `consul.AclToken` would attempt to enforce an empty set of roles,
* because its `roles` attribute is empty. For this reason it is necessary to add
* the lifecycle clause to prevent Terraform from attempting to clear the set of
* roles associated to the token.
*
* ## Import
*
* `consul.AclTokenRoleAttachment` can be imported. This is especially useful to manage the
* policies attached to the anonymous and the master tokens with Terraform:
*
* ```sh
* $ pulumi import consul:index/aclTokenRoleAttachment:AclTokenRoleAttachment anonymous token_id:role_id
* ```
*/
class AclTokenRoleAttachment extends pulumi.CustomResource {
/**
* Get an existing AclTokenRoleAttachment 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 AclTokenRoleAttachment(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'consul:index/aclTokenRoleAttachment:AclTokenRoleAttachment';
/**
* Returns true if the given object is an instance of AclTokenRoleAttachment. 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'] === AclTokenRoleAttachment.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["role"] = state?.role;
resourceInputs["tokenId"] = state?.tokenId;
}
else {
const args = argsOrState;
if (args?.role === undefined && !opts.urn) {
throw new Error("Missing required property 'role'");
}
if (args?.tokenId === undefined && !opts.urn) {
throw new Error("Missing required property 'tokenId'");
}
resourceInputs["role"] = args?.role;
resourceInputs["tokenId"] = args?.tokenId;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(AclTokenRoleAttachment.__pulumiType, name, resourceInputs, opts);
}
}
exports.AclTokenRoleAttachment = AclTokenRoleAttachment;
//# sourceMappingURL=aclTokenRoleAttachment.js.map