1. Packages
  2. OpenStack
  3. API Docs
  4. compute
  5. VolumeAttach
OpenStack v3.15.1 published on Thursday, Feb 1, 2024 by Pulumi

openstack.compute.VolumeAttach

Explore with Pulumi AI

openstack logo
OpenStack v3.15.1 published on Thursday, Feb 1, 2024 by Pulumi

    Attaches a Block Storage Volume to an Instance using the OpenStack Compute (Nova) v2 API.

    Example Usage

    Basic attachment of a single volume to a single instance

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using OpenStack = Pulumi.OpenStack;
    
    return await Deployment.RunAsync(() => 
    {
        var volume1 = new OpenStack.BlockStorage.Volume("volume1", new()
        {
            Size = 1,
        });
    
        var instance1 = new OpenStack.Compute.Instance("instance1", new()
        {
            SecurityGroups = new[]
            {
                "default",
            },
        });
    
        var va1 = new OpenStack.Compute.VolumeAttach("va1", new()
        {
            InstanceId = instance1.Id,
            VolumeId = volume1.Id,
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-openstack/sdk/v3/go/openstack/blockstorage"
    	"github.com/pulumi/pulumi-openstack/sdk/v3/go/openstack/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		volume1, err := blockstorage.NewVolume(ctx, "volume1", &blockstorage.VolumeArgs{
    			Size: pulumi.Int(1),
    		})
    		if err != nil {
    			return err
    		}
    		instance1, err := compute.NewInstance(ctx, "instance1", &compute.InstanceArgs{
    			SecurityGroups: pulumi.StringArray{
    				pulumi.String("default"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewVolumeAttach(ctx, "va1", &compute.VolumeAttachArgs{
    			InstanceId: instance1.ID(),
    			VolumeId:   volume1.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.openstack.blockstorage.Volume;
    import com.pulumi.openstack.blockstorage.VolumeArgs;
    import com.pulumi.openstack.compute.Instance;
    import com.pulumi.openstack.compute.InstanceArgs;
    import com.pulumi.openstack.compute.VolumeAttach;
    import com.pulumi.openstack.compute.VolumeAttachArgs;
    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 volume1 = new Volume("volume1", VolumeArgs.builder()        
                .size(1)
                .build());
    
            var instance1 = new Instance("instance1", InstanceArgs.builder()        
                .securityGroups("default")
                .build());
    
            var va1 = new VolumeAttach("va1", VolumeAttachArgs.builder()        
                .instanceId(instance1.id())
                .volumeId(volume1.id())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_openstack as openstack
    
    volume1 = openstack.blockstorage.Volume("volume1", size=1)
    instance1 = openstack.compute.Instance("instance1", security_groups=["default"])
    va1 = openstack.compute.VolumeAttach("va1",
        instance_id=instance1.id,
        volume_id=volume1.id)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as openstack from "@pulumi/openstack";
    
    const volume1 = new openstack.blockstorage.Volume("volume1", {size: 1});
    const instance1 = new openstack.compute.Instance("instance1", {securityGroups: ["default"]});
    const va1 = new openstack.compute.VolumeAttach("va1", {
        instanceId: instance1.id,
        volumeId: volume1.id,
    });
    
    resources:
      volume1:
        type: openstack:blockstorage:Volume
        properties:
          size: 1
      instance1:
        type: openstack:compute:Instance
        properties:
          securityGroups:
            - default
      va1:
        type: openstack:compute:VolumeAttach
        properties:
          instanceId: ${instance1.id}
          volumeId: ${volume1.id}
    

    Using Multiattach-enabled volumes

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using OpenStack = Pulumi.OpenStack;
    
    return await Deployment.RunAsync(() => 
    {
        var volume1 = new OpenStack.BlockStorage.Volume("volume1", new()
        {
            Size = 1,
            Multiattach = true,
        });
    
        var instance1 = new OpenStack.Compute.Instance("instance1", new()
        {
            SecurityGroups = new[]
            {
                "default",
            },
        });
    
        var instance2 = new OpenStack.Compute.Instance("instance2", new()
        {
            SecurityGroups = new[]
            {
                "default",
            },
        });
    
        var va1 = new OpenStack.Compute.VolumeAttach("va1", new()
        {
            InstanceId = instance1.Id,
            VolumeId = volume1.Id,
            Multiattach = true,
        });
    
        var va2 = new OpenStack.Compute.VolumeAttach("va2", new()
        {
            InstanceId = instance2.Id,
            VolumeId = volume1.Id,
            Multiattach = true,
        }, new CustomResourceOptions
        {
            DependsOn = new[]
            {
                "openstack_compute_volume_attach_v2.va_1",
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-openstack/sdk/v3/go/openstack/blockstorage"
    	"github.com/pulumi/pulumi-openstack/sdk/v3/go/openstack/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		volume1, err := blockstorage.NewVolume(ctx, "volume1", &blockstorage.VolumeArgs{
    			Size:        pulumi.Int(1),
    			Multiattach: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		instance1, err := compute.NewInstance(ctx, "instance1", &compute.InstanceArgs{
    			SecurityGroups: pulumi.StringArray{
    				pulumi.String("default"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		instance2, err := compute.NewInstance(ctx, "instance2", &compute.InstanceArgs{
    			SecurityGroups: pulumi.StringArray{
    				pulumi.String("default"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewVolumeAttach(ctx, "va1", &compute.VolumeAttachArgs{
    			InstanceId:  instance1.ID(),
    			VolumeId:    volume1.ID(),
    			Multiattach: pulumi.Bool(true),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewVolumeAttach(ctx, "va2", &compute.VolumeAttachArgs{
    			InstanceId:  instance2.ID(),
    			VolumeId:    volume1.ID(),
    			Multiattach: pulumi.Bool(true),
    		}, pulumi.DependsOn([]pulumi.Resource{
    			pulumi.Resource("openstack_compute_volume_attach_v2.va_1"),
    		}))
    		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.openstack.blockstorage.Volume;
    import com.pulumi.openstack.blockstorage.VolumeArgs;
    import com.pulumi.openstack.compute.Instance;
    import com.pulumi.openstack.compute.InstanceArgs;
    import com.pulumi.openstack.compute.VolumeAttach;
    import com.pulumi.openstack.compute.VolumeAttachArgs;
    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) {
            var volume1 = new Volume("volume1", VolumeArgs.builder()        
                .size(1)
                .multiattach(true)
                .build());
    
            var instance1 = new Instance("instance1", InstanceArgs.builder()        
                .securityGroups("default")
                .build());
    
            var instance2 = new Instance("instance2", InstanceArgs.builder()        
                .securityGroups("default")
                .build());
    
            var va1 = new VolumeAttach("va1", VolumeAttachArgs.builder()        
                .instanceId(instance1.id())
                .volumeId(volume1.id())
                .multiattach(true)
                .build());
    
            var va2 = new VolumeAttach("va2", VolumeAttachArgs.builder()        
                .instanceId(instance2.id())
                .volumeId(volume1.id())
                .multiattach(true)
                .build(), CustomResourceOptions.builder()
                    .dependsOn("openstack_compute_volume_attach_v2.va_1")
                    .build());
    
        }
    }
    
    import pulumi
    import pulumi_openstack as openstack
    
    volume1 = openstack.blockstorage.Volume("volume1",
        size=1,
        multiattach=True)
    instance1 = openstack.compute.Instance("instance1", security_groups=["default"])
    instance2 = openstack.compute.Instance("instance2", security_groups=["default"])
    va1 = openstack.compute.VolumeAttach("va1",
        instance_id=instance1.id,
        volume_id=volume1.id,
        multiattach=True)
    va2 = openstack.compute.VolumeAttach("va2",
        instance_id=instance2.id,
        volume_id=volume1.id,
        multiattach=True,
        opts=pulumi.ResourceOptions(depends_on=["openstack_compute_volume_attach_v2.va_1"]))
    
    import * as pulumi from "@pulumi/pulumi";
    import * as openstack from "@pulumi/openstack";
    
    const volume1 = new openstack.blockstorage.Volume("volume1", {
        size: 1,
        multiattach: true,
    });
    const instance1 = new openstack.compute.Instance("instance1", {securityGroups: ["default"]});
    const instance2 = new openstack.compute.Instance("instance2", {securityGroups: ["default"]});
    const va1 = new openstack.compute.VolumeAttach("va1", {
        instanceId: instance1.id,
        volumeId: volume1.id,
        multiattach: true,
    });
    const va2 = new openstack.compute.VolumeAttach("va2", {
        instanceId: instance2.id,
        volumeId: volume1.id,
        multiattach: true,
    }, {
        dependsOn: ["openstack_compute_volume_attach_v2.va_1"],
    });
    
    resources:
      volume1:
        type: openstack:blockstorage:Volume
        properties:
          size: 1
          multiattach: true
      instance1:
        type: openstack:compute:Instance
        properties:
          securityGroups:
            - default
      instance2:
        type: openstack:compute:Instance
        properties:
          securityGroups:
            - default
      va1:
        type: openstack:compute:VolumeAttach
        properties:
          instanceId: ${instance1.id}
          volumeId: ${volume1.id}
          multiattach: true
      va2:
        type: openstack:compute:VolumeAttach
        properties:
          instanceId: ${instance2.id}
          volumeId: ${volume1.id}
          multiattach: true
        options:
          dependson:
            - openstack_compute_volume_attach_v2.va_1
    

    Create VolumeAttach Resource

    new VolumeAttach(name: string, args: VolumeAttachArgs, opts?: CustomResourceOptions);
    @overload
    def VolumeAttach(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     device: Optional[str] = None,
                     instance_id: Optional[str] = None,
                     multiattach: Optional[bool] = None,
                     region: Optional[str] = None,
                     vendor_options: Optional[VolumeAttachVendorOptionsArgs] = None,
                     volume_id: Optional[str] = None)
    @overload
    def VolumeAttach(resource_name: str,
                     args: VolumeAttachArgs,
                     opts: Optional[ResourceOptions] = None)
    func NewVolumeAttach(ctx *Context, name string, args VolumeAttachArgs, opts ...ResourceOption) (*VolumeAttach, error)
    public VolumeAttach(string name, VolumeAttachArgs args, CustomResourceOptions? opts = null)
    public VolumeAttach(String name, VolumeAttachArgs args)
    public VolumeAttach(String name, VolumeAttachArgs args, CustomResourceOptions options)
    
    type: openstack:compute:VolumeAttach
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args VolumeAttachArgs
    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 VolumeAttachArgs
    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 VolumeAttachArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args VolumeAttachArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args VolumeAttachArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    VolumeAttach 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 VolumeAttach resource accepts the following input properties:

    InstanceId string
    The ID of the Instance to attach the Volume to.
    VolumeId string
    The ID of the Volume to attach to an Instance.
    Device string
    Multiattach bool
    Enable attachment of multiattach-capable volumes.
    Region string
    The region in which to obtain the V2 Compute client. A Compute client is needed to create a volume attachment. If omitted, the region argument of the provider is used. Changing this creates a new volume attachment.
    VendorOptions Pulumi.OpenStack.Compute.Inputs.VolumeAttachVendorOptions
    Map of additional vendor-specific options. Supported options are described below.
    InstanceId string
    The ID of the Instance to attach the Volume to.
    VolumeId string
    The ID of the Volume to attach to an Instance.
    Device string
    Multiattach bool
    Enable attachment of multiattach-capable volumes.
    Region string
    The region in which to obtain the V2 Compute client. A Compute client is needed to create a volume attachment. If omitted, the region argument of the provider is used. Changing this creates a new volume attachment.
    VendorOptions VolumeAttachVendorOptionsArgs
    Map of additional vendor-specific options. Supported options are described below.
    instanceId String
    The ID of the Instance to attach the Volume to.
    volumeId String
    The ID of the Volume to attach to an Instance.
    device String
    multiattach Boolean
    Enable attachment of multiattach-capable volumes.
    region String
    The region in which to obtain the V2 Compute client. A Compute client is needed to create a volume attachment. If omitted, the region argument of the provider is used. Changing this creates a new volume attachment.
    vendorOptions VolumeAttachVendorOptions
    Map of additional vendor-specific options. Supported options are described below.
    instanceId string
    The ID of the Instance to attach the Volume to.
    volumeId string
    The ID of the Volume to attach to an Instance.
    device string
    multiattach boolean
    Enable attachment of multiattach-capable volumes.
    region string
    The region in which to obtain the V2 Compute client. A Compute client is needed to create a volume attachment. If omitted, the region argument of the provider is used. Changing this creates a new volume attachment.
    vendorOptions VolumeAttachVendorOptions
    Map of additional vendor-specific options. Supported options are described below.
    instance_id str
    The ID of the Instance to attach the Volume to.
    volume_id str
    The ID of the Volume to attach to an Instance.
    device str
    multiattach bool
    Enable attachment of multiattach-capable volumes.
    region str
    The region in which to obtain the V2 Compute client. A Compute client is needed to create a volume attachment. If omitted, the region argument of the provider is used. Changing this creates a new volume attachment.
    vendor_options VolumeAttachVendorOptionsArgs
    Map of additional vendor-specific options. Supported options are described below.
    instanceId String
    The ID of the Instance to attach the Volume to.
    volumeId String
    The ID of the Volume to attach to an Instance.
    device String
    multiattach Boolean
    Enable attachment of multiattach-capable volumes.
    region String
    The region in which to obtain the V2 Compute client. A Compute client is needed to create a volume attachment. If omitted, the region argument of the provider is used. Changing this creates a new volume attachment.
    vendorOptions Property Map
    Map of additional vendor-specific options. Supported options are described below.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the VolumeAttach 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 VolumeAttach Resource

    Get an existing VolumeAttach 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?: VolumeAttachState, opts?: CustomResourceOptions): VolumeAttach
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            device: Optional[str] = None,
            instance_id: Optional[str] = None,
            multiattach: Optional[bool] = None,
            region: Optional[str] = None,
            vendor_options: Optional[VolumeAttachVendorOptionsArgs] = None,
            volume_id: Optional[str] = None) -> VolumeAttach
    func GetVolumeAttach(ctx *Context, name string, id IDInput, state *VolumeAttachState, opts ...ResourceOption) (*VolumeAttach, error)
    public static VolumeAttach Get(string name, Input<string> id, VolumeAttachState? state, CustomResourceOptions? opts = null)
    public static VolumeAttach get(String name, Output<String> id, VolumeAttachState 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:
    Device string
    InstanceId string
    The ID of the Instance to attach the Volume to.
    Multiattach bool
    Enable attachment of multiattach-capable volumes.
    Region string
    The region in which to obtain the V2 Compute client. A Compute client is needed to create a volume attachment. If omitted, the region argument of the provider is used. Changing this creates a new volume attachment.
    VendorOptions Pulumi.OpenStack.Compute.Inputs.VolumeAttachVendorOptions
    Map of additional vendor-specific options. Supported options are described below.
    VolumeId string
    The ID of the Volume to attach to an Instance.
    Device string
    InstanceId string
    The ID of the Instance to attach the Volume to.
    Multiattach bool
    Enable attachment of multiattach-capable volumes.
    Region string
    The region in which to obtain the V2 Compute client. A Compute client is needed to create a volume attachment. If omitted, the region argument of the provider is used. Changing this creates a new volume attachment.
    VendorOptions VolumeAttachVendorOptionsArgs
    Map of additional vendor-specific options. Supported options are described below.
    VolumeId string
    The ID of the Volume to attach to an Instance.
    device String
    instanceId String
    The ID of the Instance to attach the Volume to.
    multiattach Boolean
    Enable attachment of multiattach-capable volumes.
    region String
    The region in which to obtain the V2 Compute client. A Compute client is needed to create a volume attachment. If omitted, the region argument of the provider is used. Changing this creates a new volume attachment.
    vendorOptions VolumeAttachVendorOptions
    Map of additional vendor-specific options. Supported options are described below.
    volumeId String
    The ID of the Volume to attach to an Instance.
    device string
    instanceId string
    The ID of the Instance to attach the Volume to.
    multiattach boolean
    Enable attachment of multiattach-capable volumes.
    region string
    The region in which to obtain the V2 Compute client. A Compute client is needed to create a volume attachment. If omitted, the region argument of the provider is used. Changing this creates a new volume attachment.
    vendorOptions VolumeAttachVendorOptions
    Map of additional vendor-specific options. Supported options are described below.
    volumeId string
    The ID of the Volume to attach to an Instance.
    device str
    instance_id str
    The ID of the Instance to attach the Volume to.
    multiattach bool
    Enable attachment of multiattach-capable volumes.
    region str
    The region in which to obtain the V2 Compute client. A Compute client is needed to create a volume attachment. If omitted, the region argument of the provider is used. Changing this creates a new volume attachment.
    vendor_options VolumeAttachVendorOptionsArgs
    Map of additional vendor-specific options. Supported options are described below.
    volume_id str
    The ID of the Volume to attach to an Instance.
    device String
    instanceId String
    The ID of the Instance to attach the Volume to.
    multiattach Boolean
    Enable attachment of multiattach-capable volumes.
    region String
    The region in which to obtain the V2 Compute client. A Compute client is needed to create a volume attachment. If omitted, the region argument of the provider is used. Changing this creates a new volume attachment.
    vendorOptions Property Map
    Map of additional vendor-specific options. Supported options are described below.
    volumeId String
    The ID of the Volume to attach to an Instance.

    Supporting Types

    VolumeAttachVendorOptions, VolumeAttachVendorOptionsArgs

    IgnoreVolumeConfirmation bool
    Boolean to control whether to ignore volume status confirmation of the attached volume. This can be helpful to work with some OpenStack clouds which don't have the Block Storage V3 API available.
    IgnoreVolumeConfirmation bool
    Boolean to control whether to ignore volume status confirmation of the attached volume. This can be helpful to work with some OpenStack clouds which don't have the Block Storage V3 API available.
    ignoreVolumeConfirmation Boolean
    Boolean to control whether to ignore volume status confirmation of the attached volume. This can be helpful to work with some OpenStack clouds which don't have the Block Storage V3 API available.
    ignoreVolumeConfirmation boolean
    Boolean to control whether to ignore volume status confirmation of the attached volume. This can be helpful to work with some OpenStack clouds which don't have the Block Storage V3 API available.
    ignore_volume_confirmation bool
    Boolean to control whether to ignore volume status confirmation of the attached volume. This can be helpful to work with some OpenStack clouds which don't have the Block Storage V3 API available.
    ignoreVolumeConfirmation Boolean
    Boolean to control whether to ignore volume status confirmation of the attached volume. This can be helpful to work with some OpenStack clouds which don't have the Block Storage V3 API available.

    Import

    Volume Attachments can be imported using the Instance ID and Volume ID separated by a slash, e.g.

     $ pulumi import openstack:compute/volumeAttach:VolumeAttach va_1 89c60255-9bd6-460c-822a-e2b959ede9d2/45670584-225f-46c3-b33e-6707b589b666
    

    Package Details

    Repository
    OpenStack pulumi/pulumi-openstack
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the openstack Terraform Provider.
    openstack logo
    OpenStack v3.15.1 published on Thursday, Feb 1, 2024 by Pulumi