Skip to content

SecretsManagerClient.get_secret_value

rboto-secrets-manager==0.4.0 · Service index · Types

Model summary (excerpt): 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...

Install and imports

python -m pip install "rboto[secrets-manager]==0.4.0"
from rboto import SecretsManagerClient
from rboto_secrets_manager.types import (
    GetSecretValueOutput,
)

Signature

async def get_secret_value(
    *,
    secret_id: str,
    version_id: str | None = None,
    version_stage: str | None = None,
) -> GetSecretValueOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
secret_id Yes 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 .
version_id No 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.
version_stage No 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.

Output

GetSecretValueOutput.

Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.

Field Type Presence References
arn str | None Always present —
name str | None Always present —
version_id str | None Always present —
secret_binary bytes | None Always present —
secret_string str | None Always present —
version_stages list[str] | None Always present —
created_date str | None Always present —

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

GetSecretValueOutput

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

No output stream.

Errors

Import from rboto_secrets_manager.exceptions:

DecryptionFailureError, InternalServiceError, InvalidParameterError, InvalidRequestError, ResourceNotFoundError.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Example

Complete, type-checked service example. Replace its placeholders and configure credentials before running it.

import asyncio
import json

from rboto import SecretsManagerClient


async def main() -> None:
    client = SecretsManagerClient(region="us-east-1")
    response = await client.get_secret_value(secret_id="application/config")
    if response.secret_string is None:
        raise ValueError("Expected a text secret")
    # Pass the value to your application; do not print secret contents.
    settings = json.loads(response.secret_string)
    print("Loaded settings:", len(settings))


if __name__ == "__main__":
    asyncio.run(main())

Service guide · Pinned model