1. Packages
  2. Random
  3. API Docs
  4. RandomShuffle
random v4.16.1 published on Wednesday, Apr 17, 2024 by Pulumi

random.RandomShuffle

Explore with Pulumi AI

random logo
random v4.16.1 published on Wednesday, Apr 17, 2024 by Pulumi

    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});
    // ... and other aws_elb arguments ...
    
    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)
    # ... and other aws_elb arguments ...
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v5/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
    	})
    }
    
    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,
        });
    
        // ... and other aws_elb arguments ...
    });
    
    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());
    
            // ... and other aws_elb arguments ...
        }
    }
    
    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:
          # Place the ELB in any two of the given availability zones, selected
          #   # at random.
          availabilityZones: ${az.results}
    

    Create RandomShuffle Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new RandomShuffle(name: string, args: RandomShuffleArgs, opts?: CustomResourceOptions);
    @overload
    def RandomShuffle(resource_name: str,
                      args: RandomShuffleArgs,
                      opts: Optional[ResourceOptions] = None)
    
    @overload
    def RandomShuffle(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      inputs: Optional[Sequence[str]] = None,
                      keepers: Optional[Mapping[str, str]] = None,
                      result_count: Optional[int] = None,
                      seed: Optional[str] = None)
    func NewRandomShuffle(ctx *Context, name string, args RandomShuffleArgs, opts ...ResourceOption) (*RandomShuffle, error)
    public RandomShuffle(string name, RandomShuffleArgs args, CustomResourceOptions? opts = null)
    public RandomShuffle(String name, RandomShuffleArgs args)
    public RandomShuffle(String name, RandomShuffleArgs args, CustomResourceOptions options)
    
    type: random:RandomShuffle
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args RandomShuffleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args RandomShuffleArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args RandomShuffleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RandomShuffleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RandomShuffleArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var randomShuffleResource = new Random.RandomShuffle("randomShuffleResource", new()
    {
        Inputs = new[]
        {
            "string",
        },
        Keepers = 
        {
            { "string", "string" },
        },
        ResultCount = 0,
        Seed = "string",
    });
    
    example, err := random.NewRandomShuffle(ctx, "randomShuffleResource", &random.RandomShuffleArgs{
    	Inputs: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	Keepers: pulumi.StringMap{
    		"string": pulumi.String("string"),
    	},
    	ResultCount: pulumi.Int(0),
    	Seed:        pulumi.String("string"),
    })
    
    var randomShuffleResource = new RandomShuffle("randomShuffleResource", RandomShuffleArgs.builder()        
        .inputs("string")
        .keepers(Map.of("string", "string"))
        .resultCount(0)
        .seed("string")
        .build());
    
    random_shuffle_resource = random.RandomShuffle("randomShuffleResource",
        inputs=["string"],
        keepers={
            "string": "string",
        },
        result_count=0,
        seed="string")
    
    const randomShuffleResource = new random.RandomShuffle("randomShuffleResource", {
        inputs: ["string"],
        keepers: {
            string: "string",
        },
        resultCount: 0,
        seed: "string",
    });
    
    type: random:RandomShuffle
    properties:
        inputs:
            - string
        keepers:
            string: string
        resultCount: 0
        seed: string
    

    RandomShuffle Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The RandomShuffle resource accepts the following input properties:

    Inputs List<string>
    The list of strings to shuffle.
    Keepers Dictionary<string, string>
    Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
    ResultCount 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.
    Seed string
    Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.
    Inputs []string
    The list of strings to shuffle.
    Keepers map[string]string
    Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
    ResultCount 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.
    Seed string
    Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.
    inputs List<String>
    The list of strings to shuffle.
    keepers Map<String,String>
    Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
    resultCount Integer
    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.
    seed String
    Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.
    inputs string[]
    The list of strings to shuffle.
    keepers {[key: string]: string}
    Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
    resultCount number
    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.
    seed string
    Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.
    inputs Sequence[str]
    The list of strings to shuffle.
    keepers Mapping[str, str]
    Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
    result_count 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.
    seed str
    Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.
    inputs List<String>
    The list of strings to shuffle.
    keepers Map<String>
    Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
    resultCount Number
    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.
    seed String
    Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the RandomShuffle resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Results 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.
    Id string
    The provider-assigned unique ID for this managed resource.
    Results []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.
    id String
    The provider-assigned unique ID for this managed resource.
    results 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.
    id string
    The provider-assigned unique ID for this managed resource.
    results 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.
    id str
    The provider-assigned unique ID for this managed resource.
    results Sequence[str]
    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.
    id String
    The provider-assigned unique ID for this managed resource.
    results 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.

    Look up Existing RandomShuffle Resource

    Get an existing RandomShuffle resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: RandomShuffleState, opts?: CustomResourceOptions): RandomShuffle
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            inputs: Optional[Sequence[str]] = None,
            keepers: Optional[Mapping[str, str]] = None,
            result_count: Optional[int] = None,
            results: Optional[Sequence[str]] = None,
            seed: Optional[str] = None) -> RandomShuffle
    func GetRandomShuffle(ctx *Context, name string, id IDInput, state *RandomShuffleState, opts ...ResourceOption) (*RandomShuffle, error)
    public static RandomShuffle Get(string name, Input<string> id, RandomShuffleState? state, CustomResourceOptions? opts = null)
    public static RandomShuffle get(String name, Output<String> id, RandomShuffleState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Inputs List<string>
    The list of strings to shuffle.
    Keepers Dictionary<string, string>
    Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
    ResultCount 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.
    Results 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.
    Seed string
    Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.
    Inputs []string
    The list of strings to shuffle.
    Keepers map[string]string
    Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
    ResultCount 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.
    Results []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.
    Seed string
    Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.
    inputs List<String>
    The list of strings to shuffle.
    keepers Map<String,String>
    Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
    resultCount Integer
    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.
    results 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.
    seed String
    Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.
    inputs string[]
    The list of strings to shuffle.
    keepers {[key: string]: string}
    Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
    resultCount number
    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.
    results 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.
    seed string
    Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.
    inputs Sequence[str]
    The list of strings to shuffle.
    keepers Mapping[str, str]
    Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
    result_count 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.
    results Sequence[str]
    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.
    seed str
    Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.
    inputs List<String>
    The list of strings to shuffle.
    keepers Map<String>
    Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
    resultCount Number
    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.
    results 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.
    seed String
    Arbitrary string with which to seed the random number generator, in order to produce less-volatile permutations of the list.

    Package Details

    Repository
    random pulumi/pulumi-random
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the random Terraform Provider.
    random logo
    random v4.16.1 published on Wednesday, Apr 17, 2024 by Pulumi