DigitalOcean

v4.16.0 published on Wednesday, Sep 28, 2022 by Pulumi

VolumeAttachment

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

using System.Collections.Generic;
using Pulumi;
using DigitalOcean = Pulumi.DigitalOcean;

return await Deployment.RunAsync(() => 
{
    var foobarVolume = new DigitalOcean.Volume("foobarVolume", new()
    {
        Region = "nyc1",
        Size = 100,
        InitialFilesystemType = "ext4",
        Description = "an example volume",
    });

    var foobarDroplet = new DigitalOcean.Droplet("foobarDroplet", new()
    {
        Size = "s-1vcpu-1gb",
        Image = "ubuntu-18-04-x64",
        Region = "nyc1",
    });

    var foobarVolumeAttachment = new DigitalOcean.VolumeAttachment("foobarVolumeAttachment", new()
    {
        DropletId = foobarDroplet.Id,
        VolumeId = foobarVolume.Id,
    });

});
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 {
		foobarVolume, err := digitalocean.NewVolume(ctx, "foobarVolume", &digitalocean.VolumeArgs{
			Region:                pulumi.String("nyc1"),
			Size:                  pulumi.Int(100),
			InitialFilesystemType: pulumi.String("ext4"),
			Description:           pulumi.String("an example volume"),
		})
		if err != nil {
			return err
		}
		foobarDroplet, err := digitalocean.NewDroplet(ctx, "foobarDroplet", &digitalocean.DropletArgs{
			Size:   pulumi.String("s-1vcpu-1gb"),
			Image:  pulumi.String("ubuntu-18-04-x64"),
			Region: pulumi.String("nyc1"),
		})
		if err != nil {
			return err
		}
		_, err = digitalocean.NewVolumeAttachment(ctx, "foobarVolumeAttachment", &digitalocean.VolumeAttachmentArgs{
			DropletId: foobarDroplet.ID(),
			VolumeId:  foobarVolume.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
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 foobarVolume = new Volume("foobarVolume", VolumeArgs.builder()        
            .region("nyc1")
            .size(100)
            .initialFilesystemType("ext4")
            .description("an example volume")
            .build());

        var foobarDroplet = new Droplet("foobarDroplet", DropletArgs.builder()        
            .size("s-1vcpu-1gb")
            .image("ubuntu-18-04-x64")
            .region("nyc1")
            .build());

        var foobarVolumeAttachment = new VolumeAttachment("foobarVolumeAttachment", VolumeAttachmentArgs.builder()        
            .dropletId(foobarDroplet.id())
            .volumeId(foobarVolume.id())
            .build());

    }
}
import pulumi
import pulumi_digitalocean as digitalocean

foobar_volume = digitalocean.Volume("foobarVolume",
    region="nyc1",
    size=100,
    initial_filesystem_type="ext4",
    description="an example volume")
foobar_droplet = digitalocean.Droplet("foobarDroplet",
    size="s-1vcpu-1gb",
    image="ubuntu-18-04-x64",
    region="nyc1")
foobar_volume_attachment = digitalocean.VolumeAttachment("foobarVolumeAttachment",
    droplet_id=foobar_droplet.id,
    volume_id=foobar_volume.id)
import * as pulumi from "@pulumi/pulumi";
import * as digitalocean from "@pulumi/digitalocean";

const foobarVolume = new digitalocean.Volume("foobarVolume", {
    region: "nyc1",
    size: 100,
    initialFilesystemType: "ext4",
    description: "an example volume",
});
const foobarDroplet = new digitalocean.Droplet("foobarDroplet", {
    size: "s-1vcpu-1gb",
    image: "ubuntu-18-04-x64",
    region: "nyc1",
});
const foobarVolumeAttachment = new digitalocean.VolumeAttachment("foobarVolumeAttachment", {
    dropletId: foobarDroplet.id,
    volumeId: foobarVolume.id,
});
resources:
  foobarVolume:
    type: digitalocean:Volume
    properties:
      region: nyc1
      size: 100
      initialFilesystemType: ext4
      description: an example volume
  foobarDroplet:
    type: digitalocean:Droplet
    properties:
      size: s-1vcpu-1gb
      image: ubuntu-18-04-x64
      region: nyc1
  foobarVolumeAttachment:
    type: digitalocean:VolumeAttachment
    properties:
      dropletId: ${foobarDroplet.id}
      volumeId: ${foobarVolume.id}

Create VolumeAttachment Resource

new VolumeAttachment(name: string, args: VolumeAttachmentArgs, opts?: CustomResourceOptions);
@overload
def VolumeAttachment(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     droplet_id: Optional[int] = None,
                     volume_id: Optional[str] = None)
@overload
def VolumeAttachment(resource_name: str,
                     args: VolumeAttachmentArgs,
                     opts: Optional[ResourceOptions] = None)
func NewVolumeAttachment(ctx *Context, name string, args VolumeAttachmentArgs, opts ...ResourceOption) (*VolumeAttachment, error)
public VolumeAttachment(string name, VolumeAttachmentArgs args, CustomResourceOptions? opts = null)
public VolumeAttachment(String name, VolumeAttachmentArgs args)
public VolumeAttachment(String name, VolumeAttachmentArgs args, CustomResourceOptions options)
type: digitalocean:VolumeAttachment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args VolumeAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args VolumeAttachmentArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args VolumeAttachmentArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args VolumeAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args VolumeAttachmentArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

VolumeAttachment Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The VolumeAttachment resource accepts the following input properties:

DropletId int

ID of the Droplet to attach the volume to.

VolumeId string

ID of the Volume to be attached to the Droplet.

DropletId int

ID of the Droplet to attach the volume to.

VolumeId string

ID of the Volume to be attached to the Droplet.

dropletId Integer

ID of the Droplet to attach the volume to.

volumeId String

ID of the Volume to be attached to the Droplet.

dropletId number

ID of the Droplet to attach the volume to.

volumeId string

ID of the Volume to be attached to the Droplet.

droplet_id int

ID of the Droplet to attach the volume to.

volume_id str

ID of the Volume to be attached to the Droplet.

dropletId Number

ID of the Droplet to attach the volume to.

volumeId String

ID of the Volume to be attached to the Droplet.

Outputs

All input properties are implicitly available as output properties. Additionally, the VolumeAttachment resource produces the following output properties:

Id string

The provider-assigned unique ID for this managed resource.

Id string

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

id string

The provider-assigned unique ID for this managed resource.

id str

The provider-assigned unique ID for this managed resource.

id String

The provider-assigned unique ID for this managed resource.

Look up Existing VolumeAttachment Resource

Get an existing VolumeAttachment resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: VolumeAttachmentState, opts?: CustomResourceOptions): VolumeAttachment
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        droplet_id: Optional[int] = None,
        volume_id: Optional[str] = None) -> VolumeAttachment
