UNPKG

@pulumi/aws

Version:

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

124 lines (123 loc) 4.53 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; /** * Provides an IAM policy attached to a user. * * > **NOTE:** We suggest using explicit JSON encoding or `aws.iam.getPolicyDocument` when assigning a value to `policy`. They seamlessly translate configuration to JSON, enabling you to maintain consistency within your configuration without the need for context switches. Also, you can sidestep potential complications arising from formatting discrepancies, whitespace inconsistencies, and other nuances inherent to JSON. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const lb = new aws.iam.User("lb", { * name: "loadbalancer", * path: "/system/", * }); * const lbRo = new aws.iam.UserPolicy("lb_ro", { * name: "test", * user: lb.name, * policy: JSON.stringify({ * Version: "2012-10-17", * Statement: [{ * Action: ["ec2:Describe*"], * Effect: "Allow", * Resource: "*", * }], * }), * }); * const lbAccessKey = new aws.iam.AccessKey("lb", {user: lb.name}); * ``` * * ## Import * * Using `pulumi import`, import IAM User Policies using the `user_name:user_policy_name`. For example: * * ```sh * $ pulumi import aws:iam/userPolicy:UserPolicy mypolicy user_of_mypolicy_name:mypolicy_name * ``` */ export declare class UserPolicy extends pulumi.CustomResource { /** * Get an existing UserPolicy 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: string, id: pulumi.Input<pulumi.ID>, state?: UserPolicyState, opts?: pulumi.CustomResourceOptions): UserPolicy; /** * Returns true if the given object is an instance of UserPolicy. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is UserPolicy; /** * The name of the policy. If omitted, the provider will assign a random, unique name. */ readonly name: pulumi.Output<string>; /** * Creates a unique name beginning with the specified prefix. Conflicts with `name`. */ readonly namePrefix: pulumi.Output<string>; /** * The policy document. This is a JSON formatted string. */ readonly policy: pulumi.Output<string>; /** * IAM user to which to attach this policy. */ readonly user: pulumi.Output<string>; /** * Create a UserPolicy resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: UserPolicyArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering UserPolicy resources. */ export interface UserPolicyState { /** * The name of the policy. If omitted, the provider will assign a random, unique name. */ name?: pulumi.Input<string>; /** * Creates a unique name beginning with the specified prefix. Conflicts with `name`. */ namePrefix?: pulumi.Input<string>; /** * The policy document. This is a JSON formatted string. */ policy?: pulumi.Input<string | inputs.iam.PolicyDocument>; /** * IAM user to which to attach this policy. */ user?: pulumi.Input<string>; } /** * The set of arguments for constructing a UserPolicy resource. */ export interface UserPolicyArgs { /** * The name of the policy. If omitted, the provider will assign a random, unique name. */ name?: pulumi.Input<string>; /** * Creates a unique name beginning with the specified prefix. Conflicts with `name`. */ namePrefix?: pulumi.Input<string>; /** * The policy document. This is a JSON formatted string. */ policy: pulumi.Input<string | inputs.iam.PolicyDocument>; /** * IAM user to which to attach this policy. */ user: pulumi.Input<string>; }