1. Packages
  2. Digitalocean Provider
  3. API Docs
  4. VolumeAttachment
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

digitalocean.VolumeAttachment

Explore with Pulumi AI

digitalocean logo
DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi

    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

    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,
    });
    
    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)
    
    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
    	})
    }
    
    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,
        });
    
    });
    
    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());
    
        }
    }
    
    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}
    

    Create VolumeAttachment Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new VolumeAttachment(name: string, args: VolumeAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def VolumeAttachment(resource_name: str,
                         args: VolumeAttachmentArgs,
                         opts: Optional[ResourceOptions] = None)
    
    @overload
    def VolumeAttachment(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         droplet_id: Optional[int] = None,
                         volume_id: Optional[str] = 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.
    
    

    Parameters

    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.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var volumeAttachmentResource = new DigitalOcean.VolumeAttachment("volumeAttachmentResource", new()
    {
        DropletId = 0,
        VolumeId = "string",
    });
    
    example, err := digitalocean.NewVolumeAttachment(ctx, "volumeAttachmentResource", &digitalocean.VolumeAttachmentArgs{
    	DropletId: pulumi.Int(0),
    	VolumeId:  pulumi.String("string"),
    })
    
    var volumeAttachmentResource = new VolumeAttachment("volumeAttachmentResource", VolumeAttachmentArgs.builder()
        .dropletId(0)
        .volumeId("string")
        .build());
    
    volume_attachment_resource = digitalocean.VolumeAttachment("volumeAttachmentResource",
        droplet_id=0,
        volume_id="string")
    
    const volumeAttachmentResource = new digitalocean.VolumeAttachment("volumeAttachmentResource", {
        dropletId: 0,
        volumeId: "string",
    });
    
    type: digitalocean:VolumeAttachment
    properties:
        dropletId: 0
        volumeId: string
    

    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

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    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
    DigitalOcean pulumi/pulumi-digitalocean
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the digitalocean Terraform Provider.
    digitalocean logo
    DigitalOcean v4.35.0 published on Tuesday, Nov 19, 2024 by Pulumi