Enable console logon for a Resource Access Management (RAM) user, create and grant a RAM permission policy, and verify the authorization result in Agent Sandbox.
Before a RAM user can access the Agent Sandbox console, you must enable console logon for the user and grant the permissions required to manage the corresponding resources. A custom RAM permission policy limits the resources that the user can manage, such as Teams, API Keys, Templates, Sandboxes, and Volumes.
You must also grant the corresponding RAM permissions when you call public operations by using Alibaba Cloud OpenAPI, SDKs, or the command line interface (CLI).
Prerequisites
-
Agent Sandbox is activated for the Alibaba Cloud account.
-
The target RAM user is created. For more information, see Quick start: Create a RAM user and grant permissions.
-
The operator is an Alibaba Cloud account (root account) or a RAM identity. The RAM identity must have the permissions to manage RAM user logon settings, create permission policies, and grant permissions to RAM users.
Step 1: Enable console logon
Skip this step if console logon is already enabled for the user. For more information, see Manage RAM user logon settings.
-
Log on to the RAM console, and choose , and click the name of the target RAM user.
-
On the Authentication tab, in the Login Profile section, click Enable Console Logon.
-
Turn on Console Access, set a logon password, configure password reset at first logon and multi-factor authentication (MFA) if your enterprise requires them, and then click OK.
Step 2: Create a permission policy
Select a policy based on the scope of the user's work, and retain only the permissions that are required:
|
Work that the user needs to perform |
Authorization scope |
|
Manage all Agent Sandbox resources in the account centrally. |
All Agent Sandbox operations and resources. |
|
Manage a specific project or environment. |
The specified Team and its sub-resources. |
|
Perform only specific operations. |
The operations and resources that correspond to the required API. |
Action specifies the operations that are allowed; Resource specifies the resources on which operations can be performed; Condition specifies the conditions under which the policy takes effect, such as a region or a resource group.
In the following examples, <region> is the region in which the resource resides. <account-id> is the unique identifier (UID) of the Alibaba Cloud account to which the resource belongs. <team-id> is the ID of the target Team. Replace the placeholders with actual values before you use the policy.
Manage all Agent Sandbox resources
This policy applies to platform administrators who are responsible for all Agent Sandbox resources in the account. The following policy grants permissions on all Agent Sandbox operations in all regions of the account:
{
"Version": "1",
"Statement": [
{
"Effect": "Allow",
"Action": "sandbox:*",
"Resource": "*"
}
]
}
To limit the region, change Resource to acs:sandbox:<region>:<account-id>:*. This policy grants only Agent Sandbox permissions. Access to other cloud services requires separate authorization.
Manage a specified Team
This policy applies to personnel who manage a specific project or environment. The following policy allows operations on the specified Team and the resources under it:
{
"Version": "1",
"Statement": [
{
"Effect": "Allow",
"Action": "sandbox:*",
"Resource": [
"acs:sandbox:<region>:<account-id>:teams/<team-id>",
"acs:sandbox:<region>:<account-id>:teams/<team-id>/*"
]
}
]
}
The first Alibaba Cloud Resource Name (ARN) matches the Team itself, and the second matches the sub-resources under the Team. This policy includes permissions to modify and delete the specified Team, but does not grant permissions to create other Teams.
Querying the Team list and account information in the console requires additional query permissions, which the preceding Team-specific policy does not include. See the RAM Action list at the end of this topic to grant the required query permissions. If you grant Team list queries by resource group, the user can view the Teams in that resource group. You must still grant permissions on other Teams separately.
Grant fine-grained permissions by operation
Based on the operations that the user needs to perform, select the required permissions from the RAM Action list
at the end of this topic. Limit the scope of operations by using resource ARNs. Action and Resource must match at the same time. An API name may differ from the RAM Action. Use the Action values in the list as the reference.
Limit permissions by resource group
A resource group is not part of the ARN path. To limit permissions to a resource group, add the Condition element to the permission policy and specify the acs:ResourceGroupId condition key. The resource group of a Team determines the resource group of the resources under it, such as Templates, Sandboxes, API Keys, and Volumes.
The following example builds on Team-level authorization and uses the Condition element to limit permissions to the specified resource group:
{
"Version": "1",
"Statement": [
{
"Effect": "Allow",
"Action": "sandbox:GetTeam",
"Resource": "acs:sandbox:<region>:<account-id>:teams/<team-id>",
"Condition": {
"StringEquals": {
"acs:ResourceGroupId": "<resource-group-id>"
}
}
}
]
}
If an insufficient-permission error occurs, check the Action required for the operation, the ARN of the target resource, and the region and resource group conditions in the policy.
Save the policy in the RAM console
-
In the RAM console, choose , and click Create Policy.
-
Click the JSON Editor tab, enter the adjusted JSON policy, and then click OK.
-
In the Create Policy panel, enter a policy name (for example,
SandboxTeamAccess) and a description, and then click OK.
For more information, see Create a custom policy.
Step 3: Grant permissions to the RAM user
-
In the RAM console, choose .
-
Find the target RAM user, and click Grant Permission in the Actions column.
-
Set Resource scope to Account level, and confirm that the principal is the target RAM user.
-
In the permission policy list, select Custom Policy, search for the policy created in the previous step, and then select it.
-
Click OK to complete the authorization.
Although you select Account level here, the permissions granted by each policy are still limited by its Resource and Condition. For more information, see Manage RAM user permissions.
Step 4: Log on and verify
-
Log on to the Alibaba Cloud console as the target RAM user, and go to the Agent Sandbox console.
-
Switch to the region and resource group to which the authorized resources belong, and then select the target Team.
-
Verify that the required query and management operations are available, and confirm that unauthorized operations or resources are still denied access.
If the logon fails, check the console logon settings. If an insufficient-permission message appears after the logon, check the current identity, region, resource group, and the operations and resource scope in the policy. The permissions that the user obtains from other policies or RAM user groups also take effect during authentication. When you verify fine-grained authorization, check these grants as well.
References
-
To call operations by using Alibaba Cloud SDKs or CLI, see Alibaba Cloud SDK and API Guide.
-
To use Sandboxes by using the E2B SDK, the E2B CLI, or a compatible API, authenticate with an Agent Sandbox API Key. For more information, see Create an API Key.
-
For information about the RAM role and its permissions that a Sandbox requires to access cloud services such as storage, see Configure a RAM role.
RAM Action list
This section lists the resource ARN expressions and the RAM Actions required by resource type. For more information about how to call each operation, see the Sandbox API portal for the public API operations.
Resource ARNs
The basic format of an ARN is as follows:
acs:sandbox:<region>:<account-id>:<resource-path>
<account-id> is the UID of the Alibaba Cloud account to which the resource belongs, not the RAM user ID. <team-id>, <template-id>, and <volume-id> are the IDs of the corresponding resources. In Sandbox authorization, <template-id> is the actual ID of the Template to which the Sandbox belongs. Do not specify the Template alias or the Sandbox ID.
|
Resource scope |
ARN expression |
|
All resources |
|
|
All Agent Sandbox resources in a specified account and region |
|
|
All Agent Sandbox resources in all regions of a specified account |
|
|
All Teams in the account |
|
|
A specified Team |
|
|
All sub-resources under a specified Team |
|
|
All Templates in a Team |
|
|
A specified Template |
|
|
All Sandboxes in a Team |
|
|
Sandboxes under a specified Template |
|
|
All API Keys in a Team |
|
|
All Volumes in a Team |
|
|
A specified Volume |
|
|
All Quotas in a Team |
|
|
All Template Caches in a Team |
|
|
A specified Template Cache |
|
The following table lists the ARNs that match all resources of a specific type in the account. To determine whether an operation supports cross-Team queries, refer to the request parameter description of that operation in the Sandbox API portal. If an operation requires the teamID parameter, you must still specify it. Account-level ARN authorization cannot replace a required parameter. If you need to manage only a specific Team, prefer the Team-level scopes in the preceding table.
|
Resource scope |
ARN expression |
|
All Templates in the account |
|
|
All Sandboxes in the account |
|
|
All API Keys in the account |
|
|
All Volumes in the account |
|
|
All Quotas in the account |
|
|
All Template Caches in the account |
|
An account-level ARN and a resource-specific ARN correspond to different request scopes. The permission to query a single resource does not allow you to list all resources of that type in the account. The following tables list the RAM Actions and their purposes by resource type. For operations that support the teamID parameter, specify the ID of the target Team if you have only Team-level permissions.
Team management
|
RAM Action |
Purpose |
|
|
Creates a Team. |
|
|
Queries the Team list. |
|
|
Queries the details of a Team. |
|
|
Updates the configurations of a Team. |
|
|
Deletes a Team. |
sandbox:ListTeams uses the ARN of all Teams in the account. You cannot grant list query permissions through a single Team ARN. To limit a query to a resource group, specify the corresponding resourceGroupID. In a sandbox:UpdateTeam request, the resourceGroupID parameter changes the resource group to which the Team belongs. This operation checks the permissions on both of the source and the destination resource groups.
API Key management
|
RAM Action |
Purpose |
|
|
Creates an API Key. |
|
|
Queries the API Key list. |
|
|
Queries the details of an API Key. |
|
|
Updates the configurations of an API Key. |
|
|
Resets an API Key. |
|
|
Deletes an API Key. |
The RAM authorization granularity of an API Key is the Team. Even if you query, update, or delete a specific API Key, use apikeys/*. If an update request contains permissionPolicy or expectedPolicyVersion, you must have both of the sandbox:UpdateApiKey and sandbox:CreateApiKey permissions.
Template management
|
RAM Action |
Purpose |
|
|
Creates a Template and submits a build. |
|
|
Queries the Templates under a Team. |
|
|
Queries the details of a Template. |
|
|
Updates the configurations of a Template. |
|
|
Deletes a Template. |
Template Cache management
|
RAM Action |
Purpose |
|
|
Creates a Template Cache. |
|
|
Queries the Template Cache list. |
|
|
Queries the details of a Template Cache. |
|
|
Deletes a Template Cache. |
The last segment of the ARN of a Template Cache, which caches template images, uses <template-id>. Template Cache and Template use different resource paths and Actions. You cannot use Template permissions in place of Template Cache permissions.
Sandbox management
|
RAM Action |
Purpose |
|
|
Creates a Sandbox. |
|
|
Queries the Sandbox list. |
|
|
Queries the details of a Sandbox. |
|
|
Pauses a Sandbox. |
|
|
Resumes a Sandbox. |
|
|
Releases a Sandbox. |
|
|
Updates the timeout period of a Sandbox. |
Sandbox permissions are granted based on the Template to which the Sandbox belongs. The resource path is teams/<team-id>/templates/<template-id>/*. You cannot limit permissions to a single Sandbox ID.
Volume management
|
RAM Action |
Purpose |
|
|
Creates a Volume. |
|
|
Queries the Volume list. |
|
|
Queries the details of a Volume. |
|
|
Updates the configurations of a Volume. |
|
|
Deletes a Volume. |
The ARN of a specified Volume uses <volume-id>, not the Volume name that is referenced when the Volume is mounted. Create operations and list queries typically use the ARN of all Volumes in a Team. Queries, updates, and deletions by ID use the ARN of the specified Volume.
Quota management
|
RAM Action |
Purpose |
|
|
Queries the Quota list of the Alibaba Cloud account (root account). |
|
|
Queries the Quota of a specified Team. |
|
|
Updates the Quota of a specified Team. |
|
|
Deletes the Quota of a specified Team. |
Account feature configurations
|
RAM Action |
Purpose |
|
|
Queries the feature configurations of an account. |