com.pulumi.nomad.kotlin.Volume.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pulumi-nomad-kotlin Show documentation
Show all versions of pulumi-nomad-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.nomad.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.nomad.kotlin.outputs.VolumeCapability
import com.pulumi.nomad.kotlin.outputs.VolumeMountOptions
import com.pulumi.nomad.kotlin.outputs.VolumeTopology
import com.pulumi.nomad.kotlin.outputs.VolumeTopologyRequest
import com.pulumi.resources.Resource
import kotlin.Boolean
import kotlin.Deprecated
import kotlin.Int
import kotlin.String
import kotlin.Suppress
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
import com.pulumi.nomad.kotlin.outputs.VolumeCapability.Companion.toKotlin as volumeCapabilityToKotlin
import com.pulumi.nomad.kotlin.outputs.VolumeMountOptions.Companion.toKotlin as volumeMountOptionsToKotlin
import com.pulumi.nomad.kotlin.outputs.VolumeTopology.Companion.toKotlin as volumeTopologyToKotlin
import com.pulumi.nomad.kotlin.outputs.VolumeTopologyRequest.Companion.toKotlin as volumeTopologyRequestToKotlin
/**
* Builder for [Volume].
*/
@PulumiTagMarker
public class VolumeResourceBuilder internal constructor() {
public var name: String? = null
public var args: VolumeArgs = VolumeArgs()
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 VolumeArgsBuilder.() -> Unit) {
val builder = VolumeArgsBuilder()
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.CustomResourceOptions.opts(block)
}
internal fun build(): Volume {
val builtJavaResource = com.pulumi.nomad.Volume(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return Volume(builtJavaResource)
}
}
/**
* ## Example Usage
* Registering a volume:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as nomad from "@pulumi/nomad";
* // It can sometimes be helpful to wait for a particular plugin to be available
* const ebs = nomad.getPlugin({
* pluginId: "aws-ebs0",
* waitForHealthy: true,
* });
* const mysqlVolume = new nomad.Volume("mysql_volume", {
* type: "csi",
* pluginId: "aws-ebs0",
* volumeId: "mysql_volume",
* name: "mysql_volume",
* externalId: hashistack.ebsTestVolumeId,
* capabilities: [{
* accessMode: "single-node-writer",
* attachmentMode: "file-system",
* }],
* mountOptions: {
* fsType: "ext4",
* },
* topologyRequest: {
* required: {
* topologies: [
* {
* segments: {
* rack: "R1",
* zone: "us-east-1a",
* },
* },
* {
* segments: {
* rack: "R2",
* },
* },
* ],
* },
* },
* }, {
* dependsOn: [ebs],
* });
* ```
* ```python
* import pulumi
* import pulumi_nomad as nomad
* # It can sometimes be helpful to wait for a particular plugin to be available
* ebs = nomad.get_plugin(plugin_id="aws-ebs0",
* wait_for_healthy=True)
* mysql_volume = nomad.Volume("mysql_volume",
* type="csi",
* plugin_id="aws-ebs0",
* volume_id="mysql_volume",
* name="mysql_volume",
* external_id=hashistack["ebsTestVolumeId"],
* capabilities=[{
* "access_mode": "single-node-writer",
* "attachment_mode": "file-system",
* }],
* mount_options={
* "fs_type": "ext4",
* },
* topology_request={
* "required": {
* "topologies": [
* {
* "segments": {
* "rack": "R1",
* "zone": "us-east-1a",
* },
* },
* {
* "segments": {
* "rack": "R2",
* },
* },
* ],
* },
* },
* opts = pulumi.ResourceOptions(depends_on=[ebs]))
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using Nomad = Pulumi.Nomad;
* return await Deployment.RunAsync(() =>
* {
* // It can sometimes be helpful to wait for a particular plugin to be available
* var ebs = Nomad.GetPlugin.Invoke(new()
* {
* PluginId = "aws-ebs0",
* WaitForHealthy = true,
* });
* var mysqlVolume = new Nomad.Volume("mysql_volume", new()
* {
* Type = "csi",
* PluginId = "aws-ebs0",
* VolumeId = "mysql_volume",
* Name = "mysql_volume",
* ExternalId = hashistack.EbsTestVolumeId,
* Capabilities = new[]
* {
* new Nomad.Inputs.VolumeCapabilityArgs
* {
* AccessMode = "single-node-writer",
* AttachmentMode = "file-system",
* },
* },
* MountOptions = new Nomad.Inputs.VolumeMountOptionsArgs
* {
* FsType = "ext4",
* },
* TopologyRequest = new Nomad.Inputs.VolumeTopologyRequestArgs
* {
* Required = new Nomad.Inputs.VolumeTopologyRequestRequiredArgs
* {
* Topologies = new[]
* {
* new Nomad.Inputs.VolumeTopologyRequestRequiredTopologyArgs
* {
* Segments =
* {
* { "rack", "R1" },
* { "zone", "us-east-1a" },
* },
* },
* new Nomad.Inputs.VolumeTopologyRequestRequiredTopologyArgs
* {
* Segments =
* {
* { "rack", "R2" },
* },
* },
* },
* },
* },
* }, new CustomResourceOptions
* {
* DependsOn =
* {
* ebs,
* },
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-nomad/sdk/v2/go/nomad"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* // It can sometimes be helpful to wait for a particular plugin to be available
* ebs, err := nomad.GetPlugin(ctx, &nomad.GetPluginArgs{
* PluginId: "aws-ebs0",
* WaitForHealthy: pulumi.BoolRef(true),
* }, nil)
* if err != nil {
* return err
* }
* _, err = nomad.NewVolume(ctx, "mysql_volume", &nomad.VolumeArgs{
* Type: pulumi.String("csi"),
* PluginId: pulumi.String("aws-ebs0"),
* VolumeId: pulumi.String("mysql_volume"),
* Name: pulumi.String("mysql_volume"),
* ExternalId: pulumi.Any(hashistack.EbsTestVolumeId),
* Capabilities: nomad.VolumeCapabilityArray{
* &nomad.VolumeCapabilityArgs{
* AccessMode: pulumi.String("single-node-writer"),
* AttachmentMode: pulumi.String("file-system"),
* },
* },
* MountOptions: &nomad.VolumeMountOptionsArgs{
* FsType: pulumi.String("ext4"),
* },
* TopologyRequest: &nomad.VolumeTopologyRequestArgs{
* Required: &nomad.VolumeTopologyRequestRequiredArgs{
* Topologies: nomad.VolumeTopologyRequestRequiredTopologyArray{
* &nomad.VolumeTopologyRequestRequiredTopologyArgs{
* Segments: pulumi.StringMap{
* "rack": pulumi.String("R1"),
* "zone": pulumi.String("us-east-1a"),
* },
* },
* &nomad.VolumeTopologyRequestRequiredTopologyArgs{
* Segments: pulumi.StringMap{
* "rack": pulumi.String("R2"),
* },
* },
* },
* },
* },
* }, pulumi.DependsOn([]pulumi.Resource{
* ebs,
* }))
* if err != nil {
* return err
* }
* return nil
* })
* }
* ```
* ```java
* package generated_program;
* import com.pulumi.Context;
* import com.pulumi.Pulumi;
* import com.pulumi.core.Output;
* import com.pulumi.nomad.NomadFunctions;
* import com.pulumi.nomad.inputs.GetPluginArgs;
* import com.pulumi.nomad.Volume;
* import com.pulumi.nomad.VolumeArgs;
* import com.pulumi.nomad.inputs.VolumeCapabilityArgs;
* import com.pulumi.nomad.inputs.VolumeMountOptionsArgs;
* import com.pulumi.nomad.inputs.VolumeTopologyRequestArgs;
* import com.pulumi.nomad.inputs.VolumeTopologyRequestRequiredArgs;
* import com.pulumi.resources.CustomResourceOptions;
* 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) {
* // It can sometimes be helpful to wait for a particular plugin to be available
* final var ebs = NomadFunctions.getPlugin(GetPluginArgs.builder()
* .pluginId("aws-ebs0")
* .waitForHealthy(true)
* .build());
* var mysqlVolume = new Volume("mysqlVolume", VolumeArgs.builder()
* .type("csi")
* .pluginId("aws-ebs0")
* .volumeId("mysql_volume")
* .name("mysql_volume")
* .externalId(hashistack.ebsTestVolumeId())
* .capabilities(VolumeCapabilityArgs.builder()
* .accessMode("single-node-writer")
* .attachmentMode("file-system")
* .build())
* .mountOptions(VolumeMountOptionsArgs.builder()
* .fsType("ext4")
* .build())
* .topologyRequest(VolumeTopologyRequestArgs.builder()
* .required(VolumeTopologyRequestRequiredArgs.builder()
* .topologies(
* VolumeTopologyRequestRequiredTopologyArgs.builder()
* .segments(Map.ofEntries(
* Map.entry("rack", "R1"),
* Map.entry("zone", "us-east-1a")
* ))
* .build(),
* VolumeTopologyRequestRequiredTopologyArgs.builder()
* .segments(Map.of("rack", "R2"))
* .build())
* .build())
* .build())
* .build(), CustomResourceOptions.builder()
* .dependsOn(ebs.applyValue(getPluginResult -> getPluginResult))
* .build());
* }
* }
* ```
* ```yaml
* resources:
* mysqlVolume:
* type: nomad:Volume
* name: mysql_volume
* properties:
* type: csi
* pluginId: aws-ebs0
* volumeId: mysql_volume
* name: mysql_volume
* externalId: ${hashistack.ebsTestVolumeId}
* capabilities:
* - accessMode: single-node-writer
* attachmentMode: file-system
* mountOptions:
* fsType: ext4
* topologyRequest:
* required:
* topologies:
* - segments:
* rack: R1
* zone: us-east-1a
* - segments:
* rack: R2
* options:
* dependson:
* - ${ebs}
* variables:
* # It can sometimes be helpful to wait for a particular plugin to be available
* ebs:
* fn::invoke:
* Function: nomad:getPlugin
* Arguments:
* pluginId: aws-ebs0
* waitForHealthy: true
* ```
*
*/
public class Volume internal constructor(
override val javaResource: com.pulumi.nomad.Volume,
) : KotlinCustomResource(javaResource, VolumeMapper) {
/**
* `(string: )` - **Deprecated**. Use `capability` block instead. Defines whether a volume should be available concurrently. Possible values are:
* - `single-node-reader-only`
* - `single-node-writer`
* - `multi-node-reader-only`
* - `multi-node-single-writer`
* - `multi-node-multi-writer`
*/
@Deprecated(
message = """
use capability instead
""",
)
public val accessMode: Output?
get() = javaResource.accessMode().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* `(string: )` - **Deprecated**. Use `capability` block instead. The storage API that will be used by the volume.
*/
@Deprecated(
message = """
use capability instead
""",
)
public val attachmentMode: Output?
get() = javaResource.attachmentMode().applyValue({ args0 ->
args0.map({ args0 ->
args0
}).orElse(null)
})
/**
* `(``Capability``: )` - Options for validating the capability of a volume.
*/
public val capabilities: Output>?
get() = javaResource.capabilities().applyValue({ args0 ->
args0.map({ args0 ->
args0.map({ args0 ->
args0.let({ args0 -> volumeCapabilityToKotlin(args0) })
})
}).orElse(null)
})
/**
* `(map[string]string: )` - An optional key-value map of strings passed directly to the CSI plugin to validate the volume.
*/
public val context: Output