UNPKG

@pulumi/aws

Version:

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

110 lines 4.39 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.RolePolicyAttachment = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Attaches a Managed IAM Policy to an IAM role * * > **NOTE:** The usage of this resource conflicts with the `aws.iam.PolicyAttachment` resource and will permanently show a difference if both are defined. * * > **NOTE:** For a given role, this resource is incompatible with using the `aws.iam.Role` resource `managedPolicyArns` argument. When using that argument and this resource, both will attempt to manage the role's managed policy attachments and Pulumi will show a permanent difference. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const assumeRole = aws.iam.getPolicyDocument({ * statements: [{ * effect: "Allow", * principals: [{ * type: "Service", * identifiers: ["ec2.amazonaws.com"], * }], * actions: ["sts:AssumeRole"], * }], * }); * const role = new aws.iam.Role("role", { * name: "test-role", * assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json), * }); * const policy = aws.iam.getPolicyDocument({ * statements: [{ * effect: "Allow", * actions: ["ec2:Describe*"], * resources: ["*"], * }], * }); * const policyPolicy = new aws.iam.Policy("policy", { * name: "test-policy", * description: "A test policy", * policy: policy.then(policy => policy.json), * }); * const test_attach = new aws.iam.RolePolicyAttachment("test-attach", { * role: role.name, * policyArn: policyPolicy.arn, * }); * ``` * * ## Import * * Using `pulumi import`, import IAM role policy attachments using the role name and policy arn separated by `/`. For example: * * ```sh * $ pulumi import aws:iam/rolePolicyAttachment:RolePolicyAttachment test-attach test-role/arn:aws:iam::xxxxxxxxxxxx:policy/test-policy * ``` */ class RolePolicyAttachment extends pulumi.CustomResource { /** * Get an existing RolePolicyAttachment 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 RolePolicyAttachment(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of RolePolicyAttachment. 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'] === RolePolicyAttachment.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["policyArn"] = state?.policyArn; resourceInputs["role"] = state?.role; } else { const args = argsOrState; if (args?.policyArn === undefined && !opts.urn) { throw new Error("Missing required property 'policyArn'"); } if (args?.role === undefined && !opts.urn) { throw new Error("Missing required property 'role'"); } resourceInputs["policyArn"] = args?.policyArn; resourceInputs["role"] = args?.role; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(RolePolicyAttachment.__pulumiType, name, resourceInputs, opts); } } exports.RolePolicyAttachment = RolePolicyAttachment; /** @internal */ RolePolicyAttachment.__pulumiType = 'aws:iam/rolePolicyAttachment:RolePolicyAttachment'; //# sourceMappingURL=rolePolicyAttachment.js.map