1. Packages
  2. Vkcs Provider
  3. API Docs
  4. ComputeVolumeAttach
vkcs 0.9.3 published on Tuesday, Apr 15, 2025 by vk-cs

vkcs.ComputeVolumeAttach

Explore with Pulumi AI

Attaches a Block Storage Volume to an Instance using the VKCS Compute API.

Examples

Usage with one volume

import * as pulumi from "@pulumi/pulumi";
import * as vkcs from "@pulumi/vkcs";

const data = new vkcs.ComputeVolumeAttach("data", {
    instanceId: vkcs_compute_instance.basic.id,
    volumeId: vkcs_blockstorage_volume.data.id,
});
Copy
import pulumi
import pulumi_vkcs as vkcs

data = vkcs.ComputeVolumeAttach("data",
    instance_id=vkcs_compute_instance["basic"]["id"],
    volume_id=vkcs_blockstorage_volume["data"]["id"])
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/vkcs/vkcs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := vkcs.NewComputeVolumeAttach(ctx, "data", &vkcs.ComputeVolumeAttachArgs{
			InstanceId: pulumi.Any(vkcs_compute_instance.Basic.Id),
			VolumeId:   pulumi.Any(vkcs_blockstorage_volume.Data.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Vkcs = Pulumi.Vkcs;

return await Deployment.RunAsync(() => 
{
    var data = new Vkcs.ComputeVolumeAttach("data", new()
    {
        InstanceId = vkcs_compute_instance.Basic.Id,
        VolumeId = vkcs_blockstorage_volume.Data.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vkcs.ComputeVolumeAttach;
import com.pulumi.vkcs.ComputeVolumeAttachArgs;
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 data = new ComputeVolumeAttach("data", ComputeVolumeAttachArgs.builder()
            .instanceId(vkcs_compute_instance.basic().id())
            .volumeId(vkcs_blockstorage_volume.data().id())
            .build());

    }
}
Copy
resources:
  data:
    type: vkcs:ComputeVolumeAttach
    properties:
      instanceId: ${vkcs_compute_instance.basic.id}
      volumeId: ${vkcs_blockstorage_volume.data.id}
Copy

Usage with ORDERED multiple volumes

Attaching multiple volumes will not guarantee that the volumes are attached in a deterministic manner. The volumes will be attached in a seemingly random order.

If you want to ensure that the volumes are attached in a given order, create explicit dependencies between the volumes, such as:

import * as pulumi from "@pulumi/pulumi";
import * as vkcs from "@pulumi/vkcs";

const attach1 = new vkcs.ComputeVolumeAttach("attach1", {
    instanceId: vkcs_compute_instance.basic.id,
    volumeId: vkcs_blockstorage_volume.volumes[0].id,
});
const attach2 = new vkcs.ComputeVolumeAttach("attach2", {
    instanceId: vkcs_compute_instance.basic.id,
    volumeId: vkcs_blockstorage_volume.volumes[1].id,
}, {
    dependsOn: [attach1],
});
Copy
import pulumi
import pulumi_vkcs as vkcs

attach1 = vkcs.ComputeVolumeAttach("attach1",
    instance_id=vkcs_compute_instance["basic"]["id"],
    volume_id=vkcs_blockstorage_volume["volumes"][0]["id"])
attach2 = vkcs.ComputeVolumeAttach("attach2",
    instance_id=vkcs_compute_instance["basic"]["id"],
    volume_id=vkcs_blockstorage_volume["volumes"][1]["id"],
    opts = pulumi.ResourceOptions(depends_on=[attach1]))
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/vkcs/vkcs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		attach1, err := vkcs.NewComputeVolumeAttach(ctx, "attach1", &vkcs.ComputeVolumeAttachArgs{
			InstanceId: pulumi.Any(vkcs_compute_instance.Basic.Id),
			VolumeId:   pulumi.Any(vkcs_blockstorage_volume.Volumes[0].Id),
		})
		if err != nil {
			return err
		}
		_, err = vkcs.NewComputeVolumeAttach(ctx, "attach2", &vkcs.ComputeVolumeAttachArgs{
			InstanceId: pulumi.Any(vkcs_compute_instance.Basic.Id),
			VolumeId:   pulumi.Any(vkcs_blockstorage_volume.Volumes[1].Id),
		}, pulumi.DependsOn([]pulumi.Resource{
			attach1,
		}))
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Vkcs = Pulumi.Vkcs;

return await Deployment.RunAsync(() => 
{
    var attach1 = new Vkcs.ComputeVolumeAttach("attach1", new()
    {
        InstanceId = vkcs_compute_instance.Basic.Id,
        VolumeId = vkcs_blockstorage_volume.Volumes[0].Id,
    });

    var attach2 = new Vkcs.ComputeVolumeAttach("attach2", new()
    {
        InstanceId = vkcs_compute_instance.Basic.Id,
        VolumeId = vkcs_blockstorage_volume.Volumes[1].Id,
    }, new CustomResourceOptions
    {
        DependsOn =
        {
            attach1,
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.vkcs.ComputeVolumeAttach;
import com.pulumi.vkcs.ComputeVolumeAttachArgs;
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 attach1 = new ComputeVolumeAttach("attach1", ComputeVolumeAttachArgs.builder()
            .instanceId(vkcs_compute_instance.basic().id())
            .volumeId(vkcs_blockstorage_volume.volumes()[0].id())
            .build());

        var attach2 = new ComputeVolumeAttach("attach2", ComputeVolumeAttachArgs.builder()
            .instanceId(vkcs_compute_instance.basic().id())
            .volumeId(vkcs_blockstorage_volume.volumes()[1].id())
            .build(), CustomResourceOptions.builder()
                .dependsOn(attach1)
                .build());

    }
}
Copy
resources:
  attach1:
    type: vkcs:ComputeVolumeAttach
    properties:
      instanceId: ${vkcs_compute_instance.basic.id}
      volumeId: ${vkcs_blockstorage_volume.volumes[0].id}
  attach2:
    type: vkcs:ComputeVolumeAttach
    properties:
      instanceId: ${vkcs_compute_instance.basic.id}
      volumeId: ${vkcs_blockstorage_volume.volumes[1].id}
    options:
      dependsOn:
        - ${attach1}
Copy

Create ComputeVolumeAttach Resource

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

Constructor syntax

new ComputeVolumeAttach(name: string, args: ComputeVolumeAttachArgs, opts?: CustomResourceOptions);
@overload
def ComputeVolumeAttach(resource_name: str,
                        args: ComputeVolumeAttachArgs,
                        opts: Optional[ResourceOptions] = None)

@overload
def ComputeVolumeAttach(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        instance_id: Optional[str] = None,
                        volume_id: Optional[str] = None,
                        compute_volume_attach_id: Optional[str] = None,
                        region: Optional[str] = None,
                        timeouts: Optional[ComputeVolumeAttachTimeoutsArgs] = None)
func NewComputeVolumeAttach(ctx *Context, name string, args ComputeVolumeAttachArgs, opts ...ResourceOption) (*ComputeVolumeAttach, error)
public ComputeVolumeAttach(string name, ComputeVolumeAttachArgs args, CustomResourceOptions? opts = null)
public ComputeVolumeAttach(String name, ComputeVolumeAttachArgs args)
public ComputeVolumeAttach(String name, ComputeVolumeAttachArgs args, CustomResourceOptions options)
type: vkcs:ComputeVolumeAttach
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ComputeVolumeAttachArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ComputeVolumeAttachArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ComputeVolumeAttachArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ComputeVolumeAttachArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ComputeVolumeAttachArgs
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 computeVolumeAttachResource = new Vkcs.ComputeVolumeAttach("computeVolumeAttachResource", new()
{
    InstanceId = "string",
    VolumeId = "string",
    ComputeVolumeAttachId = "string",
    Region = "string",
    Timeouts = new Vkcs.Inputs.ComputeVolumeAttachTimeoutsArgs
    {
        Create = "string",
        Delete = "string",
    },
});
Copy
example, err := vkcs.NewComputeVolumeAttach(ctx, "computeVolumeAttachResource", &vkcs.ComputeVolumeAttachArgs{
	InstanceId:            pulumi.String("string"),
	VolumeId:              pulumi.String("string"),
	ComputeVolumeAttachId: pulumi.String("string"),
	Region:                pulumi.String("string"),
	Timeouts: &vkcs.ComputeVolumeAttachTimeoutsArgs{
		Create: pulumi.String("string"),
		Delete: pulumi.String("string"),
	},
})
Copy
var computeVolumeAttachResource = new ComputeVolumeAttach("computeVolumeAttachResource", ComputeVolumeAttachArgs.builder()
    .instanceId("string")
    .volumeId("string")
    .computeVolumeAttachId("string")
    .region("string")
    .timeouts(ComputeVolumeAttachTimeoutsArgs.builder()
        .create("string")
        .delete("string")
        .build())
    .build());
Copy
compute_volume_attach_resource = vkcs.ComputeVolumeAttach("computeVolumeAttachResource",
    instance_id="string",
    volume_id="string",
    compute_volume_attach_id="string",
    region="string",
    timeouts={
        "create": "string",
        "delete": "string",
    })
Copy
const computeVolumeAttachResource = new vkcs.ComputeVolumeAttach("computeVolumeAttachResource", {
    instanceId: "string",
    volumeId: "string",
    computeVolumeAttachId: "string",
    region: "string",
    timeouts: {
        create: "string",
        "delete": "string",
    },
});
Copy
type: vkcs:ComputeVolumeAttach
properties:
    computeVolumeAttachId: string
    instanceId: string
    region: string
    timeouts:
        create: string
        delete: string
    volumeId: string
Copy

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

InstanceId This property is required. string
required string → The ID of the Instance to attach the Volume to.
VolumeId This property is required. string
required string → The ID of the Volume to attach to an Instance.
ComputeVolumeAttachId string
string → ID of the resource.
Region string
optional string → The region in which to obtain the 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.
Timeouts ComputeVolumeAttachTimeouts
InstanceId This property is required. string
required string → The ID of the Instance to attach the Volume to.
VolumeId This property is required. string
required string → The ID of the Volume to attach to an Instance.
ComputeVolumeAttachId string
string → ID of the resource.
Region string
optional string → The region in which to obtain the 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.
Timeouts ComputeVolumeAttachTimeoutsArgs
instanceId This property is required. String
required string → The ID of the Instance to attach the Volume to.
volumeId This property is required. String
required string → The ID of the Volume to attach to an Instance.
computeVolumeAttachId String
string → ID of the resource.
region String
optional string → The region in which to obtain the 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.
timeouts ComputeVolumeAttachTimeouts
instanceId This property is required. string
required string → The ID of the Instance to attach the Volume to.
volumeId This property is required. string
required string → The ID of the Volume to attach to an Instance.
computeVolumeAttachId string
string → ID of the resource.
region string
optional string → The region in which to obtain the 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.
timeouts ComputeVolumeAttachTimeouts
instance_id This property is required. str
required string → The ID of the Instance to attach the Volume to.
volume_id This property is required. str
required string → The ID of the Volume to attach to an Instance.
compute_volume_attach_id str
string → ID of the resource.
region str
optional string → The region in which to obtain the 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.
timeouts ComputeVolumeAttachTimeoutsArgs
instanceId This property is required. String
required string → The ID of the Instance to attach the Volume to.
volumeId This property is required. String
required string → The ID of the Volume to attach to an Instance.
computeVolumeAttachId String
string → ID of the resource.
region String
optional string → The region in which to obtain the 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.
timeouts Property Map

Outputs

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

Get an existing ComputeVolumeAttach 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?: ComputeVolumeAttachState, opts?: CustomResourceOptions): ComputeVolumeAttach
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        compute_volume_attach_id: Optional[str] = None,
        instance_id: Optional[str] = None,
        region: Optional[str] = None,
        timeouts: Optional[ComputeVolumeAttachTimeoutsArgs] = None,
        volume_id: Optional[str] = None) -> ComputeVolumeAttach
func GetComputeVolumeAttach(ctx *Context, name string, id IDInput, state *ComputeVolumeAttachState, opts ...ResourceOption) (*ComputeVolumeAttach, error)
public static ComputeVolumeAttach Get(string name, Input<string> id, ComputeVolumeAttachState? state, CustomResourceOptions? opts = null)
public static ComputeVolumeAttach get(String name, Output<String> id, ComputeVolumeAttachState state, CustomResourceOptions options)
resources:  _:    type: vkcs:ComputeVolumeAttach    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
ComputeVolumeAttachId string
string → ID of the resource.
InstanceId string
required string → The ID of the Instance to attach the Volume to.
Region string
optional string → The region in which to obtain the 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.
Timeouts ComputeVolumeAttachTimeouts
VolumeId string
required string → The ID of the Volume to attach to an Instance.
ComputeVolumeAttachId string
string → ID of the resource.
InstanceId string
required string → The ID of the Instance to attach the Volume to.
Region string
optional string → The region in which to obtain the 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.
Timeouts ComputeVolumeAttachTimeoutsArgs
VolumeId string
required string → The ID of the Volume to attach to an Instance.
computeVolumeAttachId String
string → ID of the resource.
instanceId String
required string → The ID of the Instance to attach the Volume to.
region String
optional string → The region in which to obtain the 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.
timeouts ComputeVolumeAttachTimeouts
volumeId String
required string → The ID of the Volume to attach to an Instance.
computeVolumeAttachId string
string → ID of the resource.
instanceId string
required string → The ID of the Instance to attach the Volume to.
region string
optional string → The region in which to obtain the 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.
timeouts ComputeVolumeAttachTimeouts
volumeId string
required string → The ID of the Volume to attach to an Instance.
compute_volume_attach_id str
string → ID of the resource.
instance_id str
required string → The ID of the Instance to attach the Volume to.
region str
optional string → The region in which to obtain the 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.
timeouts ComputeVolumeAttachTimeoutsArgs
volume_id str
required string → The ID of the Volume to attach to an Instance.
computeVolumeAttachId String
string → ID of the resource.
instanceId String
required string → The ID of the Instance to attach the Volume to.
region String
optional string → The region in which to obtain the 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.
timeouts Property Map
volumeId String
required string → The ID of the Volume to attach to an Instance.

Supporting Types

ComputeVolumeAttachTimeouts
, ComputeVolumeAttachTimeoutsArgs

Create string
Delete string
Create string
Delete string
create String
delete String
create string
delete string
create str
delete str
create String
delete String

Import

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

$ pulumi import vkcs:index/computeVolumeAttach:ComputeVolumeAttach va_1 89c60255-9bd6-460c-822a-e2b959ede9d2/45670584-225f-46c3-b33e-6707b589b666
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
vkcs vk-cs/terraform-provider-vkcs
License
Notes
This Pulumi package is based on the vkcs Terraform Provider.