func GetVolumeAttachment(ctx *Context, name string, id IDInput, state *VolumeAttachmentState, opts ...ResourceOption) (*VolumeAttachment, error)
public static VolumeAttachment Get(string name, Input<string> id, VolumeAttachmentState? state, CustomResourceOptions? opts = null)
public static VolumeAttachment get(String name, Output<String> id, VolumeAttachmentState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
DropletId int

ID of the Droplet to attach the volume to.

VolumeId string

ID of the Volume to be attached to the Droplet.

DropletId int

ID of the Droplet to attach the volume to.

VolumeId string

ID of the Volume to be attached to the Droplet.

dropletId Integer

ID of the Droplet to attach the volume to.

volumeId String

ID of the Volume to be attached to the Droplet.

dropletId number

ID of the Droplet to attach the volume to.

volumeId string

ID of the Volume to be attached to the Droplet.

droplet_id int

ID of the Droplet to attach the volume to.

volume_id str

ID of the Volume to be attached to the Droplet.

dropletId Number

ID of the Droplet to attach the volume to.

volumeId String

ID of the Volume to be attached to the Droplet.

Package Details

Repository
https://github.com/pulumi/pulumi-digitalocean
License
Apache-2.0
Notes

This Pulumi package is based on the digitalocean Terraform Provider.