UNPKG

@pulumiverse/scaleway

Version:

A Pulumi package for creating and managing Scaleway cloud resources.

169 lines 6.86 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! *** 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.Privilege = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * Create and manage Scaleway database privileges. * For more information refer to the [API documentation](https://www.scaleway.com/en/developers/api/managed-database-postgre-mysql/#user-and-permissions). * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@pulumiverse/scaleway"; * * const main = new scaleway.databases.Instance("main", { * name: "rdb", * nodeType: "DB-DEV-S", * engine: "PostgreSQL-11", * isHaCluster: true, * disableBackup: true, * userName: "my_initial_user", * password: "thiZ_is_v&ry_s3cret", * }); * const mainDatabase = new scaleway.databases.Database("main", { * instanceId: main.id, * name: "database", * }); * const mainUser = new scaleway.databases.User("main", { * instanceId: main.id, * name: "my-db-user", * password: "thiZ_is_v&ry_s3cret", * isAdmin: false, * }); * const mainPrivilege = new scaleway.databases.Privilege("main", { * instanceId: main.id, * userName: mainUser.name, * databaseName: mainDatabase.name, * permission: "all", * }); * ``` * * ## Permission Drift Management * * ### Understanding Permission Drift * * When you configure a privilege (e.g., `readwrite`), Scaleway applies it to **database objects that exist at that moment**. If new tables, views, or sequences are created later, they won't automatically inherit these permissions. In that case, the API may return `custom`. * * **Example:** * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@pulumiverse/scaleway"; * * const app = new scaleway.databases.Privilege("app", { * instanceId: main.id, * userName: "app_user", * databaseName: "mydb", * permission: "readwrite", * }); * ``` * * ### Handling Permission Drift * * Run `pulumi up` to reapply the configured permission to all objects (existing and new): * * The plan will typically show: * * ## Import * * The user privileges can be imported using the `{region}/{instance_id}/{database_name}/{user_name}`, e.g. * * ```sh * $ pulumi import scaleway:databases/privilege:Privilege o fr-par/11111111-1111-1111-1111-111111111111/database_name/foo * ``` */ class Privilege extends pulumi.CustomResource { /** * Get an existing Privilege 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 Privilege(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'scaleway:databases/privilege:Privilege'; /** * Returns true if the given object is an instance of Privilege. 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'] === Privilege.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["databaseName"] = state?.databaseName; resourceInputs["effectivePermission"] = state?.effectivePermission; resourceInputs["instanceId"] = state?.instanceId; resourceInputs["permission"] = state?.permission; resourceInputs["permissionStatus"] = state?.permissionStatus; resourceInputs["region"] = state?.region; resourceInputs["userName"] = state?.userName; } else { const args = argsOrState; if (args?.databaseName === undefined && !opts.urn) { throw new Error("Missing required property 'databaseName'"); } if (args?.instanceId === undefined && !opts.urn) { throw new Error("Missing required property 'instanceId'"); } if (args?.permission === undefined && !opts.urn) { throw new Error("Missing required property 'permission'"); } if (args?.userName === undefined && !opts.urn) { throw new Error("Missing required property 'userName'"); } resourceInputs["databaseName"] = args?.databaseName; resourceInputs["instanceId"] = args?.instanceId; resourceInputs["permission"] = args?.permission; resourceInputs["region"] = args?.region; resourceInputs["userName"] = args?.userName; resourceInputs["effectivePermission"] = undefined /*out*/; resourceInputs["permissionStatus"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const aliasOpts = { aliases: [{ type: "scaleway:index/databasePrivilege:DatabasePrivilege" }] }; opts = pulumi.mergeOptions(opts, aliasOpts); super(Privilege.__pulumiType, name, resourceInputs, opts); } } exports.Privilege = Privilege; //# sourceMappingURL=privilege.js.map