UNPKG

@pulumi/vault

Version:

A Pulumi package for creating and managing HashiCorp Vault cloud resources.

136 lines 6.19 kB
"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.SecretBackendStaticRole = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Creates a Database Secret Backend static role in Vault. Database secret backend * static roles can be used to manage 1-to-1 mapping of a Vault Role to a user in a * database for the database. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as vault from "@pulumi/vault"; * * const db = new vault.Mount("db", { * path: "postgres", * type: "database", * }); * const postgres = new vault.database.SecretBackendConnection("postgres", { * backend: db.path, * name: "postgres", * allowedRoles: ["*"], * postgresql: { * connectionUrl: "postgres://username:password@host:port/database", * }, * }); * // configure a static role with period-based rotations * const periodRole = new vault.database.SecretBackendStaticRole("period_role", { * backend: db.path, * name: "my-period-role", * dbName: postgres.name, * username: "example", * rotationPeriod: 3600, * rotationStatements: ["ALTER USER \"{{name}}\" WITH PASSWORD '{{password}}';"], * }); * // configure a static role with schedule-based rotations * const scheduleRole = new vault.database.SecretBackendStaticRole("schedule_role", { * backend: db.path, * name: "my-schedule-role", * dbName: postgres.name, * username: "example", * rotationSchedule: "0 0 * * SAT", * rotationWindow: 172800, * rotationStatements: ["ALTER USER \"{{name}}\" WITH PASSWORD '{{password}}';"], * }); * ``` * * ## Import * * Database secret backend static roles can be imported using the `backend`, `/static-roles/`, and the `name` e.g. * * ```sh * $ pulumi import vault:database/secretBackendStaticRole:SecretBackendStaticRole example postgres/static-roles/my-role * ``` */ class SecretBackendStaticRole extends pulumi.CustomResource { /** * Get an existing SecretBackendStaticRole 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 SecretBackendStaticRole(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of SecretBackendStaticRole. 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'] === SecretBackendStaticRole.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["backend"] = state?.backend; resourceInputs["credentialConfig"] = state?.credentialConfig; resourceInputs["credentialType"] = state?.credentialType; resourceInputs["dbName"] = state?.dbName; resourceInputs["name"] = state?.name; resourceInputs["namespace"] = state?.namespace; resourceInputs["rotationPeriod"] = state?.rotationPeriod; resourceInputs["rotationSchedule"] = state?.rotationSchedule; resourceInputs["rotationStatements"] = state?.rotationStatements; resourceInputs["rotationWindow"] = state?.rotationWindow; resourceInputs["selfManagedPassword"] = state?.selfManagedPassword; resourceInputs["skipImportRotation"] = state?.skipImportRotation; resourceInputs["username"] = state?.username; } else { const args = argsOrState; if (args?.backend === undefined && !opts.urn) { throw new Error("Missing required property 'backend'"); } if (args?.dbName === undefined && !opts.urn) { throw new Error("Missing required property 'dbName'"); } if (args?.username === undefined && !opts.urn) { throw new Error("Missing required property 'username'"); } resourceInputs["backend"] = args?.backend; resourceInputs["credentialConfig"] = args?.credentialConfig; resourceInputs["credentialType"] = args?.credentialType; resourceInputs["dbName"] = args?.dbName; resourceInputs["name"] = args?.name; resourceInputs["namespace"] = args?.namespace; resourceInputs["rotationPeriod"] = args?.rotationPeriod; resourceInputs["rotationSchedule"] = args?.rotationSchedule; resourceInputs["rotationStatements"] = args?.rotationStatements; resourceInputs["rotationWindow"] = args?.rotationWindow; resourceInputs["selfManagedPassword"] = args?.selfManagedPassword ? pulumi.secret(args.selfManagedPassword) : undefined; resourceInputs["skipImportRotation"] = args?.skipImportRotation; resourceInputs["username"] = args?.username; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["selfManagedPassword"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(SecretBackendStaticRole.__pulumiType, name, resourceInputs, opts); } } exports.SecretBackendStaticRole = SecretBackendStaticRole; /** @internal */ SecretBackendStaticRole.__pulumiType = 'vault:database/secretBackendStaticRole:SecretBackendStaticRole'; //# sourceMappingURL=secretBackendStaticRole.js.map