ALIYUN::RAM::Role类型用于创建RAM角色。
语法
{
"Type": "ALIYUN::RAM::Role",
"Properties": {
"RoleName": String,
"Description": String,
"AssumeRolePolicyDocument": Map,
"MaxSessionDuration": Integer,
"Policies": List
}
}
属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
---|---|---|---|---|---|
RoleName | String | 是 | 否 | RAM角色名称。 | 最大长度为64个字符,可包含英文字母、数字、英文句点(.)、下划线(_)和短划线(-)。 |
Description | String | 否 | 否 | RAM角色描述。 | 最大长度为1024个字符。 |
AssumeRolePolicyDocument | Map | 是 | 是 | 可以扮演此RAM角色的身份。 | 更多信息,请参见AssumeRolePolicyDocument属性。 |
MaxSessionDuration | Integer | 否 | 是 | RAM角色最大会话时间。 | 取值范围:3600秒~43200秒。
默认值:3600秒。 |
Policies | List | 否 | 是 | 适用RAM角色的策略。 | 更多信息,请参见Policies属性。 |
AssumeRolePolicyDocument语法
"AssumeRolePolicyDocument": {
"Version": String,
"Statement": List
}
AssumeRolePolicyDocument属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
---|---|---|---|---|---|
Version | String | 是 | 否 | 策略版本 | 无 |
Statement | List | 是 | 否 | 策略具体规则 | 无 |
Statement语法
"Statement": [
{
"Condition": Map,
"Action": String,
"Effect": String,
"Principal": Map
}
]
Statement属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
---|---|---|---|---|---|
Condition | Map | 否 | 否 | 限制条件 | 无 |
Action | String | 否 | 否 | 策略针对的具体操作 | 无 |
Effect | String | 否 | 否 | 权限效力 | 取值:
|
Principal | Map | 否 | 否 | 可信实体类型 | 更多信息,请参见Principal属性。 |
Principal语法
"Principal": {
"Service": List,
"Federated": List,
"RAM": List
}
Principal属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
---|---|---|---|---|---|
Service | List | 否 | 否 | 阿里云服务 | 无 |
Federated | List | 否 | 否 | 身份提供商 | 无 |
RAM | List | 否 | 否 | 阿里云账号 | 无 |
Policies语法
"Policies": [
{
"Description": String,
"PolicyName": String,
"PolicyDocument": Map
}
]
Policies属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
---|---|---|---|---|---|
Description | String | 否 | 否 | 描述 | 长度为1~1024个字符。 |
PolicyName | String | 是 | 否 | 权限策略名称 | 长度为1~128个字符,可包含英文字母、数字和短划线(-)。 |
PolicyDocument | Map | 是 | 是 | 权限策略内容 | 最大长度为2048个字符。
更多信息,请参见PolicyDocument属性。 |
PolicyDocument语法
"PolicyDocument": {
"Version": String,
"Statement": List
}
PolicyDocument属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
---|---|---|---|---|---|
Version | String | 否 | 否 | 权限策略版本 | 无 |
Statement | List | 否 | 否 | 权限策略具体规则 | 无 |
Statement语法
"Statement": [
{
"Condition": Map,
"Action": List,
"Resource": List,
"Effect": String
}
]
Statement属性
属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 |
---|---|---|---|---|---|
Condition | Map | 否 | 否 | 授权生效的限制条件。 | 无 |
Action | List | 否 | 否 | 权限策略针对的具体操作。 | 无 |
Resource | List | 否 | 否 | 权限策略针对的具体资源。 | 无 |
Effect | String | 否 | 否 | 授权效力。 | 取值:
|
返回值
Fn::GetAtt
- RoleId:角色ID。
- RoleName:角色名称。
- Arn:角色的资源描述符。
示例
JSON
格式
{
"ROSTemplateFormatVersion": "2015-09-01",
"Parameters": {
"RoleName": {
"Type": "String",
"Description": "Specifies the role name, containing up to 64 characters."
},
"Description": {
"Type": "String",
"Description": "Remark information, up to 1024 characters or Chinese characters.",
"MaxLength": 1024
},
"Policies": {
"Type": "Json",
"Description": "Describes what actions are allowed on what resources."
},
"MaxSessionDuration": {
"Type": "Number",
"Description": "The maximum session duration of the RAM role.\nValid values: 3600 to 43200. Unit: seconds. Default value: 3600.\nThe default value is used if the parameter is not specified.",
"MinValue": 3600,
"MaxValue": 43200
},
"AssumeRolePolicyDocument": {
"Type": "Json",
"Description": "The RAM assume role policy that is associated with this role."
}
},
"Resources": {
"Role": {
"Type": "ALIYUN::RAM::Role",
"Properties": {
"RoleName": {
"Ref": "RoleName"
},
"Description": {
"Ref": "Description"
},
"Policies": {
"Ref": "Policies"
},
"MaxSessionDuration": {
"Ref": "MaxSessionDuration"
},
"AssumeRolePolicyDocument": {
"Ref": "AssumeRolePolicyDocument"
}
}
}
},
"Outputs": {
"RoleName": {
"Description": "Name of ram role.",
"Value": {
"Fn::GetAtt": [
"Role",
"RoleName"
]
}
},
"Arn": {
"Description": "Name of alicloud resource.",
"Value": {
"Fn::GetAtt": [
"Role",
"Arn"
]
}
},
"RoleId": {
"Description": "Id of ram role.",
"Value": {
"Fn::GetAtt": [
"Role",
"RoleId"
]
}
}
}
}
YAML
格式
ROSTemplateFormatVersion: '2015-09-01'
Parameters:
RoleName:
Type: String
Description: 'Specifies the role name, containing up to 64 characters.'
Description:
Type: String
Description: 'Remark information, up to 1024 characters or Chinese characters.'
MaxLength: 1024
Policies:
Type: Json
Description: Describes what actions are allowed on what resources.
MaxSessionDuration:
Type: Number
Description: |-
The maximum session duration of the RAM role.
Valid values: 3600 to 43200. Unit: seconds. Default value: 3600.
The default value is used if the parameter is not specified.
MinValue: 3600
MaxValue: 43200
AssumeRolePolicyDocument:
Type: Json
Description: The RAM assume role policy that is associated with this role.
Resources:
Role:
Type: 'ALIYUN::RAM::Role'
Properties:
RoleName:
Ref: RoleName
Description:
Ref: Description
Policies:
Ref: Policies
MaxSessionDuration:
Ref: MaxSessionDuration
AssumeRolePolicyDocument:
Ref: AssumeRolePolicyDocument
Outputs:
RoleName:
Description: Name of ram role.
Value:
'Fn::GetAtt':
- Role
- RoleName
Arn:
Description: Name of alicloud resource.
Value:
'Fn::GetAtt':
- Role
- Arn
RoleId:
Description: Id of ram role.
Value:
'Fn::GetAtt':
- Role
- RoleId