CmdID / aws / aws secretsmanager
aws secretsmanager list-secrets
Lists the secrets that are stored by Secrets Manager in the Amazon Web Services account, not including secrets that are marked for deletion. AWS CLI reference
3 examples 6 options Its page in the AWS CLI reference
Examples
Example 1: To list the secrets in your account
The following list-secrets example gets a list of the secrets in your account.
aws secretsmanager list-secretsIdentifyIts output
{
"SecretList": [
{
"ARN": "arn:aws:secretsmanager:us-west-2:123456789012:secret:MyTestSecret-a1b2c3",
"Name": "MyTestSecret",
"LastChangedDate": 1523477145.729,
"SecretVersionsToStages": {
"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111": [
"AWSCURRENT"
]
}
},
{
"ARN": "arn:aws:secretsmanager:us-west-2:123456789012:secret:AnotherSecret-d4e5f6",
"Name": "AnotherSecret",
"LastChangedDate": 1523482025.685,
"SecretVersionsToStages": {
"a1b2c3d4-5678-90ab-cdef-EXAMPLE22222": [
"AWSCURRENT"
]
}
}
]
}For more information, see Find a secret in the Secrets Manager User Guide.
Example 2: To filter the list of secrets in your account
The following list-secrets example gets a list of the secrets in your account that have Test in the name. Filtering by name is case sensitive.
aws secretsmanager list-secrets --filters Key="name",Values="Test"Identify--filtersThe filters to apply to the list of secrets.Its output
{
"SecretList": [
{
"ARN": "arn:aws:secretsmanager:us-west-2:123456789012:secret:MyTestSecret-a1b2c3",
"Name": "MyTestSecret",
"LastChangedDate": 1523477145.729,
"SecretVersionsToStages": {
"a1b2c3d4-5678-90ab-cdef-EXAMPLE11111": [
"AWSCURRENT"
]
}
}
]
}For more information, see Find a secret in the Secrets Manager User Guide.
Example 3: To list the secrets in your account managed by another service
The following list-secrets example returns the secrets in your account that are managed by Amazon RDS.
aws secretsmanager list-secrets --filters Key="owning-service",Values="rds"Identify--filtersThe filters to apply to the list of secrets.Its output, shortened
{
"SecretList": [
{
"Name": "rds!cluster-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
"Tags": [
{
"Value": "arn:aws:rds:us-west-2:123456789012:cluster:database-1",
"Key": "aws:rds:primaryDBClusterArn"
},
{
"Value": "rds",
"Key": "aws:secretsmanager:owningService"
}
],
"RotationRules": {
"AutomaticallyAfterDays": 1
},
"LastChangedDate": 1673477781.275,
"LastRotatedDate": 1673477781.26,
"SecretVersionsToStages": {
"a1b2c3d4-5678-90ab-cdef-EXAMPLE33333": [
"AWSPREVIOUS"
],
"a1b2c3d4-5678-90ab-cdef-EXAMPLE44444": [
"AWSCURRENT",
"AWSPENDING"
]
},
"OwningService": "rds",
"RotationEnabled": true,
… 7 more linesFor more information, see Secrets managed by other services in the Secrets Manager User Guide.
Options
--filtersThe filters to apply to the list of secrets.--include-planned-deletionSpecifies whether to include secrets scheduled for deletion.--max-resultsThe number of results to include in the response.--next-tokenA token that indicates where the output should continue from, if a previous call did not show all results.--sort-byIf not specified, secrets are listed by CreatedDate.--sort-orderSecrets are listed by CreatedDate.