Before you create a stack group with self-managed permissions, you must manually create RAM roles within the administrator and execution accounts and establish a trust relationship between them. This enables you to deploy stacks within the execution account.
Background information
Before granting self-managed permissions, you must create RAM roles for the Alibaba Cloud accounts in the following table and grant permissions to these roles:
Alibaba Cloud account | RAM role | Policy | Policy description |
Alibaba Cloud account | RAM role | Policy | Policy description |
Administrator account | AliyunROSStackGroupAdministrationRole | Custom policy: AssumeRole-AliyunROSStackGroupExecutionRole | Allows the AliyunROSStackGroupAdministrationRole RAM role to assume the AliyunROSStackGroupExecutionRole RAM role. |
Execution account | AliyunROSStackGroupExecutionRole | System policy: AdministratorAccess | Allows the AliyunROSStackGroupExecutionRole RAM role to manage all Alibaba Cloud resources that belong to the execution account. |
Note
The administrator account and the execution account can be the same Alibaba Cloud account. For more information about administrator accounts and execution accounts, see Overview.
After granting permissions to the roles, you can use the administrator account to create a stack group in the ROS console. You can then create stack instances in the stack group to deploy stacks within the execution account.
Method 1: Grant self-managed permissions in the RAM console
Configure permissions for the execution account.
Use the execution account to log on to the RAM console.
Create a RAM role (AliyunROSStackGroupExecutionRole) for the execution account. The trusted entity of the role is the administrator account.
In the left navigation bar, select .
On the Roles page, click Create Role.
On the Create Role page, select Trusted Entity Type as Alibaba Cloud Account.
Select Trusted Alibaba Cloud Account as Other Alibaba Cloud Account, and enter the ID of the administrator account.
Click OK, and enter Role Name as AliyunROSStackGroupExecutionRole in the dialog box.
Click OK to complete the creation.
Grant the AdministratorAccess permission to the AliyunROSStackGroupExecutionRole RAM role.
On the Roles page, click Add Permissions in the Actions column of the AliyunROSStackGroupExecutionRole RAM role.
In the Add Authorization panel, select Account Level as the resource scope, and the authorization entity will be automatically filled in.
Select System Policy for Select Policy, and then select AdministratorAccess.
Click OK.
Configure permissions for the administrator account.
Use the administrator account to log on to the RAM console.
Create a RAM role (AliyunROSStackGroupAdministrationRole) for the administrator account. The trusted entity of the role is Resource Orchestration Service.
In the left navigation bar, select .
On the Roles page, click Create Role.
On the Create Role page, select Trusted Entity Type as Alibaba Cloud Service.
Select Select Trusted Service as Resource Orchestration Service, and click OK.
In the dialog box, enter Role Name as AliyunROSStackGroupAdministrationRole.
Click OK to complete the creation.
Create a custom policy (AssumeRole-AliyunROSStackGroupExecutionRole).
In the left navigation bar, select .
On the Policies page, click Create Policy.
On the Create Policy page, click the Script tab, enter the following policy content, and click OK. Enter the Policy Name as AssumeRole-AliyunROSStackGroupExecutionRole.
This policy allows the AliyunROSStackGroupAdministrationRole RAM role to assume the AliyunROSStackGroupExecutionRole RAM role.
{
"Statement": [
{
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "acs:ram::*:role/AliyunROSStackGroupExecutionRole"
}
],
"Version": "1"
}
Click OK to complete the creation.
Grant the AssumeRole-AliyunROSStackGroupExecutionRole permission to the AliyunROSStackGroupAdministrationRole RAM role.
In the left navigation bar, select .
On the Roles page, click Add Permissions in the Actions column of the AliyunROSStackGroupAdministrationRole RAM role.
In the Add Permissions panel, select Scope For Authorization as Alibaba Cloud Account. The authorized principal is automatically filled in.
Select Custom Policy for Select Policy, and then select AssumeRole-AliyunROSStackGroupExecutionRole.
Click OK.
Method 2: Grant self-managed permissions in the ROS console
You can use a ROS template to create RAM roles for the administrator and execution accounts and grant permissions on stack groups and stacks to these roles.
The administrator account logs on to the ROS console and uses the AliyunROSStackGroupAdministrationRole template to create a RAM role and grant permissions to the role.
ROSTemplateFormatVersion: '2015-09-01'
Description: Configure the AliyunROSStackGroupAdministrationRole to enable use of Alibaba Cloud ROS StackGroup.
Parameters:
AdministrationRoleName:
Type: String
Default: AliyunROSStackGroupAdministrationRole
Description:
en: Role name of administration account
zh-cn: 创建授权给管理员账号的角色的名称
ExecutionRoleName:
Type: String
Default: AliyunROSStackGroupExecutionRole
Description:
en: Execution role name of target account
zh-cn: 目标账号执行角色名称
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- AdministrationRoleName
- ExecutionRoleName
Label:
default:
en: RAM
zh-cn: 账号权限
TemplateTags:
- acs:example:Security:Grant permissions to the administrator account of a stack group
Resources:
AliyunROSStackGroupAdministrationRole:
Type: ALIYUN::RAM::Role
Properties:
RoleName:
Ref: AdministrationRoleName
AssumeRolePolicyDocument:
Version: 1
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
Service:
- ros.aliyuncs.com
Policies:
- PolicyName:
Fn::Sub:
- AssumeRole-${ExecutionRoleName}
- ExecutionRoleName:
Ref: ExecutionRoleName
PolicyDocument:
Statement:
- Effect: Allow
Action:
- sts:AssumeRole
Resource:
- Fn::Sub: acs:ram::*:role/${ExecutionRoleName}
Version: '1'
Outputs:
AdministrationRoleName:
Value:
Fn::GetAtt:
- AliyunROSStackGroupAdministrationRole
- RoleName
The execution account logs on to the ROS console and uses the AliyunROSStackGroupExecutionRole template to create a RAM role and grant permissions to the role.
ROSTemplateFormatVersion: '2015-09-01'
Description: Configure the AliyunROSStackGroupExecutionRole to enable use of your account as a target account in Alibaba Cloud ROS StackGroup.
Conditions:
CurrentAccount:
Fn::Equals:
- Ref: AdministrationAccountId
- ''
Parameters:
ExecutionRoleName:
Type: String
Default: AliyunROSStackGroupExecutionRole
Description:
en: Execution role name of target account
zh-cn: 为目标账号创建执行角色的名称
AdministrationAccountId:
Type: String
Description:
zh-cn: 管理员主账号ID,不填则授权给当前账号
en: Administration account ID. If not, authorize the current account
Default: ''
Metadata:
ALIYUN::ROS::Interface:
ParameterGroups:
- Parameters:
- ExecutionRoleName
- AdministrationAccountId
Label:
default: RAM
TemplateTags:
- acs:example:Security:Grant permissions to the execution account of a stack group
Resources:
AliyunROSStackGroupExecutionRole:
Type: ALIYUN::RAM::Role
Properties:
RoleName:
Ref: ExecutionRoleName
AssumeRolePolicyDocument:
Version: 1
Statement:
- Action: sts:AssumeRole
Effect: Allow
Principal:
RAM:
- Fn::Join:
- ''
- - 'acs:ram::'
- Fn::If:
- CurrentAccount
- Ref: ALIYUN::TenantId
- Ref: AdministrationAccountId
- ':root'
AttachPolicy:
Type: ALIYUN::RAM::AttachPolicyToRole
Properties:
PolicyName: AdministratorAccess
PolicyType: System
RoleName:
Fn::GetAtt:
- AliyunROSStackGroupExecutionRole
- RoleName
Outputs:
ExecutionRoleName:
Value:
Fn::GetAtt:
- AliyunROSStackGroupExecutionRole
- RoleName