Class: AWSCDK::RDS::DatabaseSecretProps

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
rds/database_secret_props.rb

Overview

Construction properties for a DatabaseSecret.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(username:, dbname: nil, encryption_key: nil, exclude_characters: nil, master_secret: nil, replace_on_password_criteria_changes: nil, replica_regions: nil, secret_name: nil) ⇒ DatabaseSecretProps

Returns a new instance of DatabaseSecretProps.

Parameters:

  • username (String)

    The username.

  • dbname (String, nil) (defaults to: nil)

    The database name, if not using the default one.

  • encryption_key (AWSCDK::KMS::IKey, nil) (defaults to: nil)

    The KMS key to use to encrypt the secret.

  • exclude_characters (String, nil) (defaults to: nil)

    Characters to not include in the generated password.

  • master_secret (AWSCDK::SecretsManager::ISecret, nil) (defaults to: nil)

    The master secret which will be used to rotate this secret.

  • replace_on_password_criteria_changes (Boolean, nil) (defaults to: nil)

    Whether to replace this secret when the criteria for the password change.

  • replica_regions (Array<AWSCDK::SecretsManager::ReplicaRegion>, nil) (defaults to: nil)

    A list of regions where to replicate this secret.

  • secret_name (String, nil) (defaults to: nil)

    A name for the secret.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'rds/database_secret_props.rb', line 15

def initialize(username:, dbname: nil, encryption_key: nil, exclude_characters: nil, master_secret: nil, replace_on_password_criteria_changes: nil, replica_regions: nil, secret_name: nil)
  @username = username
  Jsii::Type.check_type(@username, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "username")
  @dbname = dbname
  Jsii::Type.check_type(@dbname, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "dbname") unless @dbname.nil?
  @encryption_key = encryption_key
  Jsii::Type.check_type(@encryption_key, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfa21zLklLZXkifQ==")), "encryptionKey") unless @encryption_key.nil?
  @exclude_characters = exclude_characters
  Jsii::Type.check_type(@exclude_characters, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "excludeCharacters") unless @exclude_characters.nil?
  @master_secret = master_secret
  Jsii::Type.check_type(@master_secret, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfc2VjcmV0c21hbmFnZXIuSVNlY3JldCJ9")), "masterSecret") unless @master_secret.nil?
  @replace_on_password_criteria_changes = replace_on_password_criteria_changes
  Jsii::Type.check_type(@replace_on_password_criteria_changes, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "replaceOnPasswordCriteriaChanges") unless @replace_on_password_criteria_changes.nil?
  @replica_regions = replica_regions.is_a?(Array) ? replica_regions.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::SecretsManager::ReplicaRegion.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : replica_regions
  Jsii::Type.check_type(@replica_regions, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19zZWNyZXRzbWFuYWdlci5SZXBsaWNhUmVnaW9uIn0sImtpbmQiOiJhcnJheSJ9fQ==")), "replicaRegions") unless @replica_regions.nil?
  @secret_name = secret_name
  Jsii::Type.check_type(@secret_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "secretName") unless @secret_name.nil?
end

Instance Attribute Details

#dbnameString? (readonly)

Note:

Default: - whatever the secret generates after the attach method is run

The database name, if not using the default one.

Returns:

  • (String, nil)


42
43
44
# File 'rds/database_secret_props.rb', line 42

def dbname
  @dbname
end

#encryption_keyAWSCDK::KMS::IKey? (readonly)

Note:

Default: default master key

The KMS key to use to encrypt the secret.

Returns:



47
48
49
# File 'rds/database_secret_props.rb', line 47

def encryption_key
  @encryption_key
end

#exclude_charactersString? (readonly)

Note:

Default: " %+~`#$&*()|[]{}:;<>?!'/@\"\"

Characters to not include in the generated password.

Returns:

  • (String, nil)


52
53
54
# File 'rds/database_secret_props.rb', line 52

def exclude_characters
  @exclude_characters
end

#master_secretAWSCDK::SecretsManager::ISecret? (readonly)

Note:

Default: - no master secret information will be included

The master secret which will be used to rotate this secret.



57
58
59
# File 'rds/database_secret_props.rb', line 57

def master_secret
  @master_secret
end

#replace_on_password_criteria_changesBoolean? (readonly)

Note:

Default: false

Whether to replace this secret when the criteria for the password change.

This is achieved by overriding the logical id of the AWS::SecretsManager::Secret with a hash of the options that influence the password generation. This way a new secret will be created when the password is regenerated and the cluster or instance consuming this secret will have its credentials updated.

Returns:

  • (Boolean, nil)


67
68
69
# File 'rds/database_secret_props.rb', line 67

def replace_on_password_criteria_changes
  @replace_on_password_criteria_changes
end

#replica_regionsArray<AWSCDK::SecretsManager::ReplicaRegion>? (readonly)

Note:

Default: - Secret is not replicated

A list of regions where to replicate this secret.

Returns:



72
73
74
# File 'rds/database_secret_props.rb', line 72

def replica_regions
  @replica_regions
end

#secret_nameString? (readonly)

Note:

Default: - A name is generated by CloudFormation.

A name for the secret.

Returns:

  • (String, nil)


77
78
79
# File 'rds/database_secret_props.rb', line 77

def secret_name
  @secret_name
end

#usernameString (readonly)

The username.

Returns:

  • (String)


37
38
39
# File 'rds/database_secret_props.rb', line 37

def username
  @username
end

Class Method Details

.jsii_propertiesObject



79
80
81
82
83
84
85
86
87
88
89
90
# File 'rds/database_secret_props.rb', line 79

def self.jsii_properties
  {
    :username => "username",
    :dbname => "dbname",
    :encryption_key => "encryptionKey",
    :exclude_characters => "excludeCharacters",
    :master_secret => "masterSecret",
    :replace_on_password_criteria_changes => "replaceOnPasswordCriteriaChanges",
    :replica_regions => "replicaRegions",
    :secret_name => "secretName",
  }
end

Instance Method Details

#to_jsiiObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'rds/database_secret_props.rb', line 92

def to_jsii
  result = {}
  result.merge!({
    "username" => @username,
    "dbname" => @dbname,
    "encryptionKey" => @encryption_key,
    "excludeCharacters" => @exclude_characters,
    "masterSecret" => @master_secret,
    "replaceOnPasswordCriteriaChanges" => @replace_on_password_criteria_changes,
    "replicaRegions" => @replica_regions,
    "secretName" => @secret_name,
  })
  result.compact
end