The resource random_string
generates a random permutation of alphanumeric characters and optionally special characters.
This resource does use a cryptographic random number generator.
Historically this resource's intended usage has been ambiguous as the original example used it in a password. For backwards compatibility it will continue to exist. For unique ids please use random_id, for sensitive random values please use random_password.
// DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
import { Construct } from "constructs";
import { TerraformStack } from "cdktf";
/*
* Provider bindings are generated by running `cdktf get`.
* See https://cdk.tf/provider-generation for more details.
*/
import { StringResource } from "./.gen/providers/random/string-resource";
class MyConvertedCode extends TerraformStack {
constructor(scope: Construct, name: string) {
super(scope, name);
new StringResource(this, "random", {
length: 16,
overrideSpecial: "/@\xA3$",
special: true,
});
}
}
length
(Number) The length of the string desired. The minimum value for length is 1 and, length must also be >= (minUpper
+ minLower
+ minNumeric
+ minSpecial
).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
.minLower
(Number) Minimum number of lowercase alphabet characters in the result. Default value is 0
.minNumeric
(Number) Minimum number of numeric characters in the result. Default value is 0
.minSpecial
(Number) Minimum number of special characters in the result. Default value is 0
.minUpper
(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
.overrideSpecial
(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
.id
(String) The generated random string.result
(String) The generated random string.Import is supported using the following syntax:
terraform import random_string.test test
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
import { Construct } from "constructs";
import { TerraformStack } from "cdktf";
/*
* Provider bindings are generated by running `cdktf get`.
* See https://cdk.tf/provider-generation for more details.
*/
import { StringResource } from "./.gen/providers/random/string-resource";
class MyConvertedCode extends TerraformStack {
constructor(scope: Construct, name: string) {
super(scope, name);
new StringResource(this, "test", {
length: 16,
lower: false,
});
}
}
Then importing the resource using terraform import random_string.test test
,
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_string.test test
,
replacement can be avoided by using:
cdktf get
.
2. Attribute values that match the imported ID and omit the attributes with defaults:
```typescript
// DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
import { Construct } from "constructs";
import { TerraformStack } from "cdktf";
/*
* Provider bindings are generated by running `cdktf get`.
* See https://cdk.tf/provider-generation for more details.
*/
import { StringResource } from "./.gen/providers/random/string-resource";
class MyConvertedCode extends TerraformStack {
constructor(scope: Construct, name: string) {
super(scope, name);
new StringResource(this, "test", {
length: 4,
});
}
}
ignore_changes
specifying the attributes to ignore:
```typescript
// DO NOT EDIT. Code generated by 'cdktf convert' - Please report bugs at https://cdk.tf/bug
import { Construct } from "constructs";
import { TerraformStack } from "cdktf";
/*
cdktf get
.```
**NOTE** `ignore_changes` is only required until the resource is recreated after import,
after which it will use the configuration values specified.