volcenginecc.iam.Role
角色(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)
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:
- Role
Name string - 角色名,长度1~64,支持英文、数字和.-_符号。
- Description string
- 角色描述,长度不超过128。
- Display
Name string - 角色显示名,长度不超过64。
- Max
Session intDuration - 角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
- Policies
List<Volcengine.
Role Policy> - List<Volcengine.
Role Tag> - Trust
Policy stringDocument - 角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
- Role
Name string - 角色名,长度1~64,支持英文、数字和.-_符号。
- Description string
- 角色描述,长度不超过128。
- Display
Name string - 角色显示名,长度不超过64。
- Max
Session intDuration - 角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
- Policies
[]Role
Policy Args - []Role
Tag Args - Trust
Policy stringDocument - 角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
- role
Name String - 角色名,长度1~64,支持英文、数字和.-_符号。
- description String
- 角色描述,长度不超过128。
- display
Name String - 角色显示名,长度不超过64。
- max
Session IntegerDuration - 角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
- policies
List<Role
Policy> - List<Role
Tag> - trust
Policy StringDocument - 角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
- role
Name string - 角色名,长度1~64,支持英文、数字和.-_符号。
- description string
- 角色描述,长度不超过128。
- display
Name string - 角色显示名,长度不超过64。
- max
Session numberDuration - 角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
- policies
Role
Policy[] - Role
Tag[] - trust
Policy stringDocument - 角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
- role_
name str - 角色名,长度1~64,支持英文、数字和.-_符号。
- description str
- 角色描述,长度不超过128。
- display_
name str - 角色显示名,长度不超过64。
- max_
session_ intduration - 角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
- policies
Sequence[Role
Policy Args] - Sequence[Role
Tag Args] - trust_
policy_ strdocument - 角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
- role
Name String - 角色名,长度1~64,支持英文、数字和.-_符号。
- description String
- 角色描述,长度不超过128。
- display
Name String - 角色显示名,长度不超过64。
- max
Session NumberDuration - 角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
- policies List<Property Map>
- List<Property Map>
- trust
Policy StringDocument - 角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
Outputs
All input properties are implicitly available as output properties. Additionally, the Role resource produces the following output properties:
- Create
Date string - 角色创建时间。
- Id string
- The provider-assigned unique ID for this managed resource.
- Is
Service intLinked Role - 是否是服务关联角色, 0否,1是。
- Role
Id int - 角色ID。
- Trn string
- 角色TRN。
- Update
Date string - 角色更新时间。
- Create
Date string - 角色创建时间。
- Id string
- The provider-assigned unique ID for this managed resource.
- Is
Service intLinked Role - 是否是服务关联角色, 0否,1是。
- Role
Id int - 角色ID。
- Trn string
- 角色TRN。
- Update
Date string - 角色更新时间。
- create
Date String - 角色创建时间。
- id String
- The provider-assigned unique ID for this managed resource.
- is
Service IntegerLinked Role - 是否是服务关联角色, 0否,1是。
- role
Id Integer - 角色ID。
- trn String
- 角色TRN。
- update
Date String - 角色更新时间。
- create
Date string - 角色创建时间。
- id string
- The provider-assigned unique ID for this managed resource.
- is
Service numberLinked Role - 是否是服务关联角色, 0否,1是。
- role
Id number - 角色ID。
- trn string
- 角色TRN。
- update
Date string - 角色更新时间。
- create_
date str - 角色创建时间。
- id str
- The provider-assigned unique ID for this managed resource.
- is_
service_ intlinked_ role - 是否是服务关联角色, 0否,1是。
- role_
id int - 角色ID。
- trn str
- 角色TRN。
- update_
date str - 角色更新时间。
- create
Date String - 角色创建时间。
- id String
- The provider-assigned unique ID for this managed resource.
- is
Service NumberLinked Role - 是否是服务关联角色, 0否,1是。
- role
Id Number - 角色ID。
- trn String
- 角色TRN。
- update
Date 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.
- Create
Date string - 角色创建时间。
- Description string
- 角色描述,长度不超过128。
- Display
Name string - 角色显示名,长度不超过64。
- Is
Service intLinked Role - 是否是服务关联角色, 0否,1是。
- Max
Session intDuration - 角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
- Policies
List<Volcengine.
Role Policy> - Role
Id int - 角色ID。
- Role
Name string - 角色名,长度1~64,支持英文、数字和.-_符号。
- List<Volcengine.
Role Tag> - Trn string
- 角色TRN。
- Trust
Policy stringDocument - 角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
- Update
Date string - 角色更新时间。
- Create
Date string - 角色创建时间。
- Description string
- 角色描述,长度不超过128。
- Display
Name string - 角色显示名,长度不超过64。
- Is
Service intLinked Role - 是否是服务关联角色, 0否,1是。
- Max
Session intDuration - 角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
- Policies
[]Role
Policy Args - Role
Id int - 角色ID。
- Role
Name string - 角色名,长度1~64,支持英文、数字和.-_符号。
- []Role
Tag Args - Trn string
- 角色TRN。
- Trust
Policy stringDocument - 角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
- Update
Date string - 角色更新时间。
- create
Date String - 角色创建时间。
- description String
- 角色描述,长度不超过128。
- display
Name String - 角色显示名,长度不超过64。
- is
Service IntegerLinked Role - 是否是服务关联角色, 0否,1是。
- max
Session IntegerDuration - 角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
- policies
List<Role
Policy> - role
Id Integer - 角色ID。
- role
Name String - 角色名,长度1~64,支持英文、数字和.-_符号。
- List<Role
Tag> - trn String
- 角色TRN。
- trust
Policy StringDocument - 角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
- update
Date String - 角色更新时间。
- create
Date string - 角色创建时间。
- description string
- 角色描述,长度不超过128。
- display
Name string - 角色显示名,长度不超过64。
- is
Service numberLinked Role - 是否是服务关联角色, 0否,1是。
- max
Session numberDuration - 角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
- policies
Role
Policy[] - role
Id number - 角色ID。
- role
Name string - 角色名,长度1~64,支持英文、数字和.-_符号。
- Role
Tag[] - trn string
- 角色TRN。
- trust
Policy stringDocument - 角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
- update
Date string - 角色更新时间。
- create_
date str - 角色创建时间。
- description str
- 角色描述,长度不超过128。
- display_
name str - 角色显示名,长度不超过64。
- is_
service_ intlinked_ role - 是否是服务关联角色, 0否,1是。
- max_
session_ intduration - 角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
- policies
Sequence[Role
Policy Args] - role_
id int - 角色ID。
- role_
name str - 角色名,长度1~64,支持英文、数字和.-_符号。
- Sequence[Role
Tag Args] - trn str
- 角色TRN。
- trust_
policy_ strdocument - 角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
- update_
date str - 角色更新时间。
- create
Date String - 角色创建时间。
- description String
- 角色描述,长度不超过128。
- display
Name String - 角色显示名,长度不超过64。
- is
Service NumberLinked Role - 是否是服务关联角色, 0否,1是。
- max
Session NumberDuration - 角色最大会话时间,角色最大会话时间。用于限制角色扮演产生的临时安全凭证的有效期的最大范围。取值范围:3600~43200,单位为秒,默认为43200。
- policies List<Property Map>
- role
Id Number - 角色ID。
- role
Name String - 角色名,长度1~64,支持英文、数字和.-_符号。
- List<Property Map>
- trn String
- 角色TRN。
- trust
Policy StringDocument - 角色信任策略,信任策略遵循IAM的策略语法中基于资源的策略规则。
- update
Date String - 角色更新时间。
Supporting Types
RolePolicy, RolePolicyArgs
- Policy
Name string - 策略名。
- Policy
Type string - 策略类型,策略类型。System代表系统预设策略,Custom代表自定义策略。
- Policy
Name string - 策略名。
- Policy
Type string - 策略类型,策略类型。System代表系统预设策略,Custom代表自定义策略。
- policy
Name String - 策略名。
- policy
Type String - 策略类型,策略类型。System代表系统预设策略,Custom代表自定义策略。
- policy
Name string - 策略名。
- policy
Type string - 策略类型,策略类型。System代表系统预设策略,Custom代表自定义策略。
- policy_
name str - 策略名。
- policy_
type str - 策略类型,策略类型。System代表系统预设策略,Custom代表自定义策略。
- policy
Name String - 策略名。
- policy
Type String - 策略类型,策略类型。System代表系统预设策略,Custom代表自定义策略。
RoleTag, RoleTagArgs
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.