Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.pulumi.digitalocean.kotlin.VolumeAttachment.kt Maven / Gradle / Ivy
@file:Suppress("NAME_SHADOWING", "DEPRECATION")
package com.pulumi.digitalocean.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
/**
* Builder for [VolumeAttachment].
*/
@PulumiTagMarker
public class VolumeAttachmentResourceBuilder internal constructor() {
public var name: String? = null
public var args: VolumeAttachmentArgs = VolumeAttachmentArgs()
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 VolumeAttachmentArgsBuilder.() -> Unit) {
val builder = VolumeAttachmentArgsBuilder()
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(): VolumeAttachment {
val builtJavaResource = com.pulumi.digitalocean.VolumeAttachment(
this.name,
this.args.toJava(),
this.opts.toJava(),
)
return VolumeAttachment(builtJavaResource)
}
}
/**
* Manages attaching a Volume to a Droplet.
* > **NOTE:** Volumes can be attached either directly on the `digitalocean.Droplet` resource, or using the `digitalocean.VolumeAttachment` resource - but the two cannot be used together. If both are used against the same Droplet, the volume attachments will constantly drift.
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as digitalocean from "@pulumi/digitalocean";
* const foobar = new digitalocean.Volume("foobar", {
* region: digitalocean.Region.NYC1,
* name: "baz",
* size: 100,
* initialFilesystemType: digitalocean.FileSystemType.EXT4,
* description: "an example volume",
* });
* const foobarDroplet = new digitalocean.Droplet("foobar", {
* name: "baz",
* size: digitalocean.DropletSlug.DropletS1VCPU1GB,
* image: "ubuntu-18-04-x64",
* region: digitalocean.Region.NYC1,
* });
* const foobarVolumeAttachment = new digitalocean.VolumeAttachment("foobar", {
* dropletId: foobarDroplet.id,
* volumeId: foobar.id,
* });
* ```
* ```python
* import pulumi
* import pulumi_digitalocean as digitalocean
* foobar = digitalocean.Volume("foobar",
* region=digitalocean.Region.NYC1,
* name="baz",
* size=100,
* initial_filesystem_type=digitalocean.FileSystemType.EXT4,
* description="an example volume")
* foobar_droplet = digitalocean.Droplet("foobar",
* name="baz",
* size=digitalocean.DropletSlug.DROPLET_S1_VCPU1_GB,
* image="ubuntu-18-04-x64",
* region=digitalocean.Region.NYC1)
* foobar_volume_attachment = digitalocean.VolumeAttachment("foobar",
* droplet_id=foobar_droplet.id,
* volume_id=foobar.id)
* ```
* ```csharp
* using System.Collections.Generic;
* using System.Linq;
* using Pulumi;
* using DigitalOcean = Pulumi.DigitalOcean;
* return await Deployment.RunAsync(() =>
* {
* var foobar = new DigitalOcean.Volume("foobar", new()
* {
* Region = DigitalOcean.Region.NYC1,
* Name = "baz",
* Size = 100,
* InitialFilesystemType = DigitalOcean.FileSystemType.EXT4,
* Description = "an example volume",
* });
* var foobarDroplet = new DigitalOcean.Droplet("foobar", new()
* {
* Name = "baz",
* Size = DigitalOcean.DropletSlug.DropletS1VCPU1GB,
* Image = "ubuntu-18-04-x64",
* Region = DigitalOcean.Region.NYC1,
* });
* var foobarVolumeAttachment = new DigitalOcean.VolumeAttachment("foobar", new()
* {
* DropletId = foobarDroplet.Id,
* VolumeId = foobar.Id,
* });
* });
* ```
* ```go
* package main
* import (
* "github.com/pulumi/pulumi-digitalocean/sdk/v4/go/digitalocean"
* "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
* )
* func main() {
* pulumi.Run(func(ctx *pulumi.Context) error {
* foobar, err := digitalocean.NewVolume(ctx, "foobar", &digitalocean.VolumeArgs{
* Region: pulumi.String(digitalocean.RegionNYC1),
* Name: pulumi.String("baz"),
* Size: pulumi.Int(100),
* InitialFilesystemType: pulumi.String(digitalocean.FileSystemTypeEXT4),
* Description: pulumi.String("an example volume"),
* })
* if err != nil {
* return err
* }
* foobarDroplet, err := digitalocean.NewDroplet(ctx, "foobar", &digitalocean.DropletArgs{
* Name: pulumi.String("baz"),
* Size: pulumi.String(digitalocean.DropletSlugDropletS1VCPU1GB),
* Image: pulumi.String("ubuntu-18-04-x64"),
* Region: pulumi.String(digitalocean.RegionNYC1),
* })
* if err != nil {
* return err
* }
* _, err = digitalocean.NewVolumeAttachment(ctx, "foobar", &digitalocean.VolumeAttachmentArgs{
* DropletId: foobarDroplet.ID(),
* VolumeId: foobar.ID(),
* })
* 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.digitalocean.Volume;
* import com.pulumi.digitalocean.VolumeArgs;
* import com.pulumi.digitalocean.Droplet;
* import com.pulumi.digitalocean.DropletArgs;
* import com.pulumi.digitalocean.VolumeAttachment;
* import com.pulumi.digitalocean.VolumeAttachmentArgs;
* 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 foobar = new Volume("foobar", VolumeArgs.builder()
* .region("nyc1")
* .name("baz")
* .size(100)
* .initialFilesystemType("ext4")
* .description("an example volume")
* .build());
* var foobarDroplet = new Droplet("foobarDroplet", DropletArgs.builder()
* .name("baz")
* .size("s-1vcpu-1gb")
* .image("ubuntu-18-04-x64")
* .region("nyc1")
* .build());
* var foobarVolumeAttachment = new VolumeAttachment("foobarVolumeAttachment", VolumeAttachmentArgs.builder()
* .dropletId(foobarDroplet.id())
* .volumeId(foobar.id())
* .build());
* }
* }
* ```
* ```yaml
* resources:
* foobar:
* type: digitalocean:Volume
* properties:
* region: nyc1
* name: baz
* size: 100
* initialFilesystemType: ext4
* description: an example volume
* foobarDroplet:
* type: digitalocean:Droplet
* name: foobar
* properties:
* name: baz
* size: s-1vcpu-1gb
* image: ubuntu-18-04-x64
* region: nyc1
* foobarVolumeAttachment:
* type: digitalocean:VolumeAttachment
* name: foobar
* properties:
* dropletId: ${foobarDroplet.id}
* volumeId: ${foobar.id}
* ```
*
*/
public class VolumeAttachment internal constructor(
override val javaResource: com.pulumi.digitalocean.VolumeAttachment,
) : KotlinCustomResource(javaResource, VolumeAttachmentMapper) {
/**
* ID of the Droplet to attach the volume to.
*/
public val dropletId: Output
get() = javaResource.dropletId().applyValue({ args0 -> args0 })
/**
* ID of the Volume to be attached to the Droplet.
*/
public val volumeId: Output
get() = javaResource.volumeId().applyValue({ args0 -> args0 })
}
public object VolumeAttachmentMapper : ResourceMapper {
override fun supportsMappingOfType(javaResource: Resource): Boolean =
com.pulumi.digitalocean.VolumeAttachment::class == javaResource::class
override fun map(javaResource: Resource): VolumeAttachment = VolumeAttachment(
javaResource as
com.pulumi.digitalocean.VolumeAttachment,
)
}
/**
* @see [VolumeAttachment].
* @param name The _unique_ name of the resulting resource.
* @param block Builder for [VolumeAttachment].
*/
public suspend fun volumeAttachment(
name: String,
block: suspend VolumeAttachmentResourceBuilder.() -> Unit,
): VolumeAttachment {
val builder = VolumeAttachmentResourceBuilder()
builder.name(name)
block(builder)
return builder.build()
}
/**
* @see [VolumeAttachment].
* @param name The _unique_ name of the resulting resource.
*/
public fun volumeAttachment(name: String): VolumeAttachment {
val builder = VolumeAttachmentResourceBuilder()
builder.name(name)
return builder.build()
}