DatabaseSecret

class aws_cdk.aws_redshift.DatabaseSecret(scope, id, *, username, encryption_key=None)

Bases: aws_cdk.aws_secretsmanager.Secret

A database secret.

stability :stability: experimental resource: :resource:: AWS::SecretsManager::Secret

__init__(scope, id, *, username, encryption_key=None)
Parameters
  • scope (Construct) –

  • id (str) –

  • username (str) – The username.

  • encryption_key (Optional[IKey]) – The KMS key to use to encrypt the secret. Default: default master key

stability :stability: experimental

Return type

None

Methods

add_rotation_schedule(id, *, rotation_lambda, automatically_after=None)

Adds a rotation schedule to the secret.

Parameters
  • id (str) –

  • rotation_lambda (IFunction) – The Lambda function that can rotate the secret.

  • automatically_after (Optional[Duration]) – Specifies the number of days after the previous rotation before Secrets Manager triggers the next automatic rotation. Default: Duration.days(30)

Return type

RotationSchedule

add_target_attachment(id, *, target)

Adds a target attachment to the secret.

Parameters

return :rtype: SecretTargetAttachment :return: an AttachedSecret

deprecated :deprecated: use attach() instead

stability :stability: deprecated

add_to_resource_policy(statement)

Adds a statement to the IAM resource policy associated with this secret.

If this secret was created in this stack, a resource policy will be automatically created upon the first call to addToResourcePolicy. If the secret is imported, then this is a no-op.

Parameters

statement (PolicyStatement) –

Return type

AddToResourcePolicyResult

attach(target)

Attach a target to this secret.

Parameters

target (ISecretAttachmentTarget) – The target to attach.

return :rtype: ISecret :return: An attached secret

deny_account_root_delete()

Denies the DeleteSecret action to all principals within the current account.

Return type

None

grant_read(grantee, version_stages=None)

Grants reading the secret value to some role.

Parameters
  • grantee (IGrantable) –

  • version_stages (Optional[List[str]]) –

Return type

Grant

grant_write(grantee)

Grants writing and updating the secret value to some role.

Parameters

grantee (IGrantable) –

Return type

Grant

secret_value_from_json(json_field)

Interpret the secret as a JSON object and return a field’s value from it as a SecretValue.

Parameters

json_field (str) –

Return type

SecretValue

to_string()

Returns a string representation of this construct.

Return type

str

Attributes

encryption_key

The customer-managed encryption key that is used to encrypt this secret, if any.

When not specified, the default KMS key for the account and region is being used.

Return type

Optional[IKey]

env

The environment this resource belongs to.

For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.

Return type

ResourceEnvironment

node

The construct tree node associated with this construct.

Return type

ConstructNode

secret_arn

The ARN of the secret in AWS Secrets Manager.

Return type

str

secret_value

Retrieve the value of the stored secret as a SecretValue.

Return type

SecretValue

stack

The stack in which this resource is defined.

Return type

Stack

Static Methods

classmethod from_secret_arn(scope, id, secret_arn)
Parameters
  • scope (Construct) –

  • id (str) –

  • secret_arn (str) –

Return type

ISecret

classmethod from_secret_attributes(scope, id, *, secret_arn, encryption_key=None)

Import an existing secret into the Stack.

Parameters
  • scope (Construct) – the scope of the import.

  • id (str) – the ID of the imported Secret in the construct tree.

  • secret_arn (str) – The ARN of the secret in SecretsManager.

  • encryption_key (Optional[IKey]) – The encryption key that is used to encrypt the secret, unless the default SecretsManager key is used.

Return type

ISecret

classmethod is_construct(x)

Return whether the given object is a Construct.

Parameters

x (Any) –

Return type

bool