RandomShuffle

class RandomShuffle : KotlinCustomResource

The resource random.RandomShuffle generates a random permutation of a list of strings given as an argument.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as random from "@pulumi/random";
const az = new random.RandomShuffle("az", {
inputs: [
"us-west-1a",
"us-west-1c",
"us-west-1d",
"us-west-1e",
],
resultCount: 2,
});
const example = new aws.elb.LoadBalancer("example", {availabilityZones: az.results});
import pulumi
import pulumi_aws as aws
import pulumi_random as random
az = random.RandomShuffle("az",
inputs=[
"us-west-1a",
"us-west-1c",
"us-west-1d",
"us-west-1e",
],
result_count=2)
example = aws.elb.LoadBalancer("example", availability_zones=az.results)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
using Random = Pulumi.Random;
return await Deployment.RunAsync(() =>
{
var az = new Random.RandomShuffle("az", new()
{
Inputs = new[]
{
"us-west-1a",
"us-west-1c",
"us-west-1d",
"us-west-1e",
},
ResultCount = 2,
});
var example = new Aws.Elb.LoadBalancer("example", new()
{
AvailabilityZones = az.Results,
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/elb"
"github.com/pulumi/pulumi-random/sdk/v4/go/random"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
az, err := random.NewRandomShuffle(ctx, "az", &random.RandomShuffleArgs{
Inputs: pulumi.StringArray{
pulumi.String("us-west-1a"),
pulumi.String("us-west-1c"),
pulumi.String("us-west-1d"),
pulumi.String("us-west-1e"),
},
ResultCount: pulumi.Int(2),
})
if err != nil {
return err
}
_, err = elb.NewLoadBalancer(ctx, "example", &elb.LoadBalancerArgs{
AvailabilityZones: az.Results,
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.random.RandomShuffle;
import com.pulumi.random.RandomShuffleArgs;
import com.pulumi.aws.elb.LoadBalancer;
import com.pulumi.aws.elb.LoadBalancerArgs;
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 az = new RandomShuffle("az", RandomShuffleArgs.builder()
.inputs(
"us-west-1a",
"us-west-1c",
"us-west-1d",
"us-west-1e")
.resultCount(2)
.build());
var example = new LoadBalancer("example", LoadBalancerArgs.builder()
.availabilityZones(az.results())
.build());
}
}
resources:
az:
type: random:RandomShuffle
properties:
inputs:
- us-west-1a
- us-west-1c
- us-west-1d
- us-west-1e
resultCount: 2
example:
type: aws:elb:LoadBalancer
properties:
availabilityZones: ${az.results}

Properties

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val inputs: Output<List<String>>

The list of strings to shuffle.

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 pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val resultCount: Output<Int>?

The number of results to return. Defaults to the number of items in the input list. If fewer items are requested, some elements will be excluded from the result. If more items are requested, items will be repeated in the result but not more frequently than the number of items in the input list.

Link copied to clipboard
val results: Output<List<String>>

Random permutation of the list of strings given in input. The number of elements is determined by result_count if set, or the number of elements in input.

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

Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.

Link copied to clipboard
val urn: Output<String>