Class: AWSCDK::SecretsManager::SecretStringGenerator

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
secrets_manager/secret_string_generator.rb

Overview

Configuration to generate secrets such as passwords automatically.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exclude_characters: nil, exclude_lowercase: nil, exclude_numbers: nil, exclude_punctuation: nil, exclude_uppercase: nil, generate_string_key: nil, include_space: nil, password_length: nil, require_each_included_type: nil, secret_string_template: nil) ⇒ SecretStringGenerator

Returns a new instance of SecretStringGenerator.

Parameters:

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

    A string that includes characters that shouldn't be included in the generated password.

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

    Specifies that the generated password shouldn't include lowercase letters.

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

    Specifies that the generated password shouldn't include digits.

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

    Specifies that the generated password shouldn't include punctuation characters.

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

    Specifies that the generated password shouldn't include uppercase letters.

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

    The JSON key name that's used to add the generated password to the JSON structure specified by the secretStringTemplate parameter.

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

    Specifies that the generated password can include the space character.

  • password_length (Numeric, nil) (defaults to: nil)

    The desired length of the generated password.

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

    Specifies whether the generated password must include at least one of every allowed character type.

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

    A properly structured JSON string that the generated password can be added to.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'secrets_manager/secret_string_generator.rb', line 17

def initialize(exclude_characters: nil, exclude_lowercase: nil, exclude_numbers: nil, exclude_punctuation: nil, exclude_uppercase: nil, generate_string_key: nil, include_space: nil, password_length: nil, require_each_included_type: nil, secret_string_template: nil)
  @exclude_characters = exclude_characters
  Jsii::Type.check_type(@exclude_characters, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "excludeCharacters") unless @exclude_characters.nil?
  @exclude_lowercase = exclude_lowercase
  Jsii::Type.check_type(@exclude_lowercase, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "excludeLowercase") unless @exclude_lowercase.nil?
  @exclude_numbers = exclude_numbers
  Jsii::Type.check_type(@exclude_numbers, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "excludeNumbers") unless @exclude_numbers.nil?
  @exclude_punctuation = exclude_punctuation
  Jsii::Type.check_type(@exclude_punctuation, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "excludePunctuation") unless @exclude_punctuation.nil?
  @exclude_uppercase = exclude_uppercase
  Jsii::Type.check_type(@exclude_uppercase, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "excludeUppercase") unless @exclude_uppercase.nil?
  @generate_string_key = generate_string_key
  Jsii::Type.check_type(@generate_string_key, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "generateStringKey") unless @generate_string_key.nil?
  @include_space = include_space
  Jsii::Type.check_type(@include_space, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "includeSpace") unless @include_space.nil?
  @password_length = password_length
  Jsii::Type.check_type(@password_length, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "passwordLength") unless @password_length.nil?
  @require_each_included_type = require_each_included_type
  Jsii::Type.check_type(@require_each_included_type, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "requireEachIncludedType") unless @require_each_included_type.nil?
  @secret_string_template = secret_string_template
  Jsii::Type.check_type(@secret_string_template, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "secretStringTemplate") unless @secret_string_template.nil?
end

Instance Attribute Details

#exclude_charactersString? (readonly)

Note:

Default: no exclusions

A string that includes characters that shouldn't be included in the generated password.

The string can be a minimum of 0 and a maximum of 4096 characters long.

Returns:

  • (String, nil)


47
48
49
# File 'secrets_manager/secret_string_generator.rb', line 47

def exclude_characters
  @exclude_characters
end

#exclude_lowercaseBoolean? (readonly)

Note:

Default: false

Specifies that the generated password shouldn't include lowercase letters.

Returns:

  • (Boolean, nil)


52
53
54
# File 'secrets_manager/secret_string_generator.rb', line 52

def exclude_lowercase
  @exclude_lowercase
end

#exclude_numbersBoolean? (readonly)

Note:

Default: false

Specifies that the generated password shouldn't include digits.

Returns:

  • (Boolean, nil)


57
58
59
# File 'secrets_manager/secret_string_generator.rb', line 57

def exclude_numbers
  @exclude_numbers
end

#exclude_punctuationBoolean? (readonly)

Note:

Default: false

Specifies that the generated password shouldn't include punctuation characters.

Returns:

  • (Boolean, nil)


62
63
64
# File 'secrets_manager/secret_string_generator.rb', line 62

def exclude_punctuation
  @exclude_punctuation
end

#exclude_uppercaseBoolean? (readonly)

Note:

Default: false

Specifies that the generated password shouldn't include uppercase letters.

Returns:

  • (Boolean, nil)


67
68
69
# File 'secrets_manager/secret_string_generator.rb', line 67

def exclude_uppercase
  @exclude_uppercase
end

#generate_string_keyString? (readonly)

The JSON key name that's used to add the generated password to the JSON structure specified by the secretStringTemplate parameter.

If you specify generate_string_key then secret_string_template must be also be specified.

Returns:

  • (String, nil)


74
75
76
# File 'secrets_manager/secret_string_generator.rb', line 74

def generate_string_key
  @generate_string_key
end

#include_spaceBoolean? (readonly)

Note:

Default: false

Specifies that the generated password can include the space character.

Returns:

  • (Boolean, nil)


79
80
81
# File 'secrets_manager/secret_string_generator.rb', line 79

def include_space
  @include_space
end

#password_lengthNumeric? (readonly)

Note:

Default: 32

The desired length of the generated password.

Returns:

  • (Numeric, nil)


84
85
86
# File 'secrets_manager/secret_string_generator.rb', line 84

def password_length
  @password_length
end

#require_each_included_typeBoolean? (readonly)

Note:

Default: true

Specifies whether the generated password must include at least one of every allowed character type.

Returns:

  • (Boolean, nil)


89
90
91
# File 'secrets_manager/secret_string_generator.rb', line 89

def require_each_included_type
  @require_each_included_type
end

#secret_string_templateString? (readonly)

A properly structured JSON string that the generated password can be added to.

The generate_string_key is combined with the generated random string and inserted into the JSON structure that's specified by this parameter. The merged JSON string is returned as the completed SecretString of the secret. If you specify secret_string_template then generate_string_key must be also be specified.

Returns:

  • (String, nil)


98
99
100
# File 'secrets_manager/secret_string_generator.rb', line 98

def secret_string_template
  @secret_string_template
end

Class Method Details

.jsii_propertiesObject



100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'secrets_manager/secret_string_generator.rb', line 100

def self.jsii_properties
  {
    :exclude_characters => "excludeCharacters",
    :exclude_lowercase => "excludeLowercase",
    :exclude_numbers => "excludeNumbers",
    :exclude_punctuation => "excludePunctuation",
    :exclude_uppercase => "excludeUppercase",
    :generate_string_key => "generateStringKey",
    :include_space => "includeSpace",
    :password_length => "passwordLength",
    :require_each_included_type => "requireEachIncludedType",
    :secret_string_template => "secretStringTemplate",
  }
end

Instance Method Details

#to_jsiiObject



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'secrets_manager/secret_string_generator.rb', line 115

def to_jsii
  result = {}
  result.merge!({
    "excludeCharacters" => @exclude_characters,
    "excludeLowercase" => @exclude_lowercase,
    "excludeNumbers" => @exclude_numbers,
    "excludePunctuation" => @exclude_punctuation,
    "excludeUppercase" => @exclude_uppercase,
    "generateStringKey" => @generate_string_key,
    "includeSpace" => @include_space,
    "passwordLength" => @password_length,
    "requireEachIncludedType" => @require_each_included_type,
    "secretStringTemplate" => @secret_string_template,
  })
  result.compact
end