random.RandomUuid
Explore with Pulumi AI
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azurerm from "@pulumi/azurerm";
import * as random from "@pulumi/random";
// The following example shows how to generate a unique name for an Azure Resource Group.
const test = new random.RandomUuid("test", {});
const testResourceGroup = new azurerm.index.ResourceGroup("test", {
name: `${test.result}-rg`,
location: "Central US",
});
import pulumi
import pulumi_azurerm as azurerm
import pulumi_random as random
# The following example shows how to generate a unique name for an Azure Resource Group.
test = random.RandomUuid("test")
test_resource_group = azurerm.index.ResourceGroup("test",
name=f{test.result}-rg,
location=Central US)
package main
import (
"fmt"
"github.com/pulumi/pulumi-azurerm/sdk/v1/go/azurerm"
"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 {
// The following example shows how to generate a unique name for an Azure Resource Group.
test, err := random.NewRandomUuid(ctx, "test", nil)
if err != nil {
return err
}
_, err = index.NewResourceGroup(ctx, "test", &index.ResourceGroupArgs{
Name: pulumi.String(fmt.Sprintf("%v-rg", test.Result)),
Location: "Central US",
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azurerm = Pulumi.Azurerm;
using Random = Pulumi.Random;
return await Deployment.RunAsync(() =>
{
// The following example shows how to generate a unique name for an Azure Resource Group.
var test = new Random.RandomUuid("test");
var testResourceGroup = new Azurerm.Index.ResourceGroup("test", new()
{
Name = $"{test.Result}-rg",
Location = "Central US",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.random.RandomUuid;
import com.pulumi.azurerm.resourceGroup;
import com.pulumi.azurerm.ResourceGroupArgs;
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) {
// The following example shows how to generate a unique name for an Azure Resource Group.
var test = new RandomUuid("test");
var testResourceGroup = new ResourceGroup("testResourceGroup", ResourceGroupArgs.builder()
.name(String.format("%s-rg", test.result()))
.location("Central US")
.build());
}
}
resources:
# The following example shows how to generate a unique name for an Azure Resource Group.
test:
type: random:RandomUuid
testResourceGroup:
type: azurerm:resourceGroup
name: test
properties:
name: ${test.result}-rg
location: Central US
Create RandomUuid Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new RandomUuid(name: string, args?: RandomUuidArgs, opts?: CustomResourceOptions);
@overload
def RandomUuid(resource_name: str,
args: Optional[RandomUuidArgs] = None,
opts: Optional[ResourceOptions] = None)
@overload
def RandomUuid(resource_name: str,
opts: Optional[ResourceOptions] = None,
keepers: Optional[Mapping[str, str]] = None)
func NewRandomUuid(ctx *Context, name string, args *RandomUuidArgs, opts ...ResourceOption) (*RandomUuid, error)
public RandomUuid(string name, RandomUuidArgs? args = null, CustomResourceOptions? opts = null)
public RandomUuid(String name, RandomUuidArgs args)
public RandomUuid(String name, RandomUuidArgs args, CustomResourceOptions options)
type: random:RandomUuid
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 RandomUuidArgs
- 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 RandomUuidArgs
- 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 RandomUuidArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args RandomUuidArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args RandomUuidArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var randomUuidResource = new Random.RandomUuid("randomUuidResource", new()
{
Keepers =
{
{ "string", "string" },
},
});
example, err := random.NewRandomUuid(ctx, "randomUuidResource", &random.RandomUuidArgs{
Keepers: pulumi.StringMap{
"string": pulumi.String("string"),
},
})
var randomUuidResource = new RandomUuid("randomUuidResource", RandomUuidArgs.builder()
.keepers(Map.of("string", "string"))
.build());
random_uuid_resource = random.RandomUuid("randomUuidResource", keepers={
"string": "string",
})
const randomUuidResource = new random.RandomUuid("randomUuidResource", {keepers: {
string: "string",
}});
type: random:RandomUuid
properties:
keepers:
string: string
RandomUuid 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 RandomUuid resource accepts the following input properties:
- Keepers Dictionary<string, string>
- Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- Keepers map[string]string
- Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- keepers Map<String,String>
- Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- keepers {[key: string]: string}
- Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- keepers Mapping[str, str]
- Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
- keepers Map<String>
- Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
Outputs
All input properties are implicitly available as output properties. Additionally, the RandomUuid resource produces the following output properties:
Look up Existing RandomUuid Resource
Get an existing RandomUuid 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?: RandomUuidState, opts?: CustomResourceOptions): RandomUuid
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
keepers: Optional[Mapping[str, str]] = None,
result: Optional[str] = None) -> RandomUuid
func GetRandomUuid(ctx *Context, name string, id IDInput, state *RandomUuidState, opts ...ResourceOption) (*RandomUuid, error)
public static RandomUuid Get(string name, Input<string> id, RandomUuidState? state, CustomResourceOptions? opts = null)
public static RandomUuid get(String name, Output<String> id, RandomUuidState 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.
Import
Random UUID’s can be imported. This can be used to replace a config
value with a value interpolated from the random provider without
experiencing diffs.
$ pulumi import random:index/randomUuid:RandomUuid main aabbccdd-eeff-0011-2233-445566778899
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- random pulumi/pulumi-random
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
random
Terraform Provider.