Obtains the value of a secret.
Operation description
-
For information about the required access policy for a RAM user or RAM role to call this API operation, see Resource Access Management.
-
If you do not specify a version number or stage, KMS returns the secret value of the version that is marked as ACSCurrent.
-
If a user-specified key is used to protect the secret value, the caller must have the
kms:Decryptpermission on the corresponding master key.
This topic provides an example of how to obtain the value of a secret named secret001. The response shows that the secret value of SecretData is testdata1.
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 |
secret001 |
| VersionStage |
string |
No |
The stage label that marks the secret version. The default value is ACSCurrent. If you specify this parameter, the secret value of the version with the specified stage label is returned. If you do not specify this parameter, the secret value of the version marked with ACSCurrent is returned. Note
For RDS secrets, PolarDB secrets, Redis/Tair secrets, RAM secrets, and ECS secrets, you can obtain the secret values of only the versions that are marked with ACSPrevious and ACSCurrent. |
ACSCurrent |
| VersionId |
string |
No |
The version number. Note
You cannot specify the VersionId parameter for RDS secrets, PolarDB secrets, Redis/Tair secrets, RAM secrets, or ECS secrets. If you set this parameter, the setting is ignored. |
00000000000000000000000000000001 |
| FetchExtendedConfig |
boolean |
No |
Specifies whether to retrieve the extended configuration of the secret. Valid values:
Note
Generic secrets do not support extended configurations. If you set this parameter for a generic secret, the setting is ignored. |
true |
| DryRun |
string |
No |
Specifies whether to enable the dry run feature.
The dry run feature is used to test the API call. It verifies whether you have the required permissions on the resources and whether the request parameters are valid. If you enable the dry run feature, KMS always returns a failure response that indicates the cause of the failure. The following failure causes are possible:
|
false |
For more information about common request parameters, see Common parameters.
Response parameters
|
Parameter |
Type |
Description |
Example |
|
object |
|||
| SecretDataType |
string |
The type of the secret value. Valid values:
|
binary |
| CreateTime |
string |
The time when the secret was created. |
2020-02-21T15:39:26Z |
| VersionId |
string |
The version number of the secret. |
00000000000000000000000000000001 |
| NextRotationDate |
string |
The time when the secret is next rotated. Note
This parameter is returned only if automatic rotation is enabled. |
2020-07-06T18:22:03Z |
| SecretData |
string |
The value of the secret. The value is decrypted from the ciphertext by KMS and returned.
|
testdata1 |
| RotationInterval |
string |
The interval for automatic rotation. Note
This parameter is returned only if automatic rotation is enabled. |
604800s |
| ExtendedConfig |
string |
The extended configuration of the secret. Note
This parameter is returned for an RDS secret, PolarDB secret, Redis/Tair secret, RAM secret, or ECS secret only when FetchExtendedConfig is set to true. |
{\"SecretSubType\":\"SingleUser\", \"DBInstanceId\":\"rm-uf667446pc955****\", \"CustomData\":{} } |
| LastRotationDate |
string |
The time when the secret was last rotated. Note
This parameter is returned only if the secret was rotated. |
2020-07-05T08:22:03Z |
| RequestId |
string |
The ID of the request, which is a unique identifier generated by Alibaba Cloud. You can use this ID to troubleshoot issues. |
6a3e9c36-1150-4881-84d3-eb8672fcafad |
| SecretName |
string |
The name of the secret. |
secret001 |
| AutomaticRotation |
string |
Indicates whether automatic rotation is enabled. Valid values:
Note
This parameter is returned only for an RDS secret, PolarDB secret, Redis/Tair secret, RAM secret, or ECS secret. |
Enabled |
| SecretType |
string |
The type of the secret. Valid values:
|
Generic |
| VersionStages |
array |
The stage labels that mark the secret version. |
|
|
string |
The stage label that marks the secret version. |
{ "VersionStage": [ "ACSCurrent" ] } |
Examples
Success response
JSON format
{
"SecretDataType": "binary",
"CreateTime": "2020-02-21T15:39:26Z",
"VersionId": "00000000000000000000000000000001",
"NextRotationDate": "2020-07-06T18:22:03Z",
"SecretData": "testdata1",
"RotationInterval": "604800s",
"ExtendedConfig": "{\\\"SecretSubType\\\":\\\"SingleUser\\\", \\\"DBInstanceId\\\":\\\"rm-uf667446pc955****\\\", \\\"CustomData\\\":{} }",
"LastRotationDate": "2020-07-05T08:22:03Z",
"RequestId": "6a3e9c36-1150-4881-84d3-eb8672fcafad",
"SecretName": "secret001",
"AutomaticRotation": "Enabled",
"SecretType": "Generic",
"VersionStages": [
"{ \"VersionStage\": [ \t\"ACSCurrent\" \t] }"
]
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 403 | Forbidden.DKMSInstanceStateInvalid | The DKMS instance state is invalid. | Your dedicated KMS instance is invalid. |
| 403 | Forbidden.DKMSInstanceNotFound | The specified DKMS Instance is not found. | Your dedicated KMS instance is not found. |
| 404 | Forbidden.KeyNotFound | The specified Key is not found. | The error message returned because the specified CMK does not exist. |
| 404 | Forbidden.ResourceNotFound | Resource not found. | The resource is not found. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.