1. Packages
  2. Volcengine
  3. API Docs
  4. iam
  5. UserPolicyAttachment
Volcengine v0.0.24 published on Tuesday, Jun 25, 2024 by Volcengine

volcengine.iam.UserPolicyAttachment

Explore with Pulumi AI

volcengine logo
Volcengine v0.0.24 published on Tuesday, Jun 25, 2024 by Volcengine

    Provides a resource to manage iam user policy attachment

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Volcengine = Pulumi.Volcengine;
    
    return await Deployment.RunAsync(() => 
    {
        var user = new Volcengine.Iam.User("user", new()
        {
            UserName = "TfTest",
            Description = "test",
        });
    
        var policy = new Volcengine.Iam.Policy("policy", new()
        {
            PolicyName = "TerraformResourceTest1",
            Description = "created by terraform 1",
            PolicyDocument = "{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"auto_scaling:DescribeScalingGroups\"],\"Resource\":[\"*\"]}]}",
        });
    
        var foo = new Volcengine.Iam.UserPolicyAttachment("foo", new()
        {
            UserName = user.UserName,
            PolicyName = policy.PolicyName,
            PolicyType = policy.PolicyType,
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/volcengine/pulumi-volcengine/sdk/go/volcengine/iam"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		user, err := iam.NewUser(ctx, "user", &iam.UserArgs{
    			UserName:    pulumi.String("TfTest"),
    			Description: pulumi.String("test"),
    		})
    		if err != nil {
    			return err
    		}
    		policy, err := iam.NewPolicy(ctx, "policy", &iam.PolicyArgs{
    			PolicyName:     pulumi.String("TerraformResourceTest1"),
    			Description:    pulumi.String("created by terraform 1"),
    			PolicyDocument: pulumi.String("{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"auto_scaling:DescribeScalingGroups\"],\"Resource\":[\"*\"]}]}"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = iam.NewUserPolicyAttachment(ctx, "foo", &iam.UserPolicyAttachmentArgs{
    			UserName:   user.UserName,
    			PolicyName: policy.PolicyName,
    			PolicyType: policy.PolicyType,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.volcengine.iam.User;
    import com.pulumi.volcengine.iam.UserArgs;
    import com.pulumi.volcengine.iam.Policy;
    import com.pulumi.volcengine.iam.PolicyArgs;
    import com.pulumi.volcengine.iam.UserPolicyAttachment;
    import com.pulumi.volcengine.iam.UserPolicyAttachmentArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var user = new User("user", UserArgs.builder()        
                .userName("TfTest")
                .description("test")
                .build());
    
            var policy = new Policy("policy", PolicyArgs.builder()        
                .policyName("TerraformResourceTest1")
                .description("created by terraform 1")
                .policyDocument("{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"auto_scaling:DescribeScalingGroups\"],\"Resource\":[\"*\"]}]}")
                .build());
    
            var foo = new UserPolicyAttachment("foo", UserPolicyAttachmentArgs.builder()        
                .userName(user.userName())
                .policyName(policy.policyName())
                .policyType(policy.policyType())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_volcengine as volcengine
    
    user = volcengine.iam.User("user",
        user_name="TfTest",
        description="test")
    policy = volcengine.iam.Policy("policy",
        policy_name="TerraformResourceTest1",
        description="created by terraform 1",
        policy_document="{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"auto_scaling:DescribeScalingGroups\"],\"Resource\":[\"*\"]}]}")
    foo = volcengine.iam.UserPolicyAttachment("foo",
        user_name=user.user_name,
        policy_name=policy.policy_name,
        policy_type=policy.policy_type)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as volcengine from "@volcengine/pulumi";
    
    const user = new volcengine.iam.User("user", {
        userName: "TfTest",
        description: "test",
    });
    const policy = new volcengine.iam.Policy("policy", {
        policyName: "TerraformResourceTest1",
        description: "created by terraform 1",
        policyDocument: "{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"auto_scaling:DescribeScalingGroups\"],\"Resource\":[\"*\"]}]}",
    });
    const foo = new volcengine.iam.UserPolicyAttachment("foo", {
        userName: user.userName,
        policyName: policy.policyName,
        policyType: policy.policyType,
    });
    
    resources:
      user:
        type: volcengine:iam:User
        properties:
          userName: TfTest
          description: test
      policy:
        type: volcengine:iam:Policy
        properties:
          policyName: TerraformResourceTest1
          description: created by terraform 1
          policyDocument: '{"Statement":[{"Effect":"Allow","Action":["auto_scaling:DescribeScalingGroups"],"Resource":["*"]}]}'
      foo:
        type: volcengine:iam:UserPolicyAttachment
        properties:
          userName: ${user.userName}
          policyName: ${policy.policyName}
          policyType: ${policy.policyType}
    

    Create UserPolicyAttachment Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new UserPolicyAttachment(name: string, args: UserPolicyAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def UserPolicyAttachment(resource_name: str,
                             args: UserPolicyAttachmentArgs,
                             opts: Optional[ResourceOptions] = None)
    
    @overload
    def UserPolicyAttachment(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             policy_name: Optional[str] = None,
                             policy_type: Optional[str] = None,
                             user_name: Optional[str] = None)
    func NewUserPolicyAttachment(ctx *Context, name string, args UserPolicyAttachmentArgs, opts ...ResourceOption) (*UserPolicyAttachment, error)
    public UserPolicyAttachment(string name, UserPolicyAttachmentArgs args, CustomResourceOptions? opts = null)
    public UserPolicyAttachment(String name, UserPolicyAttachmentArgs args)
    public UserPolicyAttachment(String name, UserPolicyAttachmentArgs args, CustomResourceOptions options)
    
    type: volcengine:iam:UserPolicyAttachment
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args UserPolicyAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args UserPolicyAttachmentArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args UserPolicyAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args UserPolicyAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args UserPolicyAttachmentArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var userPolicyAttachmentResource = new Volcengine.Iam.UserPolicyAttachment("userPolicyAttachmentResource", new()
    {
        PolicyName = "string",
        PolicyType = "string",
        UserName = "string",
    });
    
    example, err := iam.NewUserPolicyAttachment(ctx, "userPolicyAttachmentResource", &iam.UserPolicyAttachmentArgs{
    	PolicyName: pulumi.String("string"),
    	PolicyType: pulumi.String("string"),
    	UserName:   pulumi.String("string"),
    })
    
    var userPolicyAttachmentResource = new UserPolicyAttachment("userPolicyAttachmentResource", UserPolicyAttachmentArgs.builder()
        .policyName("string")
        .policyType("string")
        .userName("string")
        .build());
    
    user_policy_attachment_resource = volcengine.iam.UserPolicyAttachment("userPolicyAttachmentResource",
        policy_name="string",
        policy_type="string",
        user_name="string")
    
    const userPolicyAttachmentResource = new volcengine.iam.UserPolicyAttachment("userPolicyAttachmentResource", {
        policyName: "string",
        policyType: "string",
        userName: "string",
    });
    
    type: volcengine:iam:UserPolicyAttachment
    properties:
        policyName: string
        policyType: string
        userName: string
    

    UserPolicyAttachment Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The UserPolicyAttachment resource accepts the following input properties:

    PolicyName string
    The name of the Policy.
    PolicyType string
    The type of the Policy.
    UserName string
    The name of the user.
    PolicyName string
    The name of the Policy.
    PolicyType string
    The type of the Policy.
    UserName string
    The name of the user.
    policyName String
    The name of the Policy.
    policyType String
    The type of the Policy.
    userName String
    The name of the user.
    policyName string
    The name of the Policy.
    policyType string
    The type of the Policy.
    userName string
    The name of the user.
    policy_name str
    The name of the Policy.
    policy_type str
    The type of the Policy.
    user_name str
    The name of the user.
    policyName String
    The name of the Policy.
    policyType String
    The type of the Policy.
    userName String
    The name of the user.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the UserPolicyAttachment resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing UserPolicyAttachment Resource

    Get an existing UserPolicyAttachment resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: UserPolicyAttachmentState, opts?: CustomResourceOptions): UserPolicyAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            policy_name: Optional[str] = None,
            policy_type: Optional[str] = None,
            user_name: Optional[str] = None) -> UserPolicyAttachment
    func GetUserPolicyAttachment(ctx *Context, name string, id IDInput, state *UserPolicyAttachmentState, opts ...ResourceOption) (*UserPolicyAttachment, error)
    public static UserPolicyAttachment Get(string name, Input<string> id, UserPolicyAttachmentState? state, CustomResourceOptions? opts = null)
    public static UserPolicyAttachment get(String name, Output<String> id, UserPolicyAttachmentState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    PolicyName string
    The name of the Policy.
    PolicyType string
    The type of the Policy.
    UserName string
    The name of the user.
    PolicyName string
    The name of the Policy.
    PolicyType string
    The type of the Policy.
    UserName string
    The name of the user.
    policyName String
    The name of the Policy.
    policyType String
    The type of the Policy.
    userName String
    The name of the user.
    policyName string
    The name of the Policy.
    policyType string
    The type of the Policy.
    userName string
    The name of the user.
    policy_name str
    The name of the Policy.
    policy_type str
    The type of the Policy.
    user_name str
    The name of the user.
    policyName String
    The name of the Policy.
    policyType String
    The type of the Policy.
    userName String
    The name of the user.

    Import

    Iam user policy attachment can be imported using the UserName:PolicyName:PolicyType, e.g.

     $ pulumi import volcengine:iam/userPolicyAttachment:UserPolicyAttachment default TerraformTestUser:TerraformTestPolicy:Custom
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    volcengine volcengine/pulumi-volcengine
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the volcengine Terraform Provider.
    volcengine logo
    Volcengine v0.0.24 published on Tuesday, Jun 25, 2024 by Volcengine