UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

88 lines 3.52 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.UserPolicyAttachment = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Attaches a Managed IAM Policy to an IAM user * * > **NOTE:** The usage of this resource conflicts with the `aws.iam.PolicyAttachment` resource and will permanently show a difference if both are defined. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const user = new aws.iam.User("user", {name: "test-user"}); * const policy = new aws.iam.Policy("policy", { * name: "test-policy", * description: "A test policy", * policy: "{ ... policy JSON ... }", * }); * const test_attach = new aws.iam.UserPolicyAttachment("test-attach", { * user: user.name, * policyArn: policy.arn, * }); * ``` * * ## Import * * Using `pulumi import`, import IAM user policy attachments using the user name and policy arn separated by `/`. For example: * * ```sh * $ pulumi import aws:iam/userPolicyAttachment:UserPolicyAttachment test-attach test-user/arn:aws:iam::xxxxxxxxxxxx:policy/test-policy * ``` */ class UserPolicyAttachment extends pulumi.CustomResource { /** * Get an existing UserPolicyAttachment 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 UserPolicyAttachment(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of UserPolicyAttachment. 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'] === UserPolicyAttachment.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["policyArn"] = state?.policyArn; resourceInputs["user"] = state?.user; } else { const args = argsOrState; if (args?.policyArn === undefined && !opts.urn) { throw new Error("Missing required property 'policyArn'"); } if (args?.user === undefined && !opts.urn) { throw new Error("Missing required property 'user'"); } resourceInputs["policyArn"] = args?.policyArn; resourceInputs["user"] = args?.user; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(UserPolicyAttachment.__pulumiType, name, resourceInputs, opts); } } exports.UserPolicyAttachment = UserPolicyAttachment; /** @internal */ UserPolicyAttachment.__pulumiType = 'aws:iam/userPolicyAttachment:UserPolicyAttachment'; //# sourceMappingURL=userPolicyAttachment.js.map