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

com.pulumi.nomad.kotlin.Volume.kt Maven / Gradle / Ivy

Go to download

Build cloud applications and infrastructure by combining the safety and reliability of infrastructure as code with the power of the Kotlin programming language.

There is a newer version: 2.4.0.0
Show newest version
@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>?
        get() = javaResource.context().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    public val controllerRequired: Output
        get() = javaResource.controllerRequired().applyValue({ args0 -> args0 })

    public val controllersExpected: Output
        get() = javaResource.controllersExpected().applyValue({ args0 -> args0 })

    public val controllersHealthy: Output
        get() = javaResource.controllersHealthy().applyValue({ args0 -> args0 })

    /**
     * `(boolean: true)` - If true, the volume will be deregistered on destroy.
     */
    public val deregisterOnDestroy: Output?
        get() = javaResource.deregisterOnDestroy().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * `(string: )` - The ID of the physical volume from the storage provider.
     */
    public val externalId: Output
        get() = javaResource.externalId().applyValue({ args0 -> args0 })

    /**
     * `(block: )` Options for mounting `block-device` volumes without a pre-formatted file system.
     */
    public val mountOptions: Output?
        get() = javaResource.mountOptions().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    volumeMountOptionsToKotlin(args0)
                })
            }).orElse(null)
        })

    /**
     * `(string: )` - The display name for the volume.
     */
    public val name: Output
        get() = javaResource.name().applyValue({ args0 -> args0 })

    /**
     * `(string: "default")` - The namespace in which to register the volume.
     */
    public val namespace: Output?
        get() = javaResource.namespace().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    public val nodesExpected: Output
        get() = javaResource.nodesExpected().applyValue({ args0 -> args0 })

    public val nodesHealthy: Output
        get() = javaResource.nodesHealthy().applyValue({ args0 -> args0 })

    /**
     * `(map[string]string: )` - An optional key-value map of strings passed directly to the CSI plugin to configure the volume.
     */
    public val parameters: Output>?
        get() = javaResource.parameters().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    /**
     * `(string: )` - The ID of the Nomad plugin for registering this volume.
     */
    public val pluginId: Output
        get() = javaResource.pluginId().applyValue({ args0 -> args0 })

    public val pluginProvider: Output
        get() = javaResource.pluginProvider().applyValue({ args0 -> args0 })

    public val pluginProviderVersion: Output
        get() = javaResource.pluginProviderVersion().applyValue({ args0 -> args0 })

    public val schedulable: Output
        get() = javaResource.schedulable().applyValue({ args0 -> args0 })

    /**
     * `(map[string]string: )` - An optional key-value map of strings used as credentials for publishing and unpublishing volumes.
     */
    public val secrets: Output>?
        get() = javaResource.secrets().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.map({ args0 ->
                    args0.key.to(args0.value)
                }).toMap()
            }).orElse(null)
        })

    public val topologies: Output>
        get() = javaResource.topologies().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    volumeTopologyToKotlin(args0)
                })
            })
        })

    /**
     * `(``TopologyRequest``: )` - Specify locations (region, zone, rack, etc.) where the provisioned volume is accessible from.
     */
    public val topologyRequest: Output?
        get() = javaResource.topologyRequest().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 -> volumeTopologyRequestToKotlin(args0) })
            }).orElse(null)
        })

    /**
     * `(string: )` - The type of the volume. Currently, only `csi` is supported.
     */
    public val type: Output?
        get() = javaResource.type().applyValue({ args0 -> args0.map({ args0 -> args0 }).orElse(null) })

    /**
     * `(string: )` - The unique ID of the volume.
     */
    public val volumeId: Output
        get() = javaResource.volumeId().applyValue({ args0 -> args0 })
}

public object VolumeMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.nomad.Volume::class == javaResource::class

    override fun map(javaResource: Resource): Volume = Volume(javaResource as com.pulumi.nomad.Volume)
}

/**
 * @see [Volume].
 * @param name The _unique_ name of the resulting resource.
 * @param block Builder for [Volume].
 */
public suspend fun volume(name: String, block: suspend VolumeResourceBuilder.() -> Unit): Volume {
    val builder = VolumeResourceBuilder()
    builder.name(name)
    block(builder)
    return builder.build()
}

/**
 * @see [Volume].
 * @param name The _unique_ name of the resulting resource.
 */
public fun volume(name: String): Volume {
    val builder = VolumeResourceBuilder()
    builder.name(name)
    return builder.build()
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy