This topic describes how to grant permissions to a Resource Access Management (RAM) user.
Procedure
Log on to the RAM console by using an Alibaba Cloud account.
Create a custom policy.
In the left-side navigation pane, choose
.On the Policies page, click Create Policy.
On the Create Policy page, click the JSON tab.
NoteRAM provides the visual editing and document editing modes to create policies. When you create a custom policy for Key Management Service (KMS) resources, you must use the document editing mode. If you use the visual editing mode, you can select only all KMS resources and all operations.
Modify the policy document and click Next to edit policy information.
When you edit a KMS policy document, you must specify a custom authorization statement. A statement contains the following elements: Effect, Action, Resource, and Condition. The Condition element is optional. For more information, see Appendix: Supported resources, actions, and conditions.
NoteFor more information about the syntax and structure of RAM policies, see Policy structure and syntax.
Specify the policy name and description. Then, check and optimize the policy document as prompted.
Click OK.
Attach custom policies to a RAM user.
In the left-side navigation pane, choose
.On the Users page, find the RAM user to which you want to attach custom policies and click Add Permissions in the Actions column.
In the Grant Permission panel, configure the parameters and click Grant Permissions.
Parameter
Description
Resource Scope
The scope in which you want the permissions to take effect. KMS does not support the resource group feature. You must select Account.
Principal
The RAM user to which you want to grant permissions. The Principal parameter is automatically set to a specific RAM user. You can specify a different RAM user.
Policy
Select custom policies based on your business requirements.
Appendix: Supported resources, actions, and conditions
Resource
KMS defines the following resource types: key container, secret container, alias container, key, secret, and alias. You can configure the Resource element in a RAM policy based on the Alibaba Cloud Resource Name (ARN) of your resource. In the following example, the ARN of a key resource is queried.
Log on to the KMS console. In the top navigation bar, select a region. In the left-side navigation pane, choose .
On the Keys tab, find the key whose ARN you want to query and click Details in the Actions column. On the details page, you can view the ARN of the key. The following table describes the ARN formats for different resource types.
NoteReplace
${region}
and${account}
with your actual region and Alibaba Cloud account. You can also narrow the scope of resources based on your business requirements.${region}
supports the asterisk (*) wildcard character, which specifies all supported regions.Resource type
ARN
Key container
acs:kms:${region}:${account}:key
Secret container
acs:kms:${region}:${account}:secret
Alias container
acs:kms:${region}:${account}:alias
Key
acs:kms:${region}:${account}:key/${key-id}
NoteThe ARN of a key resource supports the asterisk (*) wildcard character. Examples:
acs:kms:${region}:${account}:key/*
: specifies all keys in a region within an account.acs:kms:*:${account}:key/*
: specifies all keys in all regions within an account.
Secret
acs:kms:${region}:${account}:secret/${secret-name}
NoteThe ARN of a secret resource supports the asterisk (*) wildcard character.
acs:kms:${region}:${account}:secret/*
: specifies all secrets in a region within an account.acs:kms:${region}:${account}:secret/prefix*
: specifies all secrets that start withprefix
in a region within an account.
Alias
acs:kms:${region}:${account}:alias/${alias-name}
Action
KMS defines actions for each API operation that requires access control. In RAM policies, actions are in the kms:<api-name>
format.
The DescribeRegions operation does not require access control. The operation can be called by Alibaba Cloud accounts, RAM users, or RAM roles after they pass RAM authentication. Alibaba Cloud accounts, RAM users, or RAM roles after they pass RAM authentication.
The following tables describe the RAM actions and resource types that correspond to each API operation.
Replace ${region}
and ${account}
with your actual region and Alibaba Cloud account. You can also narrow the scope of resources based on your business requirements. ${region}
supports the asterisk (*) wildcard character, which specifies all supported regions.
Condition
The Condition element specifies the conditions that are required for a policy to take effect. This element is optional. You can add a condition key in RAM policies to manage access to KMS. RAM authentication is successful only if the added conditions are met.
Use common condition keys: The condition key is in the
acs:<condition-key>
format. For example, you can useacs:CurrentTime
to specify the validity period of a RAM policy.For more information, see Policy elements.
Use condition keys specific to an Alibaba Cloud service: The condition key is in the
kms:<condition-key>
format. For more information about condition keys specific to an Alibaba Cloud service that are supported by KMS, see Condition keys.