Class RandomPassword


  • public class RandomPassword
    extends com.pulumi.resources.CustomResource
    Identical to random_string. This resource *does* use a cryptographic random number generator. ## Example Usage ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.random.RandomPassword; import com.pulumi.random.RandomPasswordArgs; import com.pulumi.aws.rds.Instance; import com.pulumi.aws.rds.InstanceArgs; 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 password = new RandomPassword("password", RandomPasswordArgs.builder() .length(16) .special(true) .overrideSpecial("!#$%&*()-_=+[]{}<>:?") .build()); var example = new Instance("example", InstanceArgs.builder() .instanceClass("db.t3.micro") .allocatedStorage(64) .engine("mysql") .username("someone") .password(password.result()) .build()); } } ``` ## Import You can import external passwords into your Pulumi programs as follows: ```sh $ import random:index/randomPassword:RandomPassword newPassword supersecret ``` This command will encode the `supersecret` token in Pulumi state and generate a code suggestion to include a new RandomPassword resource in your Pulumi program. Include the suggested code and do a `pulumi up`. Your secret password is now securely stored in Pulumi, and you can reference it in your Pulumi program as `newPassword.result`.
    • 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
      com.pulumi.core.Output<java.lang.String> bcryptHash()  
      static RandomPassword get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, RandomPasswordState 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

      • RandomPassword

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

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

        public RandomPassword​(java.lang.String name,
                              RandomPasswordArgs 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

      • bcryptHash

        public com.pulumi.core.Output<java.lang.String> bcryptHash()
        Returns:
        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.
      • 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 RandomPassword get​(java.lang.String name,
                                         com.pulumi.core.Output<java.lang.String> id,
                                         @Nullable
                                         RandomPasswordState 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.