Skip to content

list_secrets

list_secrets(
    *,
    config_overrides: Optional[SecretsManagerClientConfig] = None,
    include_planned_deletion: Optional[BooleanType] = None,
    max_results: Optional[MaxResultsType] = None,
    next_token: Optional[NextTokenType] = None,
    filters: Optional[FiltersListType] = None,
    sort_order: Optional[SortOrderType] = None,
    sort_by: Optional[SortByType] = None,
) -> ListSecretsResponse

Lists the secrets that are stored by Secrets Manager in the Amazon Web Services account, not including secrets that are marked for deletion. To see secrets marked for deletion, use the Secrets Manager console.

All Secrets Manager operations are eventually consistent. ListSecrets might not reflect changes from the last five minutes. You can get more recent information for a specific secret by calling DescribeSecret.

To list the versions of a secret, use ListSecretVersionIds.

To retrieve the values for the secrets, call BatchGetSecretValue or GetSecretValue.

For information about finding secrets in the console, see Find secrets in Secrets Manager.

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 CloudTrail.

Required permissions: secretsmanager:ListSecrets. For more information, see IAM policy actions for Secrets Manager and Authentication and access control in Secrets Manager.

Parameters:

  • include_planned_deletion (Optional[BooleanType], default: None ) –

    Specifies whether to include secrets scheduled for deletion. By default, secrets scheduled for deletion aren't included.

  • max_results (Optional[MaxResultsType], default: None ) –

    The number of results to include in the response.

    If there are more results available, in the response, Secrets Manager includes NextToken. To get the next results, call ListSecrets again with the value from NextToken.

  • next_token (Optional[NextTokenType], default: None ) –

    A token that indicates where the output should continue from, if a previous call did not show all results. To get the next results, call ListSecrets again with this value.

  • filters (Optional[FiltersListType], default: None ) –

    The filters to apply to the list of secrets.

  • sort_order (Optional[SortOrderType], default: None ) –

    Secrets are listed by CreatedDate.

  • sort_by (Optional[SortByType], default: None ) –

    If not specified, secrets are listed by CreatedDate.

Raises:

Examples:

To list the secrets in your account The following example shows how to list all of the secrets in your account.

>>> client.list_secrets()
Source code in docs_src/capo_secrets_manager/_services/secrets_manager.py
def list_secrets(
    self,
    *,
    config_overrides: Optional[SecretsManagerClientConfig] = None,
    include_planned_deletion: Optional[
        "capo_secrets_manager.types.boolean_type.BooleanType"
    ] = None,
    max_results: Optional[
        "capo_secrets_manager.types.max_results_type.MaxResultsType"
    ] = None,
    next_token: Optional[
        "capo_secrets_manager.types.next_token_type.NextTokenType"
    ] = None,
    filters: Optional[
        "capo_secrets_manager.types.filters_list_type.FiltersListType"
    ] = None,
    sort_order: Optional[
        "capo_secrets_manager.types.sort_order_type.SortOrderType"
    ] = None,
    sort_by: Optional["capo_secrets_manager.types.sort_by_type.SortByType"] = None,
) -> "capo_secrets_manager.types.list_secrets_response.ListSecretsResponse":
    """<p>Lists the secrets that are stored by Secrets Manager in the Amazon Web Services account, not including secrets that are marked for deletion. To see secrets marked for deletion, use the Secrets Manager console.</p> <p>All Secrets Manager operations are eventually consistent. ListSecrets might not reflect changes from the last five minutes. You can get more recent information for a specific secret by calling <a>DescribeSecret</a>.</p> <p>To list the versions of a secret, use <a>ListSecretVersionIds</a>.</p> <p>To retrieve the values for the secrets, call <a>BatchGetSecretValue</a> or <a>GetSecretValue</a>.</p> <p>For information about finding secrets in the console, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/manage_search-secret.html">Find secrets in Secrets Manager</a>.</p> <p>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 <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/retrieve-ct-entries.html">Logging Secrets Manager events with CloudTrail</a>.</p> <p> <b>Required permissions: </b> <code>secretsmanager:ListSecrets</code>. For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/reference_iam-permissions.html#reference_iam-permissions_actions"> IAM policy actions for Secrets Manager</a> and <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access.html">Authentication and access control in Secrets Manager</a>. </p>

    Args:
        include_planned_deletion: <p>Specifies whether to include secrets scheduled for deletion. By default, secrets scheduled for deletion aren't included.</p>
        max_results: <p>The number of results to include in the response.</p> <p>If there are more results available, in the response, Secrets Manager includes <code>NextToken</code>. To get the next results, call <code>ListSecrets</code> again with the value from <code>NextToken</code>.</p>
        next_token: <p>A token that indicates where the output should continue from, if a previous call did not show all results. To get the next results, call <code>ListSecrets</code> again with this value.</p>
        filters: <p>The filters to apply to the list of secrets.</p>
        sort_order: <p>Secrets are listed by <code>CreatedDate</code>. </p>
        sort_by: <p>If not specified, secrets are listed by <code>CreatedDate</code>.</p>

    Raises:
        capo_secrets_manager.errors.internal_service_error.InternalServiceError: <p>An error occurred on the server side.</p>
        capo_secrets_manager.errors.invalid_next_token_exception.InvalidNextTokenException: <p>The <code>NextToken</code> value is invalid.</p>
        capo_secrets_manager.errors.invalid_parameter_exception.InvalidParameterException: <p>The parameter name or value is invalid.</p>
        capo_secrets_manager.errors.invalid_request_exception.InvalidRequestException: <p>A parameter value is not valid for the current state of the resource.</p> <p>Possible causes:</p> <ul> <li> <p>The secret is scheduled for deletion.</p> </li> <li> <p>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. </p> </li> <li> <p>The secret is managed by another service, and you must use that service to update it. For more information, see <a href="https://docs.aws.amazon.com/secretsmanager/latest/userguide/service-linked-secrets.html">Secrets managed by other Amazon Web Services services</a>.</p> </li> </ul>
        capo_secrets_manager.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To list the secrets in your account
        The following example shows how to list all of the secrets in your account.

        >>> client.list_secrets()
    """

    def _handler(
        req: "OperationRequest[capo_secrets_manager.types.list_secrets_request.ListSecretsRequest]",
    ) -> OperationResponse[
        "capo_secrets_manager.types.list_secrets_response.ListSecretsResponse"
    ]:
        import capo_secrets_manager._operations.secretsmanager.list_secrets

        output, http_response = (
            capo_secrets_manager._operations.secretsmanager.list_secrets.list_secrets(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListSecrets")
    )
    input_: capo_secrets_manager.types.list_secrets_request.ListSecretsRequest = {}
    if include_planned_deletion is not None:
        input_["include_planned_deletion"] = include_planned_deletion
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token
    if filters is not None:
        input_["filters"] = filters
    if sort_order is not None:
        input_["sort_order"] = sort_order
    if sort_by is not None:
        input_["sort_by"] = sort_by

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output