DescribeSecret
Retrieves the details of a secret. It does not include the encrypted fields. Secrets Manager only returns fields populated with a value in the response.
Minimum permissions
To run this command, you must have the following permissions:
-
secretsmanager:DescribeSecret
Related operations
-
To create a secret, use CreateSecret.
-
To modify a secret, use UpdateSecret.
-
To retrieve the encrypted secret information in a version of the secret, use GetSecretValue.
-
To list all of the secrets in the AWS account, use ListSecrets.
Request Syntax
{
"SecretId": "string
"
}
Request Parameters
For information about the parameters that are common to all actions, see Common Parameters.
The request accepts the following data in JSON format.
- SecretId
-
The identifier of the secret whose details you want to retrieve. You can specify either the Amazon Resource Name (ARN) or the friendly name of the secret.
Note If you specify an ARN, we generally recommend that you specify a complete ARN. You can specify a partial ARN too—for example, if you don’t include the final hyphen and six random characters that Secrets Manager adds at the end of the ARN when you created the secret. A partial ARN match can work as long as it uniquely matches only one secret. However, if your secret has a name that ends in a hyphen followed by six characters (before Secrets Manager adds the hyphen and six characters to the ARN) and you try to use that as a partial ARN, then those characters cause Secrets Manager to assume that you’re specifying a complete ARN. This confusion can cause unexpected results. To avoid this situation, we recommend that you don’t create secret names ending with a hyphen followed by six characters.
If you specify an incomplete ARN without the random suffix, and instead provide the 'friendly name', you must not include the random suffix. If you do include the random suffix added by Secrets Manager, you receive either a ResourceNotFoundException or an AccessDeniedException error, depending on your permissions.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 2048.
Required: Yes
Response Syntax
{
"ARN": "string",
"CreatedDate": number,
"DeletedDate": number,
"Description": "string",
"KmsKeyId": "string",
"LastAccessedDate": number,
"LastChangedDate": number,
"LastRotatedDate": number,
"Name": "string",
"OwningService": "string",
"PrimaryRegion": "string",
"ReplicationStatus": [
{
"KmsKeyId": "string",
"LastAccessedDate": number,
"Region": "string",
"Status": "string",
"StatusMessage": "string"
}
],
"RotationEnabled": boolean,
"RotationLambdaARN": "string",
"RotationRules": {
"AutomaticallyAfterDays": number
},
"Tags": [
{
"Key": "string",
"Value": "string"
}
],
"VersionIdsToStages": {
"string" : [ "string" ]
}
}
Response Elements
If the action is successful, the service sends back an HTTP 200 response.
The following data is returned in JSON format by the service.
- ARN
-
The ARN of the secret.
Type: String
Length Constraints: Minimum length of 20. Maximum length of 2048.
- CreatedDate
-
The date you created the secret.
Type: Timestamp
- DeletedDate
-
This value exists if the secret is scheduled for deletion. Some time after the specified date and time, Secrets Manager deletes the secret and all of its versions.
If a secret is scheduled for deletion, then its details, including the encrypted secret information, is not accessible. To cancel a scheduled deletion and restore access, use RestoreSecret.
Type: Timestamp
- Description
-
The user-provided description of the secret.
Type: String
Length Constraints: Maximum length of 2048.
- KmsKeyId
-
The ARN or alias of the AWS KMS customer master key (CMK) that's used to encrypt the
SecretString
orSecretBinary
fields in each version of the secret. If you don't provide a key, then Secrets Manager defaults to encrypting the secret fields with the default AWS KMS CMK (the one namedawssecretsmanager
) for this account.Type: String
Length Constraints: Minimum length of 0. Maximum length of 2048.
- LastAccessedDate
-
The last date that this secret was accessed. This value is truncated to midnight of the date and therefore shows only the date, not the time.
Type: Timestamp
- LastChangedDate
-
The last date and time that this secret was modified in any way.
Type: Timestamp
- LastRotatedDate
-
The last date and time that the rotation process for this secret was invoked.
The most recent date and time that the Secrets Manager rotation process successfully completed. If the secret doesn't rotate, Secrets Manager returns a null value.
Type: Timestamp
- Name
-
The user-provided friendly name of the secret.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 256.
- OwningService
-
Returns the name of the service that created this secret.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
- PrimaryRegion
-
Specifies the primary region for secret replication.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
Pattern:
^([a-z]+-)+\d+$
- ReplicationStatus
-
Describes a list of replication status objects as
InProgress
,Failed
orInSync
.P
Type: Array of ReplicationStatusType objects
- RotationEnabled
-
Specifies whether automatic rotation is enabled for this secret.
To enable rotation, use RotateSecret with
AutomaticallyRotateAfterDays
set to a value greater than 0. To disable rotation, use CancelRotateSecret.Type: Boolean
- RotationLambdaARN
-
The ARN of a Lambda function that's invoked by Secrets Manager to rotate the secret either automatically per the schedule or manually by a call to
RotateSecret
.Type: String
Length Constraints: Minimum length of 0. Maximum length of 2048.
- RotationRules
-
A structure with the rotation configuration for this secret.
Type: RotationRulesType object
- Tags
-
The list of user-defined tags that are associated with the secret. To add tags to a secret, use TagResource. To remove tags, use UntagResource.
Type: Array of Tag objects
- VersionIdsToStages
-
A list of all of the currently assigned
VersionStage
staging labels and theVersionId
that each is attached to. Staging labels are used to keep track of the different versions during the rotation process.Note A version that does not have any staging labels attached is considered deprecated and subject to deletion. Such versions are not included in this list.
Type: String to array of strings map
Key Length Constraints: Minimum length of 32. Maximum length of 64.
Array Members: Minimum number of 1 item. Maximum number of 20 items.
Length Constraints: Minimum length of 1. Maximum length of 256.
Errors
For information about the errors that are common to all actions, see Common Errors.
- InternalServiceError
-
An error occurred on the server side.
HTTP Status Code: 500
- ResourceNotFoundException
-
We can't find the resource that you asked for.
HTTP Status Code: 400
Examples
Example
The following example shows how to get the details about 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.
Sample Request
POST / HTTP/1.1
Host: secretsmanager.region.domain
Accept-Encoding: identity
X-Amz-Target: secretsmanager.DescribeSecret
Content-Type: application/x-amz-json-1.1
User-Agent: <user-agent-string>
X-Amz-Date: <date>
Authorization: AWS4-HMAC-SHA256 Credential=<credentials>,SignedHeaders=<headers>, Signature=<signature>
Content-Length: <payload-size-bytes>
{
"SecretId": "MyTestDatabaseSecret"
}
Sample Response
HTTP/1.1 200 OK
Date: <date>
Content-Type: application/x-amz-json-1.1
Content-Length: <response-size-bytes>
Connection: keep-alive
x-amzn-RequestId: <request-id-guid>
{
"ARN": "arn:aws:secretsmanager:us-west-2:123456789012:secret:MyTestDatabaseSecret-a1b2c3",
"Name": "MyTestDatabaseSecret",
"Description": "My test database secret created with the CLI",
"LastChangedDate": 1523477145.729,
"RotationEnabled": true,
"RotationLambdaARN": "arn:aws:lambda:us-west-2:123456789012:function:MyTestRotationLambda",
"RotationRules": {
"AutomaticallyAfterDays": 30
},
"LastRotatedDate": 1525747253.72
"Tags": [
{
"Key": "SecondTag",
"Value": "AnotherValue"
},
{
"Key": "FirstTag",
"Value": "SomeValue"
}
],
"VersionIdsToStages": {
"EXAMPLE1-90ab-cdef-fedc-ba987SECRET1": [
"AWSPREVIOUS"
],
"EXAMPLE2-90ab-cdef-fedc-ba987SECRET2": [
"AWSCURRENT"
]
}
}
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: