DescribeSecret
Retrieves the details of a secret. It does not include the encrypted secret value. Secrets Manager only returns fields that have a value in the response.
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:DescribeSecret
.
For more information, see
IAM policy actions for Secrets Manager and Authentication
and access control in Secrets Manager.
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 ARN or name of the secret.
For an ARN, we recommend that you specify a complete ARN rather than a partial ARN. See Finding a secret from a partial ARN.
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",
"NextRotationDate": number,
"OwningService": "string",
"PrimaryRegion": "string",
"ReplicationStatus": [
{
"KmsKeyId": "string",
"LastAccessedDate": number,
"Region": "string",
"Status": "string",
"StatusMessage": "string"
}
],
"RotationEnabled": boolean,
"RotationLambdaARN": "string",
"RotationRules": {
"AutomaticallyAfterDays": number,
"Duration": "string",
"ScheduleExpression": "string"
},
"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 the secret was created.
Type: Timestamp
- DeletedDate
-
The date the secret is scheduled for deletion. If it is not scheduled for deletion, this field is omitted. When you delete a secret, Secrets Manager requires a recovery window of at least 7 days before deleting the secret. Some time after the deleted date, Secrets Manager deletes the secret, including all of its versions.
If a secret is scheduled for deletion, then its details, including the encrypted secret value, is not accessible. To cancel a scheduled deletion and restore access to the secret, use RestoreSecret.
Type: Timestamp
- Description
-
The description of the secret.
Type: String
Length Constraints: Maximum length of 2048.
- KmsKeyId
-
The key ID or alias ARN of the AWS KMS key that Secrets Manager uses to encrypt the secret value. If the secret is encrypted with the AWS managed key
aws/secretsmanager
, this field is omitted. Secrets created using the console use an AWS KMS key ID.Type: String
Length Constraints: Minimum length of 0. Maximum length of 2048.
- LastAccessedDate
-
The date that the secret was last accessed in the Region. This field is omitted if the secret has never been retrieved in the Region.
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 Secrets Manager rotated the secret. If the secret isn't configured for rotation or rotation has been disabled, Secrets Manager returns null.
Type: Timestamp
- Name
-
The name of the secret.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 256.
- NextRotationDate
-
The next rotation is scheduled to occur on or before this date. If the secret isn't configured for rotation or rotation has been disabled, Secrets Manager returns null. If rotation fails, Secrets Manager retries the entire rotation process multiple times. If rotation is unsuccessful, this date may be in the past.
This date represents the latest date that rotation will occur, but it is not an approximate rotation date. In some cases, for example if you turn off automatic rotation and then turn it back on, the next rotation may occur much sooner than this date.
Type: Timestamp
- OwningService
-
The ID of the service that created this secret. For more information, see Secrets managed by other AWS services.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
- PrimaryRegion
-
The Region the secret is in. If a secret is replicated to other Regions, the replicas are listed in
ReplicationStatus
.Type: String
Length Constraints: Minimum length of 1. Maximum length of 128.
Pattern:
^([a-z]+-)+\d+$
- ReplicationStatus
-
A list of the replicas of this secret and their status:
-
Failed
, which indicates that the replica was not created. -
InProgress
, which indicates that Secrets Manager is in the process of creating the replica. -
InSync
, which indicates that the replica was created.
Type: Array of ReplicationStatusType objects
-
- RotationEnabled
-
Specifies whether automatic rotation is turned on for this secret. If the secret has never been configured for rotation, Secrets Manager returns null.
To turn on rotation, use RotateSecret. To turn off rotation, use CancelRotateSecret.
Type: Boolean
- RotationLambdaARN
-
The ARN of the Lambda function that Secrets Manager invokes to rotate the secret.
Type: String
Length Constraints: Minimum length of 0. Maximum length of 2048.
- RotationRules
-
The rotation schedule and Lambda function for this secret. If the secret previously had rotation turned on, but it is now turned off, this field shows the previous rotation schedule and rotation function. If the secret never had rotation turned on, this field is omitted.
Type: RotationRulesType object
- Tags
-
The list of tags attached to the secret. To add tags to a secret, use TagResource. To remove tags, use UntagResource.
Type: Array of Tag objects
- VersionIdsToStages
-
A list of the versions of the secret that have staging labels attached. Versions that don't have staging labels are considered deprecated and Secrets Manager can delete them.
Secrets Manager uses staging labels to indicate the status of a secret version during rotation. The three staging labels for rotation are:
-
AWSCURRENT
, which indicates the current version of the secret. -
AWSPENDING
, which indicates the version of the secret that contains new secret information that will become the next current version when rotation finishes.During rotation, Secrets Manager creates an
AWSPENDING
version ID before creating the new secret version. To check if a secret version exists, call GetSecretValue. -
AWSPREVIOUS
, which indicates the previous current version of the secret. You can use this as the last known good version.
For more information about rotation and staging labels, see How rotation works.
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
- InvalidParameterException
-
The parameter name or value is invalid.
HTTP Status Code: 400
- ResourceNotFoundException
-
Secrets Manager 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,
"LastAccessedDate": 1606269226,
"RotationEnabled": true,
"RotationLambdaARN": "arn:aws:lambda:us-west-2:123456789012:function:MyTestRotationLambda",
"RotationRules": {
"AutomaticallyAfterDays": 14,
"ScheduleExpression": "cron(0 16 1,15 * ? *)",
"Duration": "2h"
},
"LastRotatedDate": 1525747253.72,
"NextRotationDate": 1665165599000,
"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: