Class RandomString


  • public class RandomString
    extends com.pulumi.resources.CustomResource
    The resource `random.RandomString` 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. ## Example Usage ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.random.RandomString; import com.pulumi.random.RandomStringArgs; import java.util.List; import java.util.ArrayList; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var random = new RandomString("random", RandomStringArgs.builder() .length(16) .overrideSpecial("/@£$") .special(true) .build()); } } ``` ## Import You can import external strings into your Pulumi programs as RandomString resources as follows: ```sh $ import random:index/randomString:RandomString newString myspecialdata ``` This command will encode the `myspecialdata` token in Pulumi state and generate a code suggestion to include a new RandomString resource in your Pulumi program. Include the suggested code and do a `pulumi up`. Your data is now stored in Pulumi, and you can reference it in your Pulumi program as `newString.result`. If the data needs to be stored securily as a secret, consider using the RandomPassword resource instead.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static RandomString get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, RandomStringState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> keepers()  
      com.pulumi.core.Output<java.lang.Integer> length()  
      com.pulumi.core.Output<java.lang.Boolean> lower()  
      com.pulumi.core.Output<java.lang.Integer> minLower()  
      com.pulumi.core.Output<java.lang.Integer> minNumeric()  
      com.pulumi.core.Output<java.lang.Integer> minSpecial()  
      com.pulumi.core.Output<java.lang.Integer> minUpper()  
      com.pulumi.core.Output<java.lang.Boolean> number()  
      com.pulumi.core.Output<java.lang.Boolean> numeric()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> overrideSpecial()  
      com.pulumi.core.Output<java.lang.String> result()  
      com.pulumi.core.Output<java.lang.Boolean> special()  
      com.pulumi.core.Output<java.lang.Boolean> upper()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RandomString

        public RandomString​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • RandomString

        public RandomString​(java.lang.String name,
                            RandomStringArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • RandomString

        public RandomString​(java.lang.String name,
                            RandomStringArgs args,
                            @Nullable
                            com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • keepers

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> keepers()
        Returns:
        Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
      • length

        public com.pulumi.core.Output<java.lang.Integer> length()
        Returns:
        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`).
      • lower

        public com.pulumi.core.Output<java.lang.Boolean> lower()
        Returns:
        Include lowercase alphabet characters in the result. Default value is `true`.
      • minLower

        public com.pulumi.core.Output<java.lang.Integer> minLower()
        Returns:
        Minimum number of lowercase alphabet characters in the result. Default value is `0`.
      • minNumeric

        public com.pulumi.core.Output<java.lang.Integer> minNumeric()
        Returns:
        Minimum number of numeric characters in the result. Default value is `0`.
      • minSpecial

        public com.pulumi.core.Output<java.lang.Integer> minSpecial()
        Returns:
        Minimum number of special characters in the result. Default value is `0`.
      • minUpper

        public com.pulumi.core.Output<java.lang.Integer> minUpper()
        Returns:
        Minimum number of uppercase alphabet characters in the result. Default value is `0`.
      • number

        public com.pulumi.core.Output<java.lang.Boolean> number()
        Returns:
        Include numeric characters in the result. Default value is `true`. **NOTE**: This is deprecated, use `numeric` instead.
      • numeric

        public com.pulumi.core.Output<java.lang.Boolean> numeric()
        Returns:
        Include numeric characters in the result. Default value is `true`.
      • overrideSpecial

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> overrideSpecial()
        Returns:
        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.
      • result

        public com.pulumi.core.Output<java.lang.String> result()
        Returns:
        The generated random string.
      • special

        public com.pulumi.core.Output<java.lang.Boolean> special()
        Returns:
        Include special characters in the result. These are `!@#$%&*()-_=+[]{}<>:?`. Default value is `true`.
      • upper

        public com.pulumi.core.Output<java.lang.Boolean> upper()
        Returns:
        Include uppercase alphabet characters in the result. Default value is `true`.
      • get

        public static RandomString get​(java.lang.String name,
                                       com.pulumi.core.Output<java.lang.String> id,
                                       @Nullable
                                       RandomStringState state,
                                       @Nullable
                                       com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.