All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.random.kotlin.RandomIdArgs.kt Maven / Gradle / Ivy

@file:Suppress("NAME_SHADOWING", "DEPRECATION")

package com.pulumi.random.kotlin

import com.pulumi.core.Output
import com.pulumi.core.Output.of
import com.pulumi.kotlin.ConvertibleToJava
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.random.RandomIdArgs.builder
import kotlin.Int
import kotlin.Pair
import kotlin.String
import kotlin.Suppress
import kotlin.collections.Map
import kotlin.jvm.JvmName

/**
 * The resource `random.RandomId` generates random numbers that are intended to be
 * used as unique identifiers for other resources. If the output is considered
 * sensitive, and should not be displayed in the CLI, use `random.RandomBytes`
 * instead.
 * This resource *does* use a cryptographic random number generator in order
 * to minimize the chance of collisions, making the results of this resource
 * when a 16-byte identifier is requested of equivalent uniqueness to a
 * type-4 UUID.
 * 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.RandomId;
 * import com.pulumi.random.RandomIdArgs;
 * import com.pulumi.aws.ec2.Instance;
 * import com.pulumi.aws.ec2.InstanceArgs;
 * 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 serverRandomId = new RandomId("serverRandomId", RandomIdArgs.builder()
 *             .keepers(Map.of("ami_id", var_.ami_id()))
 *             .byteLength(8)
 *             .build());
 *         var serverInstance = new Instance("serverInstance", InstanceArgs.builder()
 *             .tags(Map.of("Name", serverRandomId.hex().applyValue(hex -> String.format("web-server %s", hex))))
 *             .ami(serverRandomId.keepers().applyValue(keepers -> keepers.amiId()))
 *             .build());
 *     }
 * }
 * ```
 * ## Import
 * Random IDs can be imported using the b64_url with an optional prefix. This can be used to replace a config value with a value interpolated from the random provider without experiencing diffs. Example with no prefix
 * ```sh
 *  $ pulumi import random:index/randomId:RandomId server p-9hUg
 * ```
 *  Example with prefix (prefix is separated by a ,)
 * ```sh
 *  $ pulumi import random:index/randomId:RandomId server my-prefix-,p-9hUg
 * ```
 * @property byteLength The number of random bytes to produce. The minimum value is 1, which produces eight bits of randomness.
 * @property keepers Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
 * @property prefix Arbitrary string to prefix the output value with. This string is supplied as-is, meaning it is not guaranteed to be URL-safe or base64 encoded.
 */
public data class RandomIdArgs(
    public val byteLength: Output? = null,
    public val keepers: Output>? = null,
    public val prefix: Output? = null,
) : ConvertibleToJava {
    override fun toJava(): com.pulumi.random.RandomIdArgs = com.pulumi.random.RandomIdArgs.builder()
        .byteLength(byteLength?.applyValue({ args0 -> args0 }))
        .keepers(keepers?.applyValue({ args0 -> args0.map({ args0 -> args0.key.to(args0.value) }).toMap() }))
        .prefix(prefix?.applyValue({ args0 -> args0 })).build()
}

/**
 * Builder for [RandomIdArgs].
 */
@PulumiTagMarker
public class RandomIdArgsBuilder internal constructor() {
    private var byteLength: Output? = null

    private var keepers: Output>? = null

    private var prefix: Output? = null

    /**
     * @param value The number of random bytes to produce. The minimum value is 1, which produces eight bits of randomness.
     */
    @JvmName("iftufcenrjcekvem")
    public suspend fun byteLength(`value`: Output) {
        this.byteLength = value
    }

    /**
     * @param value Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
     */
    @JvmName("ahtvvmradhdpmhjy")
    public suspend fun keepers(`value`: Output>) {
        this.keepers = value
    }

    /**
     * @param value Arbitrary string to prefix the output value with. This string is supplied as-is, meaning it is not guaranteed to be URL-safe or base64 encoded.
     */
    @JvmName("fusggpyevxweaylh")
    public suspend fun prefix(`value`: Output) {
        this.prefix = value
    }

    /**
     * @param value The number of random bytes to produce. The minimum value is 1, which produces eight bits of randomness.
     */
    @JvmName("gyfnbekseatgnuuy")
    public suspend fun byteLength(`value`: Int?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.byteLength = mapped
    }

    /**
     * @param value Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
     */
    @JvmName("ouyohvycribyxgkj")
    public suspend fun keepers(`value`: Map?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.keepers = mapped
    }

    /**
     * @param values Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
     */
    @JvmName("xmvfyiououlwwwlb")
    public fun keepers(vararg values: Pair) {
        val toBeMapped = values.toMap()
        val mapped = toBeMapped.let({ args0 -> of(args0) })
        this.keepers = mapped
    }

    /**
     * @param value Arbitrary string to prefix the output value with. This string is supplied as-is, meaning it is not guaranteed to be URL-safe or base64 encoded.
     */
    @JvmName("fjsfpixvdcxcijnn")
    public suspend fun prefix(`value`: String?) {
        val toBeMapped = value
        val mapped = toBeMapped?.let({ args0 -> of(args0) })
        this.prefix = mapped
    }

    internal fun build(): RandomIdArgs = RandomIdArgs(
        byteLength = byteLength,
        keepers = keepers,
        prefix = prefix,
    )
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy