Package com.pulumi.random
Class RandomInteger
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.random.RandomInteger
-
public class RandomInteger extends com.pulumi.resources.CustomResourceThe resource `random.RandomInteger` generates random values from a given range, described by the `min` and `max` attributes of a given resource. This resource can be used in conjunction with resources that have the `create_before_destroy` lifecycle flag set, to avoid conflicts with unique names during the brief period where both the old and new resources exist concurrently. ## Example Usage ```java package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.random.RandomInteger; import com.pulumi.random.RandomIntegerArgs; import com.pulumi.aws.alb.ListenerRule; import com.pulumi.aws.alb.ListenerRuleArgs; import com.pulumi.aws.alb.inputs.ListenerRuleActionArgs; 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 priority = new RandomInteger("priority", RandomIntegerArgs.builder() .min(1) .max(50000) .keepers(Map.of("listener_arn", var_.listener_arn())) .build()); var main = new ListenerRule("main", ListenerRuleArgs.builder() .listenerArn(priority.keepers().applyValue(keepers -> keepers.listenerArn())) .priority(priority.result()) .actions(ListenerRuleActionArgs.builder() .type("forward") .targetGroupArn(var_.target_group_arn()) .build()) .build()); } } ``` ## Import Random integers can be imported using the result, min, and max, with an optional seed. This can be used to replace a config value with a value interpolated from the random provider without experiencing diffs. Example (values are separated by a ,) ```sh $ pulumi import random:index/randomInteger:RandomInteger priority 15390,1,50000 ```
-
-
Constructor Summary
Constructors Constructor Description RandomInteger(java.lang.String name)RandomInteger(java.lang.String name, RandomIntegerArgs args)RandomInteger(java.lang.String name, RandomIntegerArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RandomIntegerget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, RandomIntegerState 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>max()com.pulumi.core.Output<java.lang.Integer>min()com.pulumi.core.Output<java.lang.Integer>result()com.pulumi.core.Output<java.util.Optional<java.lang.String>>seed()
-
-
-
Constructor Detail
-
RandomInteger
public RandomInteger(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
RandomInteger
public RandomInteger(java.lang.String name, RandomIntegerArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
RandomInteger
public RandomInteger(java.lang.String name, RandomIntegerArgs 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.
-
max
public com.pulumi.core.Output<java.lang.Integer> max()
- Returns:
- The maximum inclusive value of the range.
-
min
public com.pulumi.core.Output<java.lang.Integer> min()
- Returns:
- The minimum inclusive value of the range.
-
result
public com.pulumi.core.Output<java.lang.Integer> result()
- Returns:
- The random integer result.
-
seed
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> seed()
- Returns:
- A custom seed to always produce the same value.
-
get
public static RandomInteger get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable RandomIntegerState 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.
-
-