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

com.pulumi.nomad.kotlin.ExternalVolume.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.2.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.ExternalVolumeCapability
import com.pulumi.nomad.kotlin.outputs.ExternalVolumeMountOptions
import com.pulumi.nomad.kotlin.outputs.ExternalVolumeTopology
import com.pulumi.nomad.kotlin.outputs.ExternalVolumeTopologyRequest
import com.pulumi.resources.Resource
import kotlin.Boolean
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.ExternalVolumeCapability.Companion.toKotlin as externalVolumeCapabilityToKotlin
import com.pulumi.nomad.kotlin.outputs.ExternalVolumeMountOptions.Companion.toKotlin as externalVolumeMountOptionsToKotlin
import com.pulumi.nomad.kotlin.outputs.ExternalVolumeTopology.Companion.toKotlin as externalVolumeTopologyToKotlin
import com.pulumi.nomad.kotlin.outputs.ExternalVolumeTopologyRequest.Companion.toKotlin as externalVolumeTopologyRequestToKotlin

/**
 * Builder for [ExternalVolume].
 */
@PulumiTagMarker
public class ExternalVolumeResourceBuilder internal constructor() {
    public var name: String? = null

    public var args: ExternalVolumeArgs = ExternalVolumeArgs()

    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 ExternalVolumeArgsBuilder.() -> Unit) {
        val builder = ExternalVolumeArgsBuilder()
        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(): ExternalVolume {
        val builtJavaResource = com.pulumi.nomad.ExternalVolume(
            this.name,
            this.args.toJava(),
            this.opts.toJava(),
        )
        return ExternalVolume(builtJavaResource)
    }
}

/**
 * ## Example Usage
 * Creating 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.ExternalVolume("mysql_volume", {
 *     type: "csi",
 *     pluginId: "aws-ebs0",
 *     volumeId: "mysql_volume",
 *     name: "mysql_volume",
 *     capacityMin: "10GiB",
 *     capacityMax: "20GiB",
 *     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.ExternalVolume("mysql_volume",
 *     type="csi",
 *     plugin_id="aws-ebs0",
 *     volume_id="mysql_volume",
 *     name="mysql_volume",
 *     capacity_min="10GiB",
 *     capacity_max="20GiB",
 *     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.ExternalVolume("mysql_volume", new()
 *     {
 *         Type = "csi",
 *         PluginId = "aws-ebs0",
 *         VolumeId = "mysql_volume",
 *         Name = "mysql_volume",
 *         CapacityMin = "10GiB",
 *         CapacityMax = "20GiB",
 *         Capabilities = new[]
 *         {
 *             new Nomad.Inputs.ExternalVolumeCapabilityArgs
 *             {
 *                 AccessMode = "single-node-writer",
 *                 AttachmentMode = "file-system",
 *             },
 *         },
 *         MountOptions = new Nomad.Inputs.ExternalVolumeMountOptionsArgs
 *         {
 *             FsType = "ext4",
 *         },
 *         TopologyRequest = new Nomad.Inputs.ExternalVolumeTopologyRequestArgs
 *         {
 *             Required = new Nomad.Inputs.ExternalVolumeTopologyRequestRequiredArgs
 *             {
 *                 Topologies = new[]
 *                 {
 *                     new Nomad.Inputs.ExternalVolumeTopologyRequestRequiredTopologyArgs
 *                     {
 *                         Segments =
 *                         {
 *                             { "rack", "R1" },
 *                             { "zone", "us-east-1a" },
 *                         },
 *                     },
 *                     new Nomad.Inputs.ExternalVolumeTopologyRequestRequiredTopologyArgs
 *                     {
 *                         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.NewExternalVolume(ctx, "mysql_volume", &nomad.ExternalVolumeArgs{
 * 			Type:        pulumi.String("csi"),
 * 			PluginId:    pulumi.String("aws-ebs0"),
 * 			VolumeId:    pulumi.String("mysql_volume"),
 * 			Name:        pulumi.String("mysql_volume"),
 * 			CapacityMin: pulumi.String("10GiB"),
 * 			CapacityMax: pulumi.String("20GiB"),
 * 			Capabilities: nomad.ExternalVolumeCapabilityArray{
 * 				&nomad.ExternalVolumeCapabilityArgs{
 * 					AccessMode:     pulumi.String("single-node-writer"),
 * 					AttachmentMode: pulumi.String("file-system"),
 * 				},
 * 			},
 * 			MountOptions: &nomad.ExternalVolumeMountOptionsArgs{
 * 				FsType: pulumi.String("ext4"),
 * 			},
 * 			TopologyRequest: &nomad.ExternalVolumeTopologyRequestArgs{
 * 				Required: &nomad.ExternalVolumeTopologyRequestRequiredArgs{
 * 					Topologies: nomad.ExternalVolumeTopologyRequestRequiredTopologyArray{
 * 						&nomad.ExternalVolumeTopologyRequestRequiredTopologyArgs{
 * 							Segments: pulumi.StringMap{
 * 								"rack": pulumi.String("R1"),
 * 								"zone": pulumi.String("us-east-1a"),
 * 							},
 * 						},
 * 						&nomad.ExternalVolumeTopologyRequestRequiredTopologyArgs{
 * 							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.ExternalVolume;
 * import com.pulumi.nomad.ExternalVolumeArgs;
 * import com.pulumi.nomad.inputs.ExternalVolumeCapabilityArgs;
 * import com.pulumi.nomad.inputs.ExternalVolumeMountOptionsArgs;
 * import com.pulumi.nomad.inputs.ExternalVolumeTopologyRequestArgs;
 * import com.pulumi.nomad.inputs.ExternalVolumeTopologyRequestRequiredArgs;
 * 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 ExternalVolume("mysqlVolume", ExternalVolumeArgs.builder()
 *             .type("csi")
 *             .pluginId("aws-ebs0")
 *             .volumeId("mysql_volume")
 *             .name("mysql_volume")
 *             .capacityMin("10GiB")
 *             .capacityMax("20GiB")
 *             .capabilities(ExternalVolumeCapabilityArgs.builder()
 *                 .accessMode("single-node-writer")
 *                 .attachmentMode("file-system")
 *                 .build())
 *             .mountOptions(ExternalVolumeMountOptionsArgs.builder()
 *                 .fsType("ext4")
 *                 .build())
 *             .topologyRequest(ExternalVolumeTopologyRequestArgs.builder()
 *                 .required(ExternalVolumeTopologyRequestRequiredArgs.builder()
 *                     .topologies(
 *                         ExternalVolumeTopologyRequestRequiredTopologyArgs.builder()
 *                             .segments(Map.ofEntries(
 *                                 Map.entry("rack", "R1"),
 *                                 Map.entry("zone", "us-east-1a")
 *                             ))
 *                             .build(),
 *                         ExternalVolumeTopologyRequestRequiredTopologyArgs.builder()
 *                             .segments(Map.of("rack", "R2"))
 *                             .build())
 *                     .build())
 *                 .build())
 *             .build(), CustomResourceOptions.builder()
 *                 .dependsOn(ebs.applyValue(getPluginResult -> getPluginResult))
 *                 .build());
 *     }
 * }
 * ```
 * ```yaml
 * resources:
 *   mysqlVolume:
 *     type: nomad:ExternalVolume
 *     name: mysql_volume
 *     properties:
 *       type: csi
 *       pluginId: aws-ebs0
 *       volumeId: mysql_volume
 *       name: mysql_volume
 *       capacityMin: 10GiB
 *       capacityMax: 20GiB
 *       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 ExternalVolume internal constructor(
    override val javaResource: com.pulumi.nomad.ExternalVolume,
) : KotlinCustomResource(javaResource, ExternalVolumeMapper) {
    /**
     * `(``Capability``: )` - Options for validating the capability of a volume.
     */
    public val capabilities: Output>
        get() = javaResource.capabilities().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    externalVolumeCapabilityToKotlin(args0)
                })
            })
        })

    /**
     * `(string: )` - Option to signal a maximum volume size. This may not be supported by all storage providers.
     */
    public val capacityMax: Output?
        get() = javaResource.capacityMax().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * `(string: )` - Option to signal a minimum volume size. This may not be supported by all storage providers.
     */
    public val capacityMin: Output?
        get() = javaResource.capacityMin().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    /**
     * `(string: )` - The external ID of an existing volume to restore. If ommited, the volume will be created from scratch. Conflicts with `snapshot_id`.
     */
    public val cloneId: Output?
        get() = javaResource.cloneId().applyValue({ args0 -> args0.map({ args0 -> args0 }).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 })

    /**
     * `(block: optional)` 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 ->
                    externalVolumeMountOptionsToKotlin(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: optional)` 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: optional)` 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)
        })

    /**
     * `(string: )` - The external ID of a snapshot to restore. If ommited, the volume will be created from scratch. Conflicts with `clone_id`.
     */
    public val snapshotId: Output?
        get() = javaResource.snapshotId().applyValue({ args0 ->
            args0.map({ args0 ->
                args0
            }).orElse(null)
        })

    public val topologies: Output>
        get() = javaResource.topologies().applyValue({ args0 ->
            args0.map({ args0 ->
                args0.let({ args0 ->
                    externalVolumeTopologyToKotlin(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 -> externalVolumeTopologyRequestToKotlin(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 ExternalVolumeMapper : ResourceMapper {
    override fun supportsMappingOfType(javaResource: Resource): Boolean =
        com.pulumi.nomad.ExternalVolume::class == javaResource::class

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy