GetSecretValue
Retrieves the contents of the encrypted fields SecretString or SecretBinary from the specified version of a secret, whichever contains content.
To retrieve the values for a group of secrets, call BatchGetSecretValue .
We recommend that you cache your secret values by using client-side caching. Caching secrets improves speed and reduces your costs. For more information, see Cache secrets for your applications .
To retrieve the version of a secret, use VersionStage and specify AWSPREVIOUS. To revert to the version of a secret, call UpdateSecretVersionStage .
Secrets Manager generates a CloudTrail log entry when you call this action. Do not include sensitive information in request parameters because it might be logged. For more information, see Logging Secrets Manager events with AWS CloudTrail .
Required permissions: secretsmanager:GetSecretValue . If the secret is encrypted using a customer-managed key instead of the AWS managed key aws/secretsmanager , then you also need kms:Decrypt permissions for that key. For more information, see IAM policy actions for Secrets Manager and Authentication and access control in Secrets Manager .
For information the parameters that are common to all actions, see Common Parameters .
The request accepts the following data in JSON format.
The ARN or name of the secret to retrieve. To retrieve a secret from another account, you must use an ARN.
For an ARN, we recommend that you specify a complete ARN rather than a partial ARN. See Finding a secret from a partial ARN .
Length Constraints: Minimum length of 1. Maximum length of 2048.
The unique identifier of the version of the secret to retrieve. If you include both this parameter and VersionStage , the two parameters must refer to the same secret version. If you don't specify either a VersionStage or VersionId , then Secrets Manager returns the AWSCURRENT version.
This value is typically a UUID-type value with 32 hexadecimal digits.
Length Constraints: Minimum length of 32. Maximum length of 64.
The staging label of the version of the secret to retrieve.
Secrets Manager uses staging labels to keep track of different versions during the rotation process. If you include both this parameter and VersionId , the two parameters must refer to the same secret version. If you don't specify either a VersionStage or VersionId , Secrets Manager returns the AWSCURRENT version.
Length Constraints: Minimum length of 1. Maximum length of 256.
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
The ARN of the secret.
Length Constraints: Minimum length of 20. Maximum length of 2048.
The date and time that this version of the secret was created. If you don't specify which version in VersionId or VersionStage , then Secrets Manager uses the AWSCURRENT version.
The friendly name of the secret.
Length Constraints: Minimum length of 1. Maximum length of 256.
The decrypted secret value, if the secret value was originally provided as binary data in the form of a byte array. When you retrieve a SecretBinary using the HTTP API, the Python SDK, or the AWS CLI, the value is Base64-encoded. Otherwise, it is not encoded.
If the secret was created by using the Secrets Manager console, or if the secret value was originally provided as a string, then this field is omitted. The secret value appears in SecretString instead.
Sensitive: This field contains sensitive information, so the service does not include it in AWS CloudTrail log entries. If you create your own log entries, you must also avoid logging the information in this field.
Type: Base64-encoded binary data object
Length Constraints: Minimum length of 1. Maximum length of 65536.
The decrypted secret value, if the secret value was originally provided as a string or through the Secrets Manager console.
If this secret was created by using the console, then Secrets Manager stores the information as a JSON structure of key/value pairs.
Sensitive: This field contains sensitive information, so the service does not include it in AWS CloudTrail log entries. If you create your own log entries, you must also avoid logging the information in this field.
Length Constraints: Minimum length of 1. Maximum length of 65536.
The unique identifier of this version of the secret.
Length Constraints: Minimum length of 32. Maximum length of 64.
A list of all of the staging labels currently attached to this version of the secret.
Type: Array of strings
Array Members: Minimum number of 1 item. Maximum number of 20 items.
Length Constraints: Minimum length of 1. Maximum length of 256.
For information the errors that are common to all actions, see Common Errors .
Secrets Manager can't decrypt the protected secret text using the provided KMS key.
HTTP Status Code: 400
An error occurred on the server side.
HTTP Status Code: 500
The parameter name or value is invalid.
HTTP Status Code: 400
A parameter value is not valid for the current state of the resource.
The secret is scheduled for deletion.
The secret is scheduled for deletion.
You tried to enable rotation on a secret that doesn't already have a Lambda function ARN configured and you didn't include such an ARN as a parameter in this call.
You tried to enable rotation on a secret that doesn't already have a Lambda function ARN configured and you didn't include such an ARN as a parameter in this call.
The secret is managed by another service, and you must use that service to update it. For more information, see Secrets managed by other AWS services .
The secret is managed by another service, and you must use that service to update it. For more information, see Secrets managed by other AWS services .
HTTP Status Code: 400
Secrets Manager can't find the resource that you asked for.
HTTP Status Code: 400
The following example shows how to retrieve the secret value from a secret. The JSON request string input and response output displays formatted code with white space and line breaks for better readability. Submit your input as a single line JSON string.
For more information using this API in one of the language-specific AWS SDKs, see the following:
AWS Command Line Interface V2
AWS Command Line Interface V2
AWS SDK for JavaScript V3
AWS SDK for JavaScript V3
AWS SDK for Python (Boto3)
AWS SDK for Python (Boto3)
Thanks for letting us know we're doing a good job!
If you've got a moment, please tell us what we did right so we can do more of it.
Thanks for letting us know this page needs work. We're sorry we let you down.
If you've got a moment, please tell us how we can make the documentation better.
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
