SecretProps

class aws_cdk.aws_secretsmanager.SecretProps(*, description=None, encryption_key=None, generate_secret_string=None, removal_policy=None, replica_regions=None, secret_name=None, secret_string_beta1=None, secret_string_value=None)

Bases: object

The properties required to create a new secret in AWS Secrets Manager.

Parameters
  • description (Optional[str]) – An optional, human-friendly description of the secret. Default: - No description.

  • encryption_key (Optional[IKey]) – The customer-managed encryption key to use for encrypting the secret value. Default: - A default KMS key for the account and region is used.

  • generate_secret_string (Union[SecretStringGenerator, Dict[str, Any], None]) – Configuration for how to generate a secret value. Only one of secretString and generateSecretString can be provided. Default: - 32 characters with upper-case letters, lower-case letters, punctuation and numbers (at least one from each category), per the default values of SecretStringGenerator.

  • removal_policy (Optional[RemovalPolicy]) – Policy to apply when the secret is removed from this stack. Default: - Not set.

  • replica_regions (Optional[Sequence[Union[ReplicaRegion, Dict[str, Any]]]]) – A list of regions where to replicate this secret. Default: - Secret is not replicated

  • secret_name (Optional[str]) – A name for the secret. Note that deleting secrets from SecretsManager does not happen immediately, but after a 7 to 30 days blackout period. During that period, it is not possible to create another secret that shares the same name. Default: - A name is generated by CloudFormation.

  • secret_string_beta1 (Optional[SecretStringValueBeta1]) – (deprecated) Initial value for the secret. NOTE: It is **highly* encouraged to leave this field undefined and allow SecretsManager to create the secret value. The secret string – if provided – will be included in the output of the cdk as part of synthesis, and will appear in the CloudFormation template in the console. This can be secure(-ish) if that value is merely reference to another resource (or one of its attributes), but if the value is a plaintext string, it will be visible to anyone with access to the CloudFormation template (via the AWS Console, SDKs, or CLI). Specifies text data that you want to encrypt and store in this new version of the secret. May be a simple string value, or a string representation of a JSON structure. Only one of secretStringBeta1, secretStringValue, and generateSecretString can be provided. Default: - SecretsManager generates a new secret value.

  • secret_string_value (Optional[SecretValue]) – Initial value for the secret. NOTE: It is **highly* encouraged to leave this field undefined and allow SecretsManager to create the secret value. The secret string – if provided – will be included in the output of the cdk as part of synthesis, and will appear in the CloudFormation template in the console. This can be secure(-ish) if that value is merely reference to another resource (or one of its attributes), but if the value is a plaintext string, it will be visible to anyone with access to the CloudFormation template (via the AWS Console, SDKs, or CLI). Specifies text data that you want to encrypt and store in this new version of the secret. May be a simple string value, or a string representation of a JSON structure. Only one of secretStringBeta1, secretStringValue, and generateSecretString can be provided. Default: - SecretsManager generates a new secret value.

ExampleMetadata

infused

Example:

# Creates a new IAM user, access and secret keys, and stores the secret access key in a Secret.
user = iam.User(self, "User")
access_key = iam.AccessKey(self, "AccessKey", user=user)
secret_value = secretsmanager.SecretStringValueBeta1.from_token(access_key.secret_access_key.to_string())
secretsmanager.Secret(self, "Secret",
    secret_string_beta1=secret_value
)

Attributes

description

An optional, human-friendly description of the secret.

Default
  • No description.

Return type

Optional[str]

encryption_key

The customer-managed encryption key to use for encrypting the secret value.

Default
  • A default KMS key for the account and region is used.

Return type

Optional[IKey]

generate_secret_string

Configuration for how to generate a secret value.

Only one of secretString and generateSecretString can be provided.

Default

  • 32 characters with upper-case letters, lower-case letters, punctuation and numbers (at least one from each

category), per the default values of SecretStringGenerator.

Return type

Optional[SecretStringGenerator]

removal_policy

Policy to apply when the secret is removed from this stack.

Default
  • Not set.

Return type

Optional[RemovalPolicy]

replica_regions

A list of regions where to replicate this secret.

Default
  • Secret is not replicated

Return type

Optional[List[ReplicaRegion]]

secret_name

A name for the secret.

Note that deleting secrets from SecretsManager does not happen immediately, but after a 7 to 30 days blackout period. During that period, it is not possible to create another secret that shares the same name.

Default
  • A name is generated by CloudFormation.

Return type

Optional[str]

secret_string_beta1

(deprecated) Initial value for the secret.

NOTE: It is **highly* encouraged to leave this field undefined and allow SecretsManager to create the secret value. The secret string – if provided – will be included in the output of the cdk as part of synthesis, and will appear in the CloudFormation template in the console. This can be secure(-ish) if that value is merely reference to another resource (or one of its attributes), but if the value is a plaintext string, it will be visible to anyone with access to the CloudFormation template (via the AWS Console, SDKs, or CLI).

Specifies text data that you want to encrypt and store in this new version of the secret. May be a simple string value, or a string representation of a JSON structure.

Only one of secretStringBeta1, secretStringValue, and generateSecretString can be provided.

Default
  • SecretsManager generates a new secret value.

Deprecated

Use secretStringValue instead.

Stability

deprecated

Return type

Optional[SecretStringValueBeta1]

secret_string_value

Initial value for the secret.

NOTE: It is **highly* encouraged to leave this field undefined and allow SecretsManager to create the secret value. The secret string – if provided – will be included in the output of the cdk as part of synthesis, and will appear in the CloudFormation template in the console. This can be secure(-ish) if that value is merely reference to another resource (or one of its attributes), but if the value is a plaintext string, it will be visible to anyone with access to the CloudFormation template (via the AWS Console, SDKs, or CLI).

Specifies text data that you want to encrypt and store in this new version of the secret. May be a simple string value, or a string representation of a JSON structure.

Only one of secretStringBeta1, secretStringValue, and generateSecretString can be provided.

Default
  • SecretsManager generates a new secret value.

Return type

Optional[SecretValue]