GetSecretValue
Retrieves a secret value.
Operation description
-
For details about the access policy that needs to be granted to a Resource Access Management (RAM) user or RAM role to invoke this operation, see Access control.
-
If you do not specify a version number or version status, KMS returns the credential value of the version marked as ACSCurrent by default.
-
If the credential uses a custom master key to protect the credential value, the caller must also have the
kms:Decryptpermission on the corresponding master key.
This topic provides an example of retrieving the credential value of a credential named secret001. The response shows that the credential value SecretData is testdata1.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
kms:GetSecretValue |
get |
*Secret
|
None |
|
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| SecretName |
string |
Yes |
The secret name or secret Alibaba Cloud Resource Name (ARN). Note
When accessing a secret in another Alibaba Cloud account, you must enter the secret ARN. The format of the secret ARN is |
secret001 |
| VersionStage |
string |
No |
The version status. Default value: ACSCurrent. If you specify this parameter, the secret value of the specified version status is returned. If you do not specify this parameter, the secret value of the ACSCurrent version status is returned. Note
For ApsaraDB RDS secrets, PolarDB secrets, Redis/Tair secrets, dynamic RAM secrets, and dynamic ECS secrets, only the secret values corresponding to ACSPrevious and ACSCurrent can be retrieved. |
ACSCurrent |
| VersionId |
string |
No |
The version number. Note
Specifying VersionId is not supported for ApsaraDB RDS secrets, PolarDB secrets, Redis/Tair secrets, dynamic RAM secrets, or dynamic ECS secrets. If you set this parameter, it is ignored. |
v1 |
| FetchExtendedConfig |
boolean |
No |
Specifies whether to retrieve the extended configuration of the secret. Valid values:
Note
Generic secrets do not support extended configuration. If you set this parameter, it is ignored. |
true |
| DryRun |
string |
No |
Specifies whether to enable DryRun mode. Valid values:
DryRun mode is used to test API calls, verify whether you have the required permissions on the specified resources, and check whether the request parameters are configured correctly. When DryRun mode is enabled, KMS always returns a failure with the reason for the failure. Possible failure reasons include:
|
false |
| Recipient |
string |
No |
{ "AttestationDocument":"base64-encoded-attestion-document", "KeyEncryptionAlgorithm":"RSAES_OAEP_SHA_256" } |
For details about common request parameters, see Common parameters.
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| SecretDataType |
string |
The type of the secret value. Valid values:
|
binary |
| CreateTime |
string |
The time when the secret was created. |
2024-02-21T15:39:26Z |
| VersionId |
string |
The version number of the secret. |
v1 |
| NextRotationDate |
string |
The time of the next rotation. Note
This parameter is returned when automatic rotation is enabled. |
2024-07-06T18:22:03Z |
| SecretData |
string |
The secret value. KMS decrypts the stored ciphertext secret value and returns this parameter.
|
testdata1 |
| RotationInterval |
string |
The interval for automatic secret rotation. The format is Note
This parameter is returned when automatic rotation is enabled. |
604800s |
| ExtendedConfig |
string |
The extended configuration of the secret. Note
This parameter is returned only for ApsaraDB RDS secrets, PolarDB secrets, Redis/Tair secrets, dynamic RAM secrets, or dynamic ECS secrets when FetchExtendedConfig is set to true. |
{\"SecretSubType\":\"SingleUser\", \"DBInstanceId\":\"rm-uf667446pc955****\", \"CustomData\":{} } |
| LastRotationDate |
string |
The time of the most recent rotation. Note
This parameter is returned when the secret has been rotated at least once. |
2023-07-05T08:22:03Z |
| RequestId |
string |
The ID of the request, which is a unique identifier generated by Alibaba Cloud for the request. You can use this ID to troubleshoot and locate issues. |
6a3e9c36-1150-4881-84d3-eb8672fcafad |
| SecretName |
string |
The secret name. |
secret001 |
| AutomaticRotation |
string |
Indicates whether automatic rotation is enabled. Valid values:
Note
This parameter is returned only for ApsaraDB RDS secrets, PolarDB secrets, Redis/Tair secrets, dynamic RAM secrets, or dynamic ECS secrets. |
Enabled |
| SecretType |
string |
The secret type. Valid values:
|
Generic |
| VersionStages |
object |
||
| VersionStage |
array |
The status label of the secret version. |
|
|
string |
The status label of the secret version. |
{ "VersionStage": [ "ACSCurrent" ] } |
|
| CiphertextForRecipient |
string |
***CipherForRecipient*** |
Examples
Success response
JSON format
{
"SecretDataType": "binary",
"CreateTime": "2024-02-21T15:39:26Z",
"VersionId": "v1",
"NextRotationDate": "2024-07-06T18:22:03Z",
"SecretData": "testdata1",
"RotationInterval": "604800s",
"ExtendedConfig": "{\\\"SecretSubType\\\":\\\"SingleUser\\\", \\\"DBInstanceId\\\":\\\"rm-uf667446pc955****\\\", \\\"CustomData\\\":{} }",
"LastRotationDate": "2023-07-05T08:22:03Z",
"RequestId": "6a3e9c36-1150-4881-84d3-eb8672fcafad",
"SecretName": "secret001",
"AutomaticRotation": "Enabled",
"SecretType": "Generic",
"VersionStages": {
"VersionStage": [
"{ \"VersionStage\": [ \t\"ACSCurrent\" \t] }"
]
},
"CiphertextForRecipient": "***CipherForRecipient***"
}
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.