Sets a secret policy for a secret in a KMS instance.
Operation description
-
For information about the access policy that a RAM user or RAM role requires to call this operation, see Resource Access Management.
-
For more information about secret policies, see Secret policy overview.
Try it now
Test
RAM authorization
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| SecretName |
string |
Yes |
The name or Alibaba Cloud Resource Name (ARN) of the secret. Note
When you access a secret in another Alibaba Cloud account, you must specify the ARN of the secret. The ARN of a secret is in the format of |
secret_test |
| PolicyName |
string |
No |
The name of the secret policy. The value can only be `default`. |
default |
| Policy |
string |
Yes |
The content of the secret policy. The value must be in the JSON format. The value can be up to 32,768 bytes in length. A secret policy contains the following elements:
The following code shows the format of a secret policy:
The following section describes the elements in a statement:
Note
After you grant permissions to a RAM user or RAM role of another Alibaba Cloud account, you must go to the RAM console and use the Alibaba Cloud account to which the RAM user or RAM role belongs to grant the RAM user or RAM role the permissions to use the secret. For more information, see Custom policies for KMS, Grant permissions to a RAM user, and Grant permissions to a RAM role. |
{"Version":"1","Statement": [{"Sid":"kms default secret policy","Effect":"Allow","Principal":{"RAM": ["acs:ram::119285303511****:*"]},"Action":["kms:*"],"Resource": ["*"] }] } |
Response parameters
|
Parameter |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The ID of the request, which is a unique identifier generated by Alibaba Cloud. You can use this ID to troubleshoot issues. |
381D5D33-BB8F-395F-8EE4-AE3BB4B523C8 |
Examples
Success response
JSON format
{
"RequestId": "381D5D33-BB8F-395F-8EE4-AE3BB4B523C8"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | MissingParameter | The parameter needed but no provided. | The required parameters are not specified. |
| 400 | InvalidParameter | The specified parameter is not valid. | An invalid value is specified for the parameter. |
| 400 | Forbidden.NoPermission | This operation is forbidden by permission system. | You are not authorized to perform this operation. |
| 400 | Forbidden.KeyPolicyUnSupported | The specified key does not support key policy. | The specified key does not support key policies. |
| 400 | Rejected.ShareQuotaExceedLimit | Instance Share Quota Exceed Limit. | The instance share quota exceeds the limit. |
| 403 | Forbidden.DKMSInstanceStateInvalid | The DKMS instance state is invalid. | Your dedicated KMS instance is invalid. |
| 404 | Forbidden.ResourceNotFound | Resource not found. | The resource is not found. |
| 404 | Forbidden.KeyNotFound | The specified Key is not found. | The error message returned because the specified CMK does not exist. |
| 503 | SerivceUnvailableTemporary | Service Unvailable Temporary | The service is temporarily unavailable. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.