com.pulumi.random.kotlin.RandomPet.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-random-kotlin Show documentation
Show all versions of pulumi-random-kotlin Show documentation
Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.random.kotlin
import com.pulumi.core.Output
import com.pulumi.kotlin.KotlinCustomResource
import com.pulumi.kotlin.PulumiTagMarker
import com.pulumi.kotlin.ResourceMapper
import com.pulumi.kotlin.options.CustomResourceOptions
import com.pulumi.kotlin.options.CustomResourceOptionsBuilder
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.Map
/**
* Builder for [RandomPet].
*/
@PulumiTagMarker
public class RandomPetResourceBuilder internal constructor() {
public var name: String? = null
public var args: RandomPetArgs = RandomPetArgs()
public var opts: CustomResourceOptions = CustomResourceOptions()
/**
* @param name The _unique_ name of the resulting resource.
*/
public fun name(`value`: String) {
this.name = value
}
/**
* @param block The arguments to use to populate this resource's properties.
*/
public suspend fun args(block: suspend RandomPetArgsBuilder.() -> Unit) {
val builder = RandomPetArgsBuilder()
block(builder)
this.args = builder.build()
}
/**
* @param block A bag of options that control this resource's behavior.
*/
public suspend fun opts(block: suspend CustomResourceOptionsBuilder.() -> Unit) {
this.opts = com.pulumi.kotlin.options.opts(block)
}
internal fun build(): RandomPet {
val builtJavaResource = com.pulumi.random.RandomPet(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return RandomPet(builtJavaResource)
}
}
/**
* The resource `random.RandomPet` generates random pet names that are intended to be used as unique identifiers for other resources.
* 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.RandomPet;
* import com.pulumi.random.RandomPetArgs;
* 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 serverRandomPet = new RandomPet("serverRandomPet", RandomPetArgs.builder()
* .keepers(Map.of("ami_id", var_.ami_id()))
* .build());
* var serverInstance = new Instance("serverInstance", InstanceArgs.builder()
* .tags(Map.of("Name", serverRandomPet.id().applyValue(id -> String.format("web-server-%s", id))))
* .ami(serverRandomPet.keepers().applyValue(keepers -> keepers.amiId()))
* .build());
* }
* }
* ```
*/
public class RandomPet internal constructor(
override val javaResource: com.pulumi.random.RandomPet,
) : KotlinCustomResource(javaResource, RandomPetMapper) {
/**
* Arbitrary map of values that, when changed, will trigger recreation of resource. See the main provider documentation for more information.
*/
public val keepers: Output