UNPKG

@pulumiverse/scaleway

Version:

A Pulumi package for creating and managing Scaleway cloud resources.

176 lines 6.72 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.User = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("../utilities")); /** * Manages MongoDB users. For more information, see the [API documentation](https://developers.scaleway.com/products/mongodb/api/). * * > **Security Best Practice:** * For enhanced security, we recommend using the `passwordWo` write-only argument instead of the regular `password` argument. This ensures your sensitive credentials are never stored in Terraform state files, providing superior protection against accidental exposure. Write-Only arguments are supported in Terraform 1.11.0 and later. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@pulumiverse/scaleway"; * * //## Basic user creation * const main = new scaleway.mongodb.Instance("main", { * name: "test-mongodb-user", * version: "7.0.12", * nodeType: "MGDB-PLAY2-NANO", * nodeNumber: 1, * userName: "initial_user", * password: "initial_password123", * volumeSizeInGb: 5, * }); * const mainUser = new scaleway.mongodb.User("main", { * instanceId: main.id, * name: "my_user", * password: "my_password123", * roles: [{ * role: "read_write", * databaseName: "my_database", * }], * }); * ``` * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as scaleway from "@pulumiverse/scaleway"; * * //## Multiple user creation * const main = new scaleway.mongodb.Instance("main", { * name: "test-mongodb-multi-user", * version: "7.0.12", * nodeType: "MGDB-PLAY2-NANO", * nodeNumber: 1, * userName: "admin_user", * password: "admin_password123", * volumeSizeInGb: 5, * }); * const appUser = new scaleway.mongodb.User("app_user", { * instanceId: main.id, * name: "app_user", * password: "app_password123", * roles: [ * { * role: "read_write", * databaseName: "app_database", * }, * { * role: "read", * databaseName: "logs_database", * }, * ], * }); * const adminUser = new scaleway.mongodb.User("admin_user", { * instanceId: main.id, * name: "admin_user", * password: "admin_password123", * roles: [ * { * role: "db_admin", * databaseName: "admin", * }, * { * role: "read", * anyDatabase: true, * }, * ], * }); * ``` * * ## Import * * MongoDB® users can be imported using the `{region}/{instance_id}/{name}`, e.g. * * ```sh * $ pulumi import scaleway:mongodb/user:User main fr-par/11111111-1111-1111-1111-111111111111/my_user * ``` */ class User extends pulumi.CustomResource { /** * Get an existing User 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 User(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'scaleway:mongodb/user:User'; /** * Returns true if the given object is an instance of User. 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'] === User.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["instanceId"] = state?.instanceId; resourceInputs["name"] = state?.name; resourceInputs["password"] = state?.password; resourceInputs["passwordWo"] = state?.passwordWo; resourceInputs["passwordWoVersion"] = state?.passwordWoVersion; resourceInputs["region"] = state?.region; resourceInputs["roles"] = state?.roles; } else { const args = argsOrState; if (args?.instanceId === undefined && !opts.urn) { throw new Error("Missing required property 'instanceId'"); } resourceInputs["instanceId"] = args?.instanceId; resourceInputs["name"] = args?.name; resourceInputs["password"] = args?.password ? pulumi.secret(args.password) : undefined; resourceInputs["passwordWo"] = args?.passwordWo ? pulumi.secret(args.passwordWo) : undefined; resourceInputs["passwordWoVersion"] = args?.passwordWoVersion; resourceInputs["region"] = args?.region; resourceInputs["roles"] = args?.roles; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const secretOpts = { additionalSecretOutputs: ["password", "passwordWo"] }; opts = pulumi.mergeOptions(opts, secretOpts); super(User.__pulumiType, name, resourceInputs, opts); } } exports.User = User; //# sourceMappingURL=user.js.map