Queries the key policy of a CMK in a KMS instance.
Operation description
-
For more information about the access policy required for a Resource Access Management (RAM) user or RAM role to call this operation, see Resource Access Management.
-
Because the key policy name can only be set to default, you must set the PolicyName parameter to default when you query the key policy. Otherwise, a
Not Founderror is returned.
Try it now
Test
RAM authorization
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| KeyId |
string |
Yes |
The ID or Alibaba Cloud Resource Name (ARN) of the key. Note
When you access a key in another Alibaba Cloud account, you must enter the ARN of the key. The ARN of a key is in the |
key-hzz630494463ejqjx**** |
| PolicyName |
string |
No |
The name of the key policy. Only the static value default is supported. |
default |
Response elements
|
Parameter |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The ID of the request. This ID is a unique identifier generated by Alibaba Cloud for the request. You can use this ID to troubleshoot issues. |
381D5D33-BB8F-395F-8EE4-AE3B84B523C8 |
| Policy |
string |
The key policy. |
{"Statement": [{"Action": ["kms:*"],"Effect": "Allow","Principal": {"RAM": ["acs:ram::190325303126****:*","acs:ram::119285303511****:*"]},"Resource": ["*"],"Sid": "kms default key policy"}],"Version": "1" } |
Examples
Success response
JSON format
{
"RequestId": "381D5D33-BB8F-395F-8EE4-AE3B84B523C8",
"Policy": "{\"Statement\": [{\"Action\": [\"kms:*\"],\"Effect\": \"Allow\",\"Principal\": {\"RAM\": [\"acs:ram::190325303126****:*\",\"acs:ram::119285303511****:*\"]},\"Resource\": [\"*\"],\"Sid\": \"kms default key policy\"}],\"Version\": \"1\" }"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParameter | The specified parameter is not valid. | An invalid value is specified for the parameter. |
| 400 | MissingParameter | The parameter needed but no provided. | The required parameters are not specified. |
| 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. |
| 404 | Forbidden.KeyNotFound | The specified Key is not found. | The error message returned because the specified CMK does not exist. |
| 404 | Forbidden.ResourceNotFound | Policy not found. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.