Identical to random_string with the exception that the result is treated as sensitive and, thus, not displayed in console output. Read more about sensitive data handling in the Terraform documentation.
This resource does use a cryptographic random number generator.
# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug from constructs import Construct from cdktf import TerraformStack # # Provider bindings are generated by running `cdktf get`. # See https://cdk.tf/provider-generation for more details. # from imports.aws.db_instance import DbInstance from imports.random.password import Password class MyConvertedCode(TerraformStack): def __init__(self, scope, name): super().__init__(scope, name) password = Password(self, "password", length=16, override_special="!#$%&*()-_=+[]{}<>:?", special=True ) DbInstance(self, "example", allocated_storage=64, engine="mysql", instance_class="db.t3.micro", password=password.result, username="someone" )
length (Number) The length of the string desired. The minimum value for length is 1 and, length must also be >= (min_upper + min_lower + min_numeric + min_special).keepers (Map of String) Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.lower (Boolean) Include lowercase alphabet characters in the result. Default value is true.min_lower (Number) Minimum number of lowercase alphabet characters in the result. Default value is 0.min_numeric (Number) Minimum number of numeric characters in the result. Default value is 0.min_special (Number) Minimum number of special characters in the result. Default value is 0.min_upper (Number) Minimum number of uppercase alphabet characters in the result. Default value is 0.number (Boolean, Deprecated) Include numeric characters in the result. Default value is true. NOTE: This is deprecated, use numeric instead.numeric (Boolean) Include numeric characters in the result. Default value is true.override_special (String) Supply your own list of special characters to use for string generation. This overrides the default character list in the special argument. The special argument must still be set to true for any overwritten characters to be used in generation.special (Boolean) Include special characters in the result. These are !@#$%&*()-_=+[]{}<>:?. Default value is true.upper (Boolean) Include uppercase alphabet characters in the result. Default value is true.bcrypt_hash (String, Sensitive) A bcrypt hash of the generated random string. NOTE: If the generated random string is greater than 72 bytes in length, bcrypt_hash will contain a hash of the first 72 bytes.id (String) A static value used internally by Terraform, this should not be referenced in configurations.result (String, Sensitive) The generated random string.Import is supported using the following syntax:
terraform import random_password.password securepassword
Any attribute values that are specified within Terraform config will be ignored during import and all attributes that have defaults defined within the schema will have the default assigned.
For instance, using the following config during import:
# DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug from constructs import Construct from cdktf import TerraformStack # # Provider bindings are generated by running `cdktf get`. # See https://cdk.tf/provider-generation for more details. # from imports.random.password import Password class MyConvertedCode(TerraformStack): def __init__(self, scope, name): super().__init__(scope, name) Password(self, "password", length=16, lower=False )
Then importing the resource using terraform import random_password.password securepassword, would result in the triggering of a replacement (i.e., destroy-create) during the next terraform apply.
If the resource were imported using terraform import random_password.password securepassword, replacement could be avoided by using:
Attribute values that match the imported ID and defaults:
from constructs import Construct from cdktf import TerraformStack
cdktf get.from imports.random.password import Password class MyConvertedCode(TerraformStack): def init(self, scope, name): super().init(scope, name) Password(self, “password”, length=14, lower=True )
2. Attribute values that match the imported ID and omit the attributes with defaults: ```python # DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug from constructs import Construct from cdktf import TerraformStack # # Provider bindings are generated by running `cdktf get`. # See https://cdk.tf/provider-generation for more details. # from imports.random.password import Password class MyConvertedCode(TerraformStack): def __init__(self, scope, name): super().__init__(scope, name) Password(self, "password", length=14 )
ignore_changes specifying the attributes to ignore:
from cdktf import TerraformResourceLifecycle from constructs import Construct from cdktf import TerraformStack
cdktf get.from imports.random.password import Password class MyConvertedCode(TerraformStack): def init(self, scope, name): super().init(scope, name) Password(self, “password”, length=16, lifecycle=TerraformResourceLifecycle( ignore_changes=[length, lower] ), lower=False )
**NOTE** `ignore_changes` is only required until the resource is recreated after import, after which it will use the configuration values specified. <!-- cache-key: cdktf-0.19.0 input-679f2842bdae2deada09d08030e614f09c42f4d6c2a4a7861ed1b7a84f1ceeea 556251879b8ed0dc4c87a76b568667e0ab5e2c46efdd14a05c556daf05678783-->