Skip to content

SecretsManagerClient.create_secret

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

Model summary (excerpt): Creates a new secret. A secret can be a password, a set of credentials such as a user name and password, an OAuth token, or other secret information that you store in an encrypted form in Secrets Manager. The secret also includes the connection information to access a database or other service. Secrets Manager does not encrypt this connection information. A secret in Secrets Manager consists...

Install and imports

python -m pip install "rboto[secrets-manager]==0.4.0"
from rboto import SecretsManagerClient
from collections.abc import Sequence
from rboto_secrets_manager.types import (
    CreateSecretOutput,
    ReplicaRegionType,
    Tag,
)

Signature

async def create_secret(
    *,
    name: str,
    client_request_token: str | None = None,
    description: str | None = None,
    kms_key_id: str | None = None,
    secret_binary: bytes | None = None,
    secret_string: str | None = None,
    tags: Sequence[Tag] | None = None,
    add_replica_regions: Sequence[ReplicaRegionType] | None = None,
    force_overwrite_replica_secret: bool | None = None,
    type: str | None = None,
    cross_account_primary_arn: str | None = None,
) -> CreateSecretOutput: ...

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)
name Yes The name of the new secret. The secret name can contain ASCII letters, numbers, and the following characters: /_+=.@- Do not end your secret name with a hyphen followed by six characters. If you do so, you risk confusion and unexpected results when searching for a secret by partial ARN. Secrets Manager automatically adds a hyphen and six random characters after the secret name at the end of...
client_request_token No If you include SecretString or SecretBinary , then Secrets Manager creates an initial version for the secret, and this parameter specifies the unique identifier for the new version. If you use the Amazon Web Services CLI or one of the Amazon Web Services SDKs to call this operation, then you can leave this parameter empty. The CLI or SDK generates a random UUID for you and includes it as the...
description No The description of the secret.
kms_key_id No The ARN, key ID, or alias of the KMS key that Secrets Manager uses to encrypt the secret value in the secret. An alias is always prefixed by alias/ , for example alias/aws/secretsmanager . For more information, see About aliases . To use a KMS key in a different account, use the key ARN or the alias ARN. If you don't specify this value, then Secrets Manager uses the key aws/secretsmanager . If...
secret_binary No The binary data to encrypt and store in the new version of the secret. We recommend that you store your binary data in a file and then pass the contents of the file as a parameter. Either SecretString or SecretBinary must have a value, but not both. This parameter is not available in the Secrets Manager console. Sensitive: This field contains sensitive information, so the service does not...
secret_string No The text data to encrypt and store in this new version of the secret. We recommend you use a JSON structure of key/value pairs for your secret value. Either SecretString or SecretBinary must have a value, but not both. If you create a secret by using the Secrets Manager console then Secrets Manager puts the protected secret text in only the SecretString parameter. The Secrets Manager console...
tags No A list of tags to attach to the secret. Each tag is a key and value pair of strings in a JSON text string, for example: [{"Key":"CostCenter","Value":"12345"},{"Key":"environment","Value":"production"}] Secrets Manager tag key names are case sensitive. A tag with the key "ABC" is a different tag from one with key "abc". If you check tags in permissions policies as part of your security...
add_replica_regions No A list of Regions and KMS keys to replicate secrets.
force_overwrite_replica_secret No Specifies whether to overwrite a secret with the same name in the destination Region. By default, secrets aren't overwritten.
type No The exact string that identifies the partner that holds the external secret. For more information, see Using Secrets Manager managed external secrets .
cross_account_primary_arn No The ARN of a primary secret in another Amazon Web Services account. Include this field to create a cross-account replica secret that receives replicated data from that primary secret. The primary secret must be in the same Amazon Web Services Region and partition as the replica, and you must specify a customer managed KMS key in KmsKeyId . You can't include SecretString , SecretBinary ,...

Output

CreateSecretOutput.

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 —
replication_status list[ReplicationStatusTypeOutput] | None Always present ReplicationStatusTypeOutput

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

CreateSecretOutput, ReplicaRegionType, Tag

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, EncryptionFailureError, InternalServiceError, InvalidParameterError, InvalidRequestError, LimitExceededError, MalformedPolicyDocumentError, PreconditionNotMetError, ResourceExistsError, ResourceNotFoundError.

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

Service guide · Pinned model