ALIYUN::RAM::Role リソースは、RAM ロールを作成します。
構文
{
"Type": "ALIYUN::RAM::Role",
"Properties": {
"RoleName": String,
"Description": String,
"AssumeRolePolicyDocument": Map,
"MaxSessionDuration": Integer,
"Policies": List,
"IgnoreExisting": Boolean,
"DeletionForce": Boolean,
"PolicyAttachments": Map
}
}プロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
AssumeRolePolicyDocument | Map | はい | はい | この RAM ロールを偽装できる ID | 信頼ポリシー。この RAM ロールを偽装できる 1 つ以上の信頼できるエンティティを指定します。このエンティティは、Alibaba Cloud アカウント、Alibaba Cloud サービス、または ID プロバイダーのいずれかになります。 |
RoleName | String | はい | いいえ | RAM ロール名です。 | 長さ:1~64 文字。英字、数字、ピリオド (.)、ハイフン (-) を使用できます。 |
Description | String | いいえ | いいえ | RAM ロールの説明です。 | 最大長:1024 文字。 |
MaxSessionDuration | Integer | いいえ | はい | RAM ロールの最大セッション期間です。 | 値の範囲:3600 秒~43200 秒。 デフォルト値:3600 秒。 |
Policies | List | いいえ | はい | RAM ロールに適用されるポリシーです。 | 詳細については、「アクセスポリシーの概要」をご参照ください。 |
IgnoreExisting | Boolean | いいえ | いいえ | 既存のロールを無視するかどうかを指定します。 | 値:
説明 ROS がロールを作成しなかった場合、更新および削除時にそのロールは無視されます。 |
DeletionForce | Boolean | いいえ | はい | ロールに関連付けられたポリシーを強制的にデタッチするかどうかを指定します。 | デフォルト値:false。 |
PolicyAttachments | Map | いいえ | はい | アタッチするシステムポリシーおよびカスタムポリシーの名前です。 | 詳細については、「PolicyAttachments プロパティ」をご参照ください。 |
AssumeRolePolicyDocument の構文
"AssumeRolePolicyDocument": {
"Version": String,
"Statement": List
}AssumeRolePolicyDocument のプロパティ
プロパティ名 | タイプ | 必須 | 更新許可 | 説明 | 制約 |
Version | String | はい | いいえ | ポリシーのバージョンです。 | なし |
Statement | List | はい | いいえ | ポリシーの具体的なルールです。 | 詳細については、「Statement プロパティ」をご参照ください。 |
Statement の構文
"Statement": [
{
"Condition": Map,
"Action": String,
"Effect": String,
"Principal": Map
}
]Statement のプロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
Condition | Map | いいえ | いいえ | 条件です。 | なし |
Action | String | いいえ | いいえ | ポリシーが対象とする具体的な操作です。 | なし |
Effect | String | いいえ | いいえ | 権限の効果です。 | 値:
|
Principal | Map | いいえ | いいえ | 信頼できるエンティティのタイプです。 | 詳細については、「Principal プロパティ」をご参照ください。 |
主な構文
"Principal": {
"Service": List,
"Federated": List,
"RAM": List
}主要なプロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
Service | List | いいえ | いいえ | Alibaba Cloud サービスです。 | なし |
Federated | List | いいえ | いいえ | ID プロバイダーです。 | なし |
RAM | List | いいえ | いいえ | Alibaba Cloud アカウントです。 | なし |
Policies の構文
"Policies": [
{
"Description": String,
"PolicyName": String,
"PolicyDocument": Map
}
]Policies のプロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
Description | String | いいえ | いいえ | 説明です。 | 長さ:1~1024 文字。 |
PolicyName | String | はい | いいえ | アクセスポリシー名です。 | 長さ:1~128 文字。英字、数字、ハイフン (-) を使用できます。 |
PolicyDocument | Map | はい | はい | ポリシードキュメントです。 | 最大長:2048 文字。 詳細については、「PolicyDocument プロパティ」をご参照ください。 |
PolicyAttachments の構文
"PolicyAttachments": {
"System": List,
"Custom": List
}PolicyAttachments のプロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
Custom | List | いいえ | はい | カスタムポリシー名のリストです。 | ポリシー数は 5 以下である必要があります。 |
System | List | いいえ | はい | システムポリシー名のリストです。 | ポリシー数は 20 以下である必要があります。 |
PolicyDocument の構文
"PolicyDocument": {
"Version": String,
"Statement": List
}PolicyDocument のプロパティ
プロパティ名 | タイプ | 必須 | 更新可能 | 説明 | 制約 |
Version | String | はい | いいえ | アクセスポリシーのバージョンです。 | なし |
Statement | List | はい | いいえ | アクセスポリシーの具体的なルールです。 | なし |
戻り値
Fn::GetAtt
RoleId:ロール ID です。
RoleName:ロール名です。
Arn:ロールのリソース記述子です。
例
シナリオ 1:RAM ロールを作成します。
ROSTemplateFormatVersion: '2015-09-01'
Description: Test RAM Role
Parameters: {}
Resources:
Role:
Type: ALIYUN::RAM::Role
Properties:
RoleName: TestRole
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service:
- actiontrail.aliyuncs.com
Version: '1'
Outputs:
RoleId:
Description: Id of ram role.
Value:
Fn::GetAtt:
- Role
- RoleId
Arn:
Description: Name of alicloud resource.
Value:
Fn::GetAtt:
- Role
- Arn
RoleName:
Description: Name of ram role.
Value:
Fn::GetAtt:
- Role
- RoleName{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": "Test RAM Role",
"Parameters": {
},
"Resources": {
"Role": {
"Type": "ALIYUN::RAM::Role",
"Properties": {
"RoleName": "TestRole",
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": [
"actiontrail.aliyuncs.com"
]
}
}
],
"Version": "1"
}
}
}
},
"Outputs": {
"RoleId": {
"Description": "Id of ram role.",
"Value": {
"Fn::GetAtt": [
"Role",
"RoleId"
]
}
},
"Arn": {
"Description": "Name of alicloud resource.",
"Value": {
"Fn::GetAtt": [
"Role",
"Arn"
]
}
},
"RoleName": {
"Description": "Name of ram role.",
"Value": {
"Fn::GetAtt": [
"Role",
"RoleName"
]
}
}
}
}シナリオ 2:RAM ロールを作成し、カスタムポリシーをアタッチして、指定されたサービスがロールを偽装できるようにし、ポリシー操作を定義します。
ROSTemplateFormatVersion: '2015-09-01'
Description:
en: RAM ロールを作成し、指定されたサービスがそのロールを偽装できるようにするカスタムポリシーをアタッチし、ポリシー操作を定義します。
Parameters:
RoleName:
Type: String
Label:
en: ロール名
Description:
en: ロールの名前です。既に存在する場合は名前を変更してください。<br/>英字、数字、または '-' 記号で構成され、64 文字以内である必要があります。
<br/> ConstraintDescription:
<br/> en: 64 文字以内で、英字、数字、または '-' 記号のみ使用できます。
<br/> Default: test-role
<br/> AllowedPattern: ^[a-zA-Z0-9\-]+$
<br/> MinLength: 1
<br/> MaxLength: 64
<br/> AssumeRolePrincipalServices:
<br/> Type: JSON
<br/> Label:
<br/> en: プリンシパルサービス
<br/> Description:
<br/> en: ロールを信頼するサービスを指定します。複数回追加できます。
<br/> Default:
<br/> - ecs.aliyuncs.com
<br/> PolicyName:
<br/> Type: String
<br/> Label:
<br/> en: ポリシー名
<br/> Description:
<br/> en: ポリシーの名前です。既に存在する場合は名前を変更してください。<br/>英字、数字、または '-' 記号で構成され、5~128 文字である必要があります。
<br/> ConstraintDescription:
<br/> en: 英字、数字、または '-' 記号で構成され、5~128 文字である必要があります。
<br/> Default: test-policy-name
<br/> AllowedPattern: ^[a-zA-Z0-9\-]+$
<br/> MinLength: 5
<br/> MaxLength: 128
<br/> SpecificAction:
<br/> Type: String
<br/> Label:
<br/> en: 特定の操作
<br/> Description:
<br/> en: 'ポリシーの特定の操作です。英語のカンマで区切ります。<br/><a href=''https://www.alibabacloud.com/help/document_detail/93738.html'' target=''_blank''><b><font color=''blue''>ポリシー要素の表示 - 操作</font></font></a><br>例:<br>[oss.*,ecs.*: <font color=''green''>oss および ecs のすべての操作</font>]<br>[oss.*: <font color=''green''>oss のすべての操作</font>]<br>[oss.GetObjectUrl: <font color=''green''>oss の GetObjectUrl 操作</font>]<br>。'
<br/> Default: oss.*,ecs.*
<br/>Resources:
<br/> RamManagedPolicy:
<br/> Type: ALIYUN::RAM::ManagedPolicy
<br/> Properties:
<br/> PolicyDocument:
<br/> Statement:
<br/> - Action:
<br/> Fn::Split:
<br/> - ','
<br/> - Ref: SpecificAction
<br/> Effect: Allow
<br/> Resource:
<br/> - '*'
<br/> Version: '1'
<br/> PolicyName:
<br/> Ref: PolicyName
<br/> RamRole:
<br/> Type: ALIYUN::RAM::Role
<br/> Properties:
<br/> AssumeRolePolicyDocument:
<br/> Statement:
<br/> - Action: sts:AssumeRole
<br/> Effect: Allow
<br/> Principal:
<br/> Service:
<br/> Ref: AssumeRolePrincipalServices
<br/> Version: '1'
<br/> Policies:
<br/> - PolicyDocument:
<br/> Statement:
<br/> - Action:
<br/> - ros:*
<br/> Effect: Allow
<br/> Resource:
<br/> - '*'
<br/> Version: '1'
<br/> PolicyName:
<br/> Fn::Join:
<br/> - ''
<br/> - - Policy-
<br/> - Ref: ALIYUN::StackId
<br/> RoleName:
<br/> Ref: RoleName
<br/> RamAttachPolicyToRole:
<br/> Type: ALIYUN::RAM::AttachPolicyToRole
<br/> Properties:
<br/> PolicyName:
<br/> Fn::GetAtt:
<br/> - RamManagedPolicy
<br/> - PolicyName
<br/> PolicyType: Custom
<br/> RoleName:
<br/> Fn::GetAtt:
<br/> - RamRole
<br/> - RoleName
<br/> DependsOn:
<br/> - RamManagedPolicy
<br/> - RamRole
<br/>Outputs:
<br/> PolicyName:
<br/> Value:
<br/> Fn::GetAtt:
<br/> - RamManagedPolicy
<br/> - PolicyName
<br/> RoleArn:
<br/> Value:
<br/> Fn::GetAtt:
<br/> - RamRole
<br/> - Arn
<br/> RoleName:
<br/> Value:
<br/> Fn::GetAtt:
<br/> - RamRole
<br/> - RoleName
<br/>Metadata:
<br/> ALIYUN::ROS::Interface:
<br/> ParameterGroups:
<br/> - Parameters:
<br/> - RoleName
<br/> - AssumeRolePrincipalServices
<br/> - PolicyName
<br/> - SpecificAction
<br/> Label:
<br/> default: RAM
<br/>{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"en": "RAM ロールを作成し、指定されたサービスがそのロールを偽装できるようにするカスタムポリシーをアタッチして、ポリシー操作を定義します。"
},
"Parameters": {
"RoleName": {
"Type": "String",
"Label": {
"en": "ロール名"
},
"Description": {
"en": "ロールの名前です。既に存在する場合は名前を変更してください。<br/>英字、数字、または「-」で構成され、64 文字以内です。"
},
"ConstraintDescription": {
"en": "64 文字以内で、英字、数字、または「-」のみ使用できます。"
},
"Default": "test-role",
"AllowedPattern": "^[a-zA-Z0-9\\-]+$",
"MinLength": 1,
"MaxLength": 64
},
"AssumeRolePrincipalServices": {
"Type": "Json",
"Label": {
"en": "プリンシパルサービス"
},
"Description": {
"en": "ロールを信頼するサービスを指定します。複数回追加できます。"
},
"Default": [
"ecs.aliyuncs.com"
]
},
"PolicyName": {
"Type": "String",
"Label": {
"en": "ポリシー名"
},
"Description": {
"en": "ポリシーの名前です。既に存在する場合は名前を変更してください。<br>英字、数字、または「-」で構成され、5~128 文字です。"
},
"ConstraintDescription": {
"en": "英字、数字、または「-」で構成され、5~128 文字です。"
},
"Default": "test-policy-name",
"AllowedPattern": "^[a-zA-Z0-9\\-]+$",
"MinLength": 5,
"MaxLength": 128
},
"SpecificAction": {
"Type": "String",
"Label": {
"en": "特定の操作"
},
"Description": {
"en": "ポリシーの特定の操作です。英語のカンマで区切ります。<a href='https://www.alibabacloud.com/help/document_detail/93738.html' target='_blank'><b><font color='blue'>ポリシー要素 - 操作を表示</font></font></a><br>例:<br>[oss.*,ecs.*: <font color='green'>oss および ecs のすべての操作</font>]<br>[oss.*: <font color='green'>oss のすべての操作</font>]<br>[oss.GetObjectUrl: <font color='green'>oss の GetObjectUrl 操作</font>]<br>。"
},
"Default": "oss.*,ecs.*"
}
},
"Resources": {
"RamManagedPolicy": {
"Type": "ALIYUN::RAM::ManagedPolicy",
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": {
"Fn::Split": [
",",
{
"Ref": "SpecificAction"
}
]
},
"Effect": "Allow",
"Resource": [
"*"
]
}
],
"Version": "1"
},
"PolicyName": {
"Ref": "PolicyName"
}
}
},
"RamRole": {
"Type": "ALIYUN::RAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": {
"Ref": "AssumeRolePrincipalServices"
}
}
}
],
"Version": "1"
},
"Policies": [
{
"PolicyDocument": {
"Statement": [
{
"Action": [
"ros:*"
],
"Effect": "Allow",
"Resource": [
"*"
]
}
],
"Version": "1"
},
"PolicyName": {
"Fn::Join": [
"",
[
"Policy-",
{
"Ref": "ALIYUN::StackId"
}
]
]
}
}
],
"RoleName": {
"Ref": "RoleName"
}
}
},
"RamAttachPolicyToRole": {
"Type": "ALIYUN::RAM::AttachPolicyToRole",
"Properties": {
"PolicyName": {
"Fn::GetAtt": [
"RamManagedPolicy",
"PolicyName"
]
},
"PolicyType": "Custom",
"RoleName": {
"Fn::GetAtt": [
"RamRole",
"RoleName"
]
}
},
"DependsOn": [
"RamManagedPolicy",
"RamRole"
]
}
},
"Outputs": {
"PolicyName": {
"Value": {
"Fn::GetAtt": [
"RamManagedPolicy",
"PolicyName"
]
}
},
"RoleArn": {
"Value": {
"Fn::GetAtt": [
"RamRole",
"Arn"
]
}
},
"RoleName": {
"Value": {
"Fn::GetAtt": [
"RamRole",
"RoleName"
]
}
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"RoleName",
"AssumeRolePrincipalServices",
"PolicyName",
"SpecificAction"
],
"Label": {
"default": "RAM"
}
}
]
}
}
}シナリオ 3:ActionTrail を管理するための RAM ロールを作成し、監査ログを指定された OSS バケットに保存し、SLS プロジェクトを設定します。
ROSTemplateFormatVersion: '2015-09-01'
Description:
en: Create RAM roles to manage operation auditing, with audit logs stored in a designated OSS bucket, and configure an SLS project for further log processing and analysis.
Parameters:
RoleName:
Type: String
Label:
en: Role Name
Description:
en: Ram role name, 1 to 64 characters in length, beginning with English letters or numbers, hyphens allowed, unique in the account.
ConstraintDescription:
en: 1 to 64 characters in length, beginning with English letters or numbers, hyphens allowed.
Default: ActionTrailTestRole
MinLength: 1
MaxLength: 64
TrailName:
Type: String
Label:
en: Trail Name
Description:
en: Trail Name, 6 to 36 characters in length, must start with a letter, and can contain letters, numbers, dashes (-), and underscores (_), unique in the account
Default: TestTrail
EventRW:
Type: String
Label:
en: Event RW
Description:
en: Read and write types of delivery events
Default: Write
AllowedValues:
- Write
- Read
- All
OssBucketName:
Type: String
Label:
en: Bucket Name
Description:
en: Tracking OSS storage space written
AssociationProperty: ALIYUN::OSS::Bucket::BucketName
AssociationPropertyMetadata:
RegionId: ${RegionId}
OssKeyPrefix:
Type: String
Label:
en: Key Prefix
Description:
en: Track the prefix of the OSS storage space file name written, can be empty. 6 to 32 characters in length, must start with a letter, and can contain letters, numbers, dashes (-), slashes (/), and underscores (_)
Default: ''
SlsProjectName:
Type: String
Label:
en: Project Name
Description:
en: Log service items to track delivery targets
Resources:
Role:
Type: ALIYUN::RAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service:
- actiontrail.aliyuncs.com
Version: '1'
Policies:
- PolicyDocument:
Statement:
- Action:
- oss:ListObjects
- oss:PutObject
- oss:GetBucketLocation
Effect: Allow
Resource:
- '*'
- Action:
- log:PostLogStoreLogs
- log:CreateLogstore
Effect: Allow
Resource:
- '*'
- Action:
- mns:PublishMessage
Effect: Allow
Resource:
- '*'
Version: '1'
PolicyName:
Fn::Sub: ActionTrailPolicy-${ALIYUN::StackId}
RoleName:
Ref: RoleName
Trail:
Type: ALIYUN::ACTIONTRAIL::Trail
Properties:
EventRW:
Ref: EventRW
Name:
Ref: TrailName
OssBucketName:
Ref: OssBucketName
OssKeyPrefix:
Ref: OssKeyPrefix
RoleName:
Fn::GetAtt:
- Role
- RoleName
SlsProjectArn:
Fn::Sub: acs:log:${ALIYUN::Region}::project/${SlsProjectName}
SlsWriteRoleArn:
Fn::Sub: acs:ram::${ALIYUN::TenantId}:role/${Role.RoleName}
DependsOn: Role
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- RoleName
Label:
default: RAM
- Parameters:
- TrailName
- EventRW
Label:
default: Trail
- Parameters:
- OssBucketName
- OssKeyPrefix
Label:
default: OSS
- Parameters:
- SlsProjectName
Label:
default: SLS
{
"ROSTemplateFormatVersion": "2015-09-01",
"Description": {
"en": "Create RAM roles to manage operation auditing, with audit logs stored in a designated OSS bucket, and configure an SLS project for further log processing and analysis."
},
"Parameters": {
"RoleName": {
"Type": "String",
"Label": {
"en": "Role Name"
},
"Description": {
"en": "Ram role name, 1 to 64 characters in length, beginning with English letters or numbers, hyphens allowed, unique in the account."
},
"ConstraintDescription": {
"en": "1 to 64 characters in length, beginning with English letters or numbers, hyphens allowed."
},
"Default": "ActionTrailTestRole",
"MinLength": 1,
"MaxLength": 64
},
"TrailName": {
"Type": "String",
"Label": {
"en": "Trail Name"
},
"Description": {
"en": "Trail Name, 6 to 36 characters in length, must start with a letter, and can contain letters, numbers, dashes (-), and underscores (_), unique in the account"
},
"Default": "TestTrail"
},
"EventRW": {
"Type": "String",
"Label": {
"en": "Event RW"
},
"Description": {
"en": "Read and write types of delivery events"
},
"Default": "Write",
"AllowedValues": [
"Write",
"Read",
"All"
]
},
"OssBucketName": {
"Type": "String",
"Label": {
"en": "Bucket Name"
},
"Description": {
"en": "Tracking OSS storage space written"
},
"AssociationProperty": "ALIYUN::OSS::Bucket::BucketName",
"AssociationPropertyMetadata": {
"RegionId": "${RegionId}"
}
},
"OssKeyPrefix": {
"Type": "String",
"Label": {
"en": "Key Prefix"
},
"Description": {
"en": "Track the prefix of the OSS storage space file name written, can be empty. 6 to 32 characters in length, must start with a letter, and can contain letters, numbers, dashes (-), slashes (/), and underscores (_)"
},
"Default": ""
},
"SlsProjectName": {
"Type": "String",
"Label": {
"en": "Project Name"
},
"Description": {
"en": "Log service items to track delivery targets"
}
}
},
"Resources": {
"Role": {
"Type": "ALIYUN::RAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": [
"actiontrail.aliyuncs.com"
]
}
}
],
"Version": "1"
},
"Policies": [
{
"PolicyDocument": {
"Statement": [
{
"Action": [
"oss:ListObjects",
"oss:PutObject",
"oss:GetBucketLocation"
],
"Effect": "Allow",
"Resource": [
"*"
]
},
{
"Action": [
"log:PostLogStoreLogs",
"log:CreateLogstore"
],
"Effect": "Allow",
"Resource": [
"*"
]
},
{
"Action": [
"mns:PublishMessage"
],
"Effect": "Allow",
"Resource": [
"*"
]
}
],
"Version": "1"
},
"PolicyName": {
"Fn::Sub": "ActionTrailPolicy-${ALIYUN::StackId}"
}
}
],
"RoleName": {
"Ref": "RoleName"
}
}
},
"Trail": {
"Type": "ALIYUN::ACTIONTRAIL::Trail",
"Properties": {
"EventRW": {
"Ref": "EventRW"
},
"Name": {
"Ref": "TrailName"
},
"OssBucketName": {
"Ref": "OssBucketName"
},
"OssKeyPrefix": {
"Ref": "OssKeyPrefix"
},
"RoleName": {
"Fn::GetAtt": [
"Role",
"RoleName"
]
},
"SlsProjectArn": {
"Fn::Sub": "acs:log:${ALIYUN::Region}::project/${SlsProjectName}"
},
"SlsWriteRoleArn": {
"Fn::Sub": "acs:ram::${ALIYUN::TenantId}:role/${Role.RoleName}"
}
},
"DependsOn": "Role"
}
},
"Metadata": {
"ALIYUN::ROS::Interface": {
"ParameterGroups": [
{
"Parameters": [
"RoleName"
],
"Label": {
"default": "RAM"
}
},
{
"Parameters": [
"TrailName",
"EventRW"
],
"Label": {
"default": "Trail"
}
},
{
"Parameters": [
"OssBucketName",
"OssKeyPrefix"
],
"Label": {
"default": "OSS"
}
},
{
"Parameters": [
"SlsProjectName"
],
"Label": {
"default": "SLS"
}
}
]
}
}
}その他の例については、「このリソースを含む公開テンプレート」をご参照ください。