UNPKG

@huaweicloudos/pulumi

Version:

A Pulumi package for creating and managing Huaweicloud cloud resources.

102 lines 4.37 kB
"use strict"; // *** 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.UserRoleAssignment = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages an IAM user role assignment within HuaweiCloud IAM. * * > **NOTE:** 1. You *must* have admin privileges to use this resource. * <br/>2. When the resource is created, the permissions will take effect after 15 to 30 minutes. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as huaweicloud from "@pulumi/huaweicloud"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const enterpriseProjectId = config.requireObject("enterpriseProjectId"); * const user1Password = config.requireObject("user1Password"); * const testRole = huaweicloud.Iam.getRole({ * displayName: "ECS FullAccess", * }); * const testUser = new huaweicloud.iam.User("testUser", { * description: "A user", * password: user1Password, * }); * const testUserRoleAssignment = new huaweicloud.iam.UserRoleAssignment("testUserRoleAssignment", { * userId: testUser.id, * roleId: testRole.then(testRole => testRole.id), * enterpriseProjectId: enterpriseProjectId, * }); * ``` * * ## Import * * The role assignments can be imported using the `user_id`, `role_id` and * * `enterprise_project_id`, e.g. bash * * ```sh * $ pulumi import huaweicloud:Iam/userRoleAssignment:UserRoleAssignment test <user_id>/<role_id>/<enterprise_project_id> * ``` */ class UserRoleAssignment extends pulumi.CustomResource { /** * Get an existing UserRoleAssignment 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 UserRoleAssignment(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of UserRoleAssignment. 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'] === UserRoleAssignment.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["enterpriseProjectId"] = state ? state.enterpriseProjectId : undefined; resourceInputs["roleId"] = state ? state.roleId : undefined; resourceInputs["userId"] = state ? state.userId : undefined; } else { const args = argsOrState; if ((!args || args.enterpriseProjectId === undefined) && !opts.urn) { throw new Error("Missing required property 'enterpriseProjectId'"); } if ((!args || args.roleId === undefined) && !opts.urn) { throw new Error("Missing required property 'roleId'"); } if ((!args || args.userId === undefined) && !opts.urn) { throw new Error("Missing required property 'userId'"); } resourceInputs["enterpriseProjectId"] = args ? args.enterpriseProjectId : undefined; resourceInputs["roleId"] = args ? args.roleId : undefined; resourceInputs["userId"] = args ? args.userId : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(UserRoleAssignment.__pulumiType, name, resourceInputs, opts); } } exports.UserRoleAssignment = UserRoleAssignment; /** @internal */ UserRoleAssignment.__pulumiType = 'huaweicloud:Iam/userRoleAssignment:UserRoleAssignment'; //# sourceMappingURL=userRoleAssignment.js.map