1. Packages
  2. Volcengine
  3. API Docs
  4. iam
  5. RolePolicyAttachment
Volcengine v0.0.26 published on Friday, Sep 13, 2024 by Volcengine

volcengine.iam.RolePolicyAttachment

Explore with Pulumi AI

volcengine logo
Volcengine v0.0.26 published on Friday, Sep 13, 2024 by Volcengine

    Provides a resource to manage iam role policy attachment

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Volcengine = Pulumi.Volcengine;
    
    return await Deployment.RunAsync(() => 
    {
        var role = new Volcengine.Iam.Role("role", new()
        {
            RoleName = "TerraformTestRole",
            DisplayName = "terraform role",
            TrustPolicyDocument = "{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"sts:AssumeRole\"],\"Principal\":{\"Service\":[\"auto_scaling\"]}}]}",
            Description = "created by terraform",
            MaxSessionDuration = 43200,
        });
    
        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.RolePolicyAttachment("foo", new()
        {
            RoleName = role.Id,
            PolicyName = policy.Id,
            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 {
    		role, err := iam.NewRole(ctx, "role", &iam.RoleArgs{
    			RoleName:            pulumi.String("TerraformTestRole"),
    			DisplayName:         pulumi.String("terraform role"),
    			TrustPolicyDocument: pulumi.String("{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"sts:AssumeRole\"],\"Principal\":{\"Service\":[\"auto_scaling\"]}}]}"),
    			Description:         pulumi.String("created by terraform"),
    			MaxSessionDuration:  pulumi.Int(43200),
    		})
    		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.NewRolePolicyAttachment(ctx, "foo", &iam.RolePolicyAttachmentArgs{
    			RoleName:   role.ID(),
    			PolicyName: policy.ID(),
    			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.Role;
    import com.pulumi.volcengine.iam.RoleArgs;
    import com.pulumi.volcengine.iam.Policy;
    import com.pulumi.volcengine.iam.PolicyArgs;
    import com.pulumi.volcengine.iam.RolePolicyAttachment;
    import com.pulumi.volcengine.iam.RolePolicyAttachmentArgs;
    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 role = new Role("role", RoleArgs.builder()        
                .roleName("TerraformTestRole")
                .displayName("terraform role")
                .trustPolicyDocument("{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"sts:AssumeRole\"],\"Principal\":{\"Service\":[\"auto_scaling\"]}}]}")
                .description("created by terraform")
                .maxSessionDuration(43200)
                .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 RolePolicyAttachment("foo", RolePolicyAttachmentArgs.builder()        
                .roleName(role.id())
                .policyName(policy.id())
                .policyType(policy.policyType())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_volcengine as volcengine
    
    role = volcengine.iam.Role("role",
        role_name="TerraformTestRole",
        display_name="terraform role",
        trust_policy_document="{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"sts:AssumeRole\"],\"Principal\":{\"Service\":[\"auto_scaling\"]}}]}",
        description="created by terraform",
        max_session_duration=43200)
    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.RolePolicyAttachment("foo",
        role_name=role.id,
        policy_name=policy.id,
        policy_type=policy.policy_type)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as volcengine from "@volcengine/pulumi";
    
    const role = new volcengine.iam.Role("role", {
        roleName: "TerraformTestRole",
        displayName: "terraform role",
        trustPolicyDocument: "{\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"sts:AssumeRole\"],\"Principal\":{\"Service\":[\"auto_scaling\"]}}]}",
        description: "created by terraform",
        maxSessionDuration: 43200,
    });
    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.RolePolicyAttachment("foo", {
        roleName: role.id,
        policyName: policy.id,
        policyType: policy.policyType,
    });
    
    resources:
      role:
        type: volcengine:iam:Role
        properties:
          roleName: TerraformTestRole
          displayName: terraform role
          trustPolicyDocument: '{"Statement":[{"Effect":"Allow","Action":["sts:AssumeRole"],"Principal":{"Service":["auto_scaling"]}}]}'
          description: created by terraform
          maxSessionDuration: 43200
      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:RolePolicyAttachment
        properties:
          roleName: ${role.id}
          policyName: ${policy.id}
          policyType: ${policy.policyType}
    

    Create RolePolicyAttachment Resource

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

    Constructor syntax

    new RolePolicyAttachment(name: string, args: RolePolicyAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def RolePolicyAttachment(resource_name: str,
                             args: RolePolicyAttachmentArgs,
                             opts: Optional[ResourceOptions] = None)
    
    @overload
    def RolePolicyAttachment(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             policy_name: Optional[str] = None,
                             policy_type: Optional[str] = None,
                             role_name: Optional[str] = None)
    func NewRolePolicyAttachment(ctx *Context, name string, args RolePolicyAttachmentArgs, opts ...ResourceOption) (*RolePolicyAttachment, error)
    public RolePolicyAttachment(string name, RolePolicyAttachmentArgs args, CustomResourceOptions? opts = null)
    public RolePolicyAttachment(String name, RolePolicyAttachmentArgs args)
    public RolePolicyAttachment(String name, RolePolicyAttachmentArgs args, CustomResourceOptions options)
    
    type: volcengine:iam:RolePolicyAttachment
    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 RolePolicyAttachmentArgs
    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 RolePolicyAttachmentArgs
    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 RolePolicyAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RolePolicyAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RolePolicyAttachmentArgs
    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 rolePolicyAttachmentResource = new Volcengine.Iam.RolePolicyAttachment("rolePolicyAttachmentResource", new()
    {
        PolicyName = "string",
        PolicyType = "string",
        RoleName = "string",
    });
    
    example, err := iam.NewRolePolicyAttachment(ctx, "rolePolicyAttachmentResource", &iam.RolePolicyAttachmentArgs{
    	PolicyName: pulumi.String("string"),
    	PolicyType: pulumi.String("string"),
    	RoleName:   pulumi.String("string"),
    })
    
    var rolePolicyAttachmentResource = new RolePolicyAttachment("rolePolicyAttachmentResource", RolePolicyAttachmentArgs.builder()
        .policyName("string")
        .policyType("string")
        .roleName("string")
        .build());
    
    role_policy_attachment_resource = volcengine.iam.RolePolicyAttachment("rolePolicyAttachmentResource",
        policy_name="string",
        policy_type="string",
        role_name="string")
    
    const rolePolicyAttachmentResource = new volcengine.iam.RolePolicyAttachment("rolePolicyAttachmentResource", {
        policyName: "string",
        policyType: "string",
        roleName: "string",
    });
    
    type: volcengine:iam:RolePolicyAttachment
    properties:
        policyName: string
        policyType: string
        roleName: string
    

    RolePolicyAttachment Resource Properties

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

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The RolePolicyAttachment resource accepts the following input properties:

    PolicyName string
    The name of the Policy.
    PolicyType string
    The type of the Policy.
    RoleName string
    The name of the Role.
    PolicyName string
    The name of the Policy.
    PolicyType string
    The type of the Policy.
    RoleName string
    The name of the Role.
    policyName String
    The name of the Policy.
    policyType String
    The type of the Policy.
    roleName String
    The name of the Role.
    policyName string
    The name of the Policy.
    policyType string
    The type of the Policy.
    roleName string
    The name of the Role.
    policy_name str
    The name of the Policy.
    policy_type str
    The type of the Policy.
    role_name str
    The name of the Role.
    policyName String
    The name of the Policy.
    policyType String
    The type of the Policy.
    roleName String
    The name of the Role.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the RolePolicyAttachment 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 RolePolicyAttachment Resource

    Get an existing RolePolicyAttachment 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?: RolePolicyAttachmentState, opts?: CustomResourceOptions): RolePolicyAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            policy_name: Optional[str] = None,
            policy_type: Optional[str] = None,
            role_name: Optional[str] = None) -> RolePolicyAttachment
    func GetRolePolicyAttachment(ctx *Context, name string, id IDInput, state *RolePolicyAttachmentState, opts ...ResourceOption) (*RolePolicyAttachment, error)
    public static RolePolicyAttachment Get(string name, Input<string> id, RolePolicyAttachmentState? state, CustomResourceOptions? opts = null)
    public static RolePolicyAttachment get(String name, Output<String> id, RolePolicyAttachmentState 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.
    RoleName string
    The name of the Role.
    PolicyName string
    The name of the Policy.
    PolicyType string
    The type of the Policy.
    RoleName string
    The name of the Role.
    policyName String
    The name of the Policy.
    policyType String
    The type of the Policy.
    roleName String
    The name of the Role.
    policyName string
    The name of the Policy.
    policyType string
    The type of the Policy.
    roleName string
    The name of the Role.
    policy_name str
    The name of the Policy.
    policy_type str
    The type of the Policy.
    role_name str
    The name of the Role.
    policyName String
    The name of the Policy.
    policyType String
    The type of the Policy.
    roleName String
    The name of the Role.

    Import

    Iam role policy attachment can be imported using the id, e.g.

     $ pulumi import volcengine:iam/rolePolicyAttachment:RolePolicyAttachment default TerraformTestRole: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.26 published on Friday, Sep 13, 2024 by Volcengine