RandomInteger

class RandomInteger : KotlinCustomResource

The 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

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 ,)

$ pulumi import random:index/randomInteger:RandomInteger priority 15390,1,50000

Properties

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val keepers: Output<Map<String, String>>?

Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.

Link copied to clipboard
val max: Output<Int>

The maximum inclusive value of the range.

Link copied to clipboard
val min: Output<Int>

The minimum inclusive value of the range.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val result: Output<Int>

The random integer result.

Link copied to clipboard
val seed: Output<String>?

A custom seed to always produce the same value.

Link copied to clipboard
val urn: Output<String>