openstack.compute.VolumeAttach
Explore with Pulumi AI
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 Pulumi;
using OpenStack = Pulumi.OpenStack;
return await Deployment.RunAsync(() =>
{
var volume1 = new OpenStack.BlockStorage.VolumeV2("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.NewVolumeV2(ctx, "volume1", &blockstorage.VolumeV2Args{
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.VolumeV2;
import com.pulumi.openstack.blockstorage.VolumeV2Args;
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 VolumeV2("volume1", VolumeV2Args.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.VolumeV2("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.VolumeV2("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:VolumeV2
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 Pulumi;
using OpenStack = Pulumi.OpenStack;
return await Deployment.RunAsync(() =>
{
var volume1 = new OpenStack.BlockStorage.Volume("volume1", new()
{
Multiattach = true,
Size = 1,
});
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,
Multiattach = true,
VolumeId = openstack_blockstorage_volume_v2.Volume_1.Id,
});
var va2 = new OpenStack.Compute.VolumeAttach("va2", new()
{
InstanceId = instance2.Id,
Multiattach = true,
VolumeId = openstack_blockstorage_volume_v2.Volume_1.Id,
}, 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 {
_, err := blockstorage.NewVolume(ctx, "volume1", &blockstorage.VolumeArgs{
Multiattach: pulumi.Bool(true),
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
}
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(),
Multiattach: pulumi.Bool(true),
VolumeId: pulumi.Any(openstack_blockstorage_volume_v2.Volume_1.Id),
})
if err != nil {
return err
}
_, err = compute.NewVolumeAttach(ctx, "va2", &compute.VolumeAttachArgs{
InstanceId: instance2.ID(),
Multiattach: pulumi.Bool(true),
VolumeId: pulumi.Any(openstack_blockstorage_volume_v2.Volume_1.Id),
}, 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()
.multiattach(true)
.size(1)
.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())
.multiattach(true)
.volumeId(openstack_blockstorage_volume_v2.volume_1().id())
.build());
var va2 = new VolumeAttach("va2", VolumeAttachArgs.builder()
.instanceId(instance2.id())
.multiattach(true)
.volumeId(openstack_blockstorage_volume_v2.volume_1().id())
.build(), CustomResourceOptions.builder()
.dependsOn("openstack_compute_volume_attach_v2.va_1")
.build());
}
}
import pulumi
import pulumi_openstack as openstack
volume1 = openstack.blockstorage.Volume("volume1",
multiattach=True,
size=1)
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,
multiattach=True,
volume_id=openstack_blockstorage_volume_v2["volume_1"]["id"])
va2 = openstack.compute.VolumeAttach("va2",
instance_id=instance2.id,
multiattach=True,
volume_id=openstack_blockstorage_volume_v2["volume_1"]["id"],
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", {
multiattach: true,
size: 1,
});
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,
multiattach: true,
volumeId: openstack_blockstorage_volume_v2.volume_1.id,
});
const va2 = new openstack.compute.VolumeAttach("va2", {
instanceId: instance2.id,
multiattach: true,
volumeId: openstack_blockstorage_volume_v2.volume_1.id,
}, {
dependsOn: ["openstack_compute_volume_attach_v2.va_1"],
});
resources:
volume1:
type: openstack:blockstorage:Volume
properties:
multiattach: true
size: 1
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}
multiattach: true
volumeId: ${openstack_blockstorage_volume_v2.volume_1.id}
va2:
type: openstack:compute:VolumeAttach
properties:
instanceId: ${instance2.id}
multiattach: true
volumeId: ${openstack_blockstorage_volume_v2.volume_1.id}
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:
- Instance
Id string The ID of the Instance to attach the Volume to.
- Volume
Id string The ID of the Volume to attach to an Instance.
- Device string
See Argument Reference above. NOTE: The correctness of this information is dependent upon the hypervisor in use. In some cases, this should not be used as an authoritative piece of information.
- 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.- Vendor
Options Pulumi.Open Stack. Compute. Inputs. Volume Attach Vendor Options Args Map of additional vendor-specific options. Supported options are described below.
- Instance
Id string The ID of the Instance to attach the Volume to.
- Volume
Id string The ID of the Volume to attach to an Instance.
- Device string
See Argument Reference above. NOTE: The correctness of this information is dependent upon the hypervisor in use. In some cases, this should not be used as an authoritative piece of information.
- 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.- Vendor
Options VolumeAttach Vendor Options Args Map of additional vendor-specific options. Supported options are described below.
- instance
Id String The ID of the Instance to attach the Volume to.
- volume
Id String The ID of the Volume to attach to an Instance.
- device String
See Argument Reference above. NOTE: The correctness of this information is dependent upon the hypervisor in use. In some cases, this should not be used as an authoritative piece of information.
- 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.- vendor
Options VolumeAttach Vendor Options Args Map of additional vendor-specific options. Supported options are described below.
- instance
Id string The ID of the Instance to attach the Volume to.
- volume
Id string The ID of the Volume to attach to an Instance.
- device string
See Argument Reference above. NOTE: The correctness of this information is dependent upon the hypervisor in use. In some cases, this should not be used as an authoritative piece of information.
- 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.- vendor
Options VolumeAttach Vendor Options Args 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
See Argument Reference above. NOTE: The correctness of this information is dependent upon the hypervisor in use. In some cases, this should not be used as an authoritative piece of information.
- 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 VolumeAttach Vendor Options Args Map of additional vendor-specific options. Supported options are described below.
- instance
Id String The ID of the Instance to attach the Volume to.
- volume
Id String The ID of the Volume to attach to an Instance.
- device String
See Argument Reference above. NOTE: The correctness of this information is dependent upon the hypervisor in use. In some cases, this should not be used as an authoritative piece of information.
- 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.- vendor
Options 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.
- Device string
See Argument Reference above. NOTE: The correctness of this information is dependent upon the hypervisor in use. In some cases, this should not be used as an authoritative piece of information.
- Instance
Id 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.- Vendor
Options Pulumi.Open Stack. Compute. Inputs. Volume Attach Vendor Options Args Map of additional vendor-specific options. Supported options are described below.
- Volume
Id string The ID of the Volume to attach to an Instance.
- Device string
See Argument Reference above. NOTE: The correctness of this information is dependent upon the hypervisor in use. In some cases, this should not be used as an authoritative piece of information.
- Instance
Id 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.- Vendor
Options VolumeAttach Vendor Options Args Map of additional vendor-specific options. Supported options are described below.
- Volume
Id string The ID of the Volume to attach to an Instance.
- device String
See Argument Reference above. NOTE: The correctness of this information is dependent upon the hypervisor in use. In some cases, this should not be used as an authoritative piece of information.
- instance
Id 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.- vendor
Options VolumeAttach Vendor Options Args Map of additional vendor-specific options. Supported options are described below.
- volume
Id String The ID of the Volume to attach to an Instance.
- device string
See Argument Reference above. NOTE: The correctness of this information is dependent upon the hypervisor in use. In some cases, this should not be used as an authoritative piece of information.
- instance
Id 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.- vendor
Options VolumeAttach Vendor Options Args Map of additional vendor-specific options. Supported options are described below.
- volume
Id string The ID of the Volume to attach to an Instance.
- device str
See Argument Reference above. NOTE: The correctness of this information is dependent upon the hypervisor in use. In some cases, this should not be used as an authoritative piece of information.
- 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 VolumeAttach Vendor Options Args 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
See Argument Reference above. NOTE: The correctness of this information is dependent upon the hypervisor in use. In some cases, this should not be used as an authoritative piece of information.
- instance
Id 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.- vendor
Options Property Map Map of additional vendor-specific options. Supported options are described below.
- volume
Id String The ID of the Volume to attach to an Instance.
Supporting Types
VolumeAttachVendorOptions
- Ignore
Volume boolConfirmation 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 boolConfirmation 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 BooleanConfirmation 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 booleanConfirmation 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_ boolconfirmation 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 BooleanConfirmation 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.