1. Packages
  2. Volcenginecc Provider
  3. API Docs
  4. iam
  5. Role
volcenginecc v0.0.2 published on Saturday, Oct 11, 2025 by Volcengine

volcenginecc.iam.Role

Deploy with Pulumi
volcenginecc logo
volcenginecc v0.0.2 published on Saturday, Oct 11, 2025 by Volcengine

    角色(Role)是IAM体系里的一种虚拟身份,用于将账号内某些访问权限授予给各类身份实体,受信任的身份实体可扮演该角色来访问账号内的云资源。

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as volcenginecc from "@volcengine/pulumi-volcenginecc";
    
    const roleDemo = new volcenginecc.iam.Role("RoleDemo", {
        roleName: "RoleDemo",
        description: "role attach policies",
        maxSessionDuration: 3600,
        trustPolicyDocument: `{
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "sts:AssumeRole"
                ],
                "Principal": {
                    "IAM": [
                        "trn:iam::20000000xx:root"
                    ]
                }
            }
        ]
    }`,
        tags: [{
            key: "env",
            value: "test",
        }],
    });
    
    import pulumi
    import pulumi_volcenginecc as volcenginecc
    
    role_demo = volcenginecc.iam.Role("RoleDemo",
        role_name="RoleDemo",
        description="role attach policies",
        max_session_duration=3600,
        trust_policy_document="""{
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "sts:AssumeRole"
                ],
                "Principal": {
                    "IAM": [
                        "trn:iam::20000000xx:root"
                    ]
                }
            }
        ]
    }""",
        tags=[{
            "key": "env",
            "value": "test",
        }])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/volcengine/pulumi-volcenginecc/sdk/go/volcenginecc/iam"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := iam.NewRole(ctx, "RoleDemo", &iam.RoleArgs{
    			RoleName:           pulumi.String("RoleDemo"),
    			Description:        pulumi.String("role attach policies"),
    			MaxSessionDuration: pulumi.Int(3600),
    			TrustPolicyDocument: pulumi.String(`{
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "sts:AssumeRole"
                ],
                "Principal": {
                    "IAM": [
                        "trn:iam::20000000xx:root"
                    ]
                }
            }
        ]
    }`),
    			Tags: iam.RoleTagArray{
    				&iam.RoleTagArgs{
    					Key:   pulumi.String("env"),
    					Value: pulumi.String("test"),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Volcenginecc = Volcengine.Pulumi.Volcenginecc;
    
    return await Deployment.RunAsync(() => 
    {
        var roleDemo = new Volcenginecc.Iam.Role("RoleDemo", new()
        {
            RoleName = "RoleDemo",
            Description = "role attach policies",
            MaxSessionDuration = 3600,
            TrustPolicyDocument = @"{
        ""Statement"": [
            {
                ""Effect"": ""Allow"",
                ""Action"": [
                    ""sts:AssumeRole""
                ],
                ""Principal"": {
                    ""IAM"": [
                        ""trn:iam::20000000xx:root""
                    ]
                }
            }
        ]
    }",
            Tags = new[]
            {
                new Volcenginecc.Iam.Inputs.RoleTagArgs
                {
                    Key = "env",
                    Value = "test",
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.volcengine.volcenginecc.iam.Role;
    import com.volcengine.volcenginecc.iam.RoleArgs;
    import com.pulumi.volcenginecc.iam.inputs.RoleTagArgs;
    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 roleDemo = new Role("roleDemo", RoleArgs.builder()
                .roleName("RoleDemo")
                .description("role attach policies")
                .maxSessionDuration(3600)
                .trustPolicyDocument("""
    {
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "sts:AssumeRole"
                ],
                "Principal": {
                    "IAM": [
                        "trn:iam::20000000xx:root"
                    ]
                }
            }
        ]
    }            """)
                .tags(RoleTagArgs.builder()
                    .key("env")
                    .value("test")
                    .build())
                .build());
    
        }
    }
    
    resources:
      roleDemo:
        type: volcenginecc:iam:Role
        name: RoleDemo
        properties:
          roleName: RoleDemo
          description: role attach policies
          maxSessionDuration: 3600
          trustPolicyDocument: |-
            {
                "Statement": [
                    {
                        "Effect": "Allow",
                        "Action": [
                            "sts:AssumeRole"
                        ],
                        "Principal": {
                            "IAM": [
                                "trn:iam::20000000xx:root"
                            ]
                        }
                    }
                ]
            }        
          tags:
            - key: env
              value: test
    

    Create Role Resource

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

    Constructor syntax

    new Role(name: string, args: RoleArgs, opts?: CustomResourceOptions);
    @overload
    def Role(resource_name: str,
             args: RoleArgs,
             opts: Optional[ResourceOptions] = None)
    
    @overload
    def Role(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             role_name: Optional[str] = None,
             description: Optional[str] = None,
             display_name: Optional[str] = None,
             max_session_duration: Optional[int] = None,
             policies: Optional[Sequence[RolePolicyArgs]] = None,
             tags: Optional[Sequence[RoleTagArgs]] = None,
             trust_policy_document: Optional[str] = None)
    func NewRole(ctx *Context, name string, args RoleArgs, opts ...ResourceOption) (*Role, error)
    public Role(string name, RoleArgs args, CustomResourceOptions? opts = null)
    public Role(String name, RoleArgs args)
    public Role(String name, RoleArgs args, CustomResourceOptions options)
    
    type: volcenginecc:iam:Role
    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 RoleArgs
    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 RoleArgs
    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 RoleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RoleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RoleArgs
    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 roleResource = new Volcenginecc.Iam.Role("roleResource", new()
    {
        RoleName = "string",
        Description = "string",
        DisplayName = "string",
        MaxSessionDuration = 0,
        Policies = new[]
        {
            new Volcenginecc.Iam.Inputs.RolePolicyArgs
            {
                PolicyName = "string",
                PolicyType = "string",
            },
        },
        Tags = new[]
        {
            new Volcenginecc.Iam.Inputs.RoleTagArgs
            {
                Key = "string",
                Value = "string",
            },
        },
        TrustPolicyDocument = "string",
    });
    
    example, err := iam.NewRole(ctx, "roleResource", &iam.RoleArgs{
    	RoleName:           pulumi.String("string"),
    	Description:        pulumi.String("string"),
    	DisplayName:        pulumi.String("string"),
    	MaxSessionDuration: pulumi.Int(0),
    	Policies: iam.RolePolicyArray{
    		&iam.RolePolicyArgs{
    			PolicyName: pulumi.String("string"),
    			PolicyType: pulumi.String("string"),
    		},
    	},
    	Tags: iam.RoleTagArray{
    		&iam.RoleTagArgs{
    			Key:   pulumi.String("string"),
    			Value: pulumi.String("string"),
    		},
    	},
    	TrustPolicyDocument: pulumi.String("string"),
    })
    
    var roleResource = new Role("roleResource", RoleArgs.builder()
        .roleName("string")
        .description("string")
        .displayName("string")
        .maxSessionDuration(0)
        .policies(RolePolicyArgs.builder()
            .policyName("string")
            .policyType("string")
            .build())
        .tags(RoleTagArgs.builder()
            .key("string")
            .value("string")
            .build())
        .trustPolicyDocument("string")
        .build());
    
    role_resource = volcenginecc.iam.Role("roleResource",
        role_name="string",
        description="string",
        display_name="string",
        max_session_duration=0,
        policies=[{
            "policy_name": "string",
            "policy_type": "string",
        }],
        tags=[{
            "key": "string",
            "value": "string",
        }],
        trust_policy_document="string")
    
    const roleResource = new volcenginecc.iam.Role("roleResource", {
        roleName: "string",
        description: "string",
        displayName: "string",
        maxSessionDuration: 0,
        policies: [{
            policyName: "string",
            policyType: "string",
        }],
        tags: [{
            key: "string",
            value: "string",
        }],
        trustPolicyDocument: "string",
    });
    
    type: volcenginecc:iam:Role
    properties:
        description: string
        displayName: string
        maxSessionDuration: 0
        policies:
            - policyName: string
              policyType: string
        roleName: string
        tags:
            - key: string
              value: string
        trustPolicyDocument: string
    

    Role 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 Role resource accepts the following input properties:

    RoleName string
    角色名,长度1~64,支持英文、数字和.-_符号。
    Description string
    角色描述,长度不超过128。
    DisplayName string
    角色显示名,长度不超过64。
    MaxSessionDuration int
    角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
    Policies List<Volcengine.RolePolicy>
    Tags List<Volcengine.RoleTag>
    TrustPolicyDocument string
    角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
    RoleName string
    角色名,长度1~64,支持英文、数字和.-_符号。
    Description string
    角色描述,长度不超过128。
    DisplayName string
    角色显示名,长度不超过64。
    MaxSessionDuration int
    角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
    Policies []RolePolicyArgs
    Tags []RoleTagArgs
    TrustPolicyDocument string
    角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
    roleName String
    角色名,长度1~64,支持英文、数字和.-_符号。
    description String
    角色描述,长度不超过128。
    displayName String
    角色显示名,长度不超过64。
    maxSessionDuration Integer
    角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
    policies List<RolePolicy>
    tags List<RoleTag>
    trustPolicyDocument String
    角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
    roleName string
    角色名,长度1~64,支持英文、数字和.-_符号。
    description string
    角色描述,长度不超过128。
    displayName string
    角色显示名,长度不超过64。
    maxSessionDuration number
    角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
    policies RolePolicy[]
    tags RoleTag[]
    trustPolicyDocument string
    角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
    role_name str
    角色名,长度1~64,支持英文、数字和.-_符号。
    description str
    角色描述,长度不超过128。
    display_name str
    角色显示名,长度不超过64。
    max_session_duration int
    角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
    policies Sequence[RolePolicyArgs]
    tags Sequence[RoleTagArgs]
    trust_policy_document str
    角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
    roleName String
    角色名,长度1~64,支持英文、数字和.-_符号。
    description String
    角色描述,长度不超过128。
    displayName String
    角色显示名,长度不超过64。
    maxSessionDuration Number
    角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
    policies List<Property Map>
    tags List<Property Map>
    trustPolicyDocument String
    角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。

    Outputs

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

    CreateDate string
    角色创建时间。
    Id string
    The provider-assigned unique ID for this managed resource.
    IsServiceLinkedRole int
    是否是服务关联角色, 0否,1是。
    RoleId int
    角色ID。
    Trn string
    角色TRN。
    UpdateDate string
    角色更新时间。
    CreateDate string
    角色创建时间。
    Id string
    The provider-assigned unique ID for this managed resource.
    IsServiceLinkedRole int
    是否是服务关联角色, 0否,1是。
    RoleId int
    角色ID。
    Trn string
    角色TRN。
    UpdateDate string
    角色更新时间。
    createDate String
    角色创建时间。
    id String
    The provider-assigned unique ID for this managed resource.
    isServiceLinkedRole Integer
    是否是服务关联角色, 0否,1是。
    roleId Integer
    角色ID。
    trn String
    角色TRN。
    updateDate String
    角色更新时间。
    createDate string
    角色创建时间。
    id string
    The provider-assigned unique ID for this managed resource.
    isServiceLinkedRole number
    是否是服务关联角色, 0否,1是。
    roleId number
    角色ID。
    trn string
    角色TRN。
    updateDate string
    角色更新时间。
    create_date str
    角色创建时间。
    id str
    The provider-assigned unique ID for this managed resource.
    is_service_linked_role int
    是否是服务关联角色, 0否,1是。
    role_id int
    角色ID。
    trn str
    角色TRN。
    update_date str
    角色更新时间。
    createDate String
    角色创建时间。
    id String
    The provider-assigned unique ID for this managed resource.
    isServiceLinkedRole Number
    是否是服务关联角色, 0否,1是。
    roleId Number
    角色ID。
    trn String
    角色TRN。
    updateDate String
    角色更新时间。

    Look up Existing Role Resource

    Get an existing Role 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?: RoleState, opts?: CustomResourceOptions): Role
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            create_date: Optional[str] = None,
            description: Optional[str] = None,
            display_name: Optional[str] = None,
            is_service_linked_role: Optional[int] = None,
            max_session_duration: Optional[int] = None,
            policies: Optional[Sequence[RolePolicyArgs]] = None,
            role_id: Optional[int] = None,
            role_name: Optional[str] = None,
            tags: Optional[Sequence[RoleTagArgs]] = None,
            trn: Optional[str] = None,
            trust_policy_document: Optional[str] = None,
            update_date: Optional[str] = None) -> Role
    func GetRole(ctx *Context, name string, id IDInput, state *RoleState, opts ...ResourceOption) (*Role, error)
    public static Role Get(string name, Input<string> id, RoleState? state, CustomResourceOptions? opts = null)
    public static Role get(String name, Output<String> id, RoleState state, CustomResourceOptions options)
    resources:  _:    type: volcenginecc:iam:Role    get:      id: ${id}
    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:
    CreateDate string
    角色创建时间。
    Description string
    角色描述,长度不超过128。
    DisplayName string
    角色显示名,长度不超过64。
    IsServiceLinkedRole int
    是否是服务关联角色, 0否,1是。
    MaxSessionDuration int
    角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
    Policies List<Volcengine.RolePolicy>
    RoleId int
    角色ID。
    RoleName string
    角色名,长度1~64,支持英文、数字和.-_符号。
    Tags List<Volcengine.RoleTag>
    Trn string
    角色TRN。
    TrustPolicyDocument string
    角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
    UpdateDate string
    角色更新时间。
    CreateDate string
    角色创建时间。
    Description string
    角色描述,长度不超过128。
    DisplayName string
    角色显示名,长度不超过64。
    IsServiceLinkedRole int
    是否是服务关联角色, 0否,1是。
    MaxSessionDuration int
    角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
    Policies []RolePolicyArgs
    RoleId int
    角色ID。
    RoleName string
    角色名,长度1~64,支持英文、数字和.-_符号。
    Tags []RoleTagArgs
    Trn string
    角色TRN。
    TrustPolicyDocument string
    角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
    UpdateDate string
    角色更新时间。
    createDate String
    角色创建时间。
    description String
    角色描述,长度不超过128。
    displayName String
    角色显示名,长度不超过64。
    isServiceLinkedRole Integer
    是否是服务关联角色, 0否,1是。
    maxSessionDuration Integer
    角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
    policies List<RolePolicy>
    roleId Integer
    角色ID。
    roleName String
    角色名,长度1~64,支持英文、数字和.-_符号。
    tags List<RoleTag>
    trn String
    角色TRN。
    trustPolicyDocument String
    角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
    updateDate String
    角色更新时间。
    createDate string
    角色创建时间。
    description string
    角色描述,长度不超过128。
    displayName string
    角色显示名,长度不超过64。
    isServiceLinkedRole number
    是否是服务关联角色, 0否,1是。
    maxSessionDuration number
    角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
    policies RolePolicy[]
    roleId number
    角色ID。
    roleName string
    角色名,长度1~64,支持英文、数字和.-_符号。
    tags RoleTag[]
    trn string
    角色TRN。
    trustPolicyDocument string
    角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
    updateDate string
    角色更新时间。
    create_date str
    角色创建时间。
    description str
    角色描述,长度不超过128。
    display_name str
    角色显示名,长度不超过64。
    is_service_linked_role int
    是否是服务关联角色, 0否,1是。
    max_session_duration int
    角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
    policies Sequence[RolePolicyArgs]
    role_id int
    角色ID。
    role_name str
    角色名,长度1~64,支持英文、数字和.-_符号。
    tags Sequence[RoleTagArgs]
    trn str
    角色TRN。
    trust_policy_document str
    角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
    update_date str
    角色更新时间。
    createDate String
    角色创建时间。
    description String
    角色描述,长度不超过128。
    displayName String
    角色显示名,长度不超过64。
    isServiceLinkedRole Number
    是否是服务关联角色, 0否,1是。
    maxSessionDuration Number
    角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
    policies List<Property Map>
    roleId Number
    角色ID。
    roleName String
    角色名,长度1~64,支持英文、数字和.-_符号。
    tags List<Property Map>
    trn String
    角色TRN。
    trustPolicyDocument String
    角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
    updateDate String
    角色更新时间。

    Supporting Types

    RolePolicy, RolePolicyArgs

    PolicyName string
    策略名。
    PolicyType string
    策略类型,策略类型。System代表系统预设策略,Custom代表自定义策略。
    PolicyName string
    策略名。
    PolicyType string
    策略类型,策略类型。System代表系统预设策略,Custom代表自定义策略。
    policyName String
    策略名。
    policyType String
    策略类型,策略类型。System代表系统预设策略,Custom代表自定义策略。
    policyName string
    策略名。
    policyType string
    策略类型,策略类型。System代表系统预设策略,Custom代表自定义策略。
    policy_name str
    策略名。
    policy_type str
    策略类型,策略类型。System代表系统预设策略,Custom代表自定义策略。
    policyName String
    策略名。
    policyType String
    策略类型,策略类型。System代表系统预设策略,Custom代表自定义策略。

    RoleTag, RoleTagArgs

    Key string
    标签键。
    Value string
    标签值。
    Key string
    标签键。
    Value string
    标签值。
    key String
    标签键。
    value String
    标签值。
    key string
    标签键。
    value string
    标签值。
    key str
    标签键。
    value str
    标签值。
    key String
    标签键。
    value String
    标签值。

    Import

    $ pulumi import volcenginecc:iam/role:Role example "role_name"
    

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

    Package Details

    Repository
    volcenginecc volcengine/pulumi-volcenginecc
    License
    MPL-2.0
    Notes
    This Pulumi package is based on the volcenginecc Terraform Provider.
    volcenginecc logo
    volcenginecc v0.0.2 published on Saturday, Oct 11, 2025 by Volcengine
      Meet Neo: Your AI Platform Teammate