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,
});
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"])
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
})
}
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,
});
});
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());
}
}
resources:
data:
type: vkcs:ComputeVolumeAttach
properties:
instanceId: ${vkcs_compute_instance.basic.id}
volumeId: ${vkcs_blockstorage_volume.data.id}
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],
});
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]))
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
})
}
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,
},
});
});
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());
}
}
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}
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 string
- The unique name of the resource.
- args ComputeVolumeAttachArgs
- 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 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 string
- The unique name of the resource.
- args ComputeVolumeAttachArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args ComputeVolumeAttachArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args 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",
},
});
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"),
},
})
var computeVolumeAttachResource = new ComputeVolumeAttach("computeVolumeAttachResource", ComputeVolumeAttachArgs.builder()
.instanceId("string")
.volumeId("string")
.computeVolumeAttachId("string")
.region("string")
.timeouts(ComputeVolumeAttachTimeoutsArgs.builder()
.create("string")
.delete("string")
.build())
.build());
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",
})
const computeVolumeAttachResource = new vkcs.ComputeVolumeAttach("computeVolumeAttachResource", {
instanceId: "string",
volumeId: "string",
computeVolumeAttachId: "string",
region: "string",
timeouts: {
create: "string",
"delete": "string",
},
});
type: vkcs:ComputeVolumeAttach
properties:
computeVolumeAttachId: string
instanceId: string
region: string
timeouts:
create: string
delete: string
volumeId: string
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:
- Instance
Id string - required string → The ID of the Instance to attach the Volume to.
- Volume
Id string - required string → The ID of the Volume to attach to an Instance.
- Compute
Volume stringAttach Id - 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
Compute
Volume Attach Timeouts
- Instance
Id string - required string → The ID of the Instance to attach the Volume to.
- Volume
Id string - required string → The ID of the Volume to attach to an Instance.
- Compute
Volume stringAttach Id - 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
Compute
Volume Attach Timeouts Args
- instance
Id String - required string → The ID of the Instance to attach the Volume to.
- volume
Id String - required string → The ID of the Volume to attach to an Instance.
- compute
Volume StringAttach Id - 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
Compute
Volume Attach Timeouts
- instance
Id string - required string → The ID of the Instance to attach the Volume to.
- volume
Id string - required string → The ID of the Volume to attach to an Instance.
- compute
Volume stringAttach Id - 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
Compute
Volume Attach Timeouts
- instance_
id str - required string → The ID of the Instance to attach the Volume to.
- volume_
id str - required string → The ID of the Volume to attach to an Instance.
- compute_
volume_ strattach_ id - 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
Compute
Volume Attach Timeouts Args
- instance
Id String - required string → The ID of the Instance to attach the Volume to.
- volume
Id String - required string → The ID of the Volume to attach to an Instance.
- compute
Volume StringAttach Id - 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
- 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.
- Compute
Volume stringAttach Id - string → ID of the resource.
- Instance
Id 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
Compute
Volume Attach Timeouts - Volume
Id string - required string → The ID of the Volume to attach to an Instance.
- Compute
Volume stringAttach Id - string → ID of the resource.
- Instance
Id 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
Compute
Volume Attach Timeouts Args - Volume
Id string - required string → The ID of the Volume to attach to an Instance.
- compute
Volume StringAttach Id - string → ID of the resource.
- instance
Id 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
Compute
Volume Attach Timeouts - volume
Id String - required string → The ID of the Volume to attach to an Instance.
- compute
Volume stringAttach Id - string → ID of the resource.
- instance
Id 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
Compute
Volume Attach Timeouts - volume
Id string - required string → The ID of the Volume to attach to an Instance.
- compute_
volume_ strattach_ id - 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
Compute
Volume Attach Timeouts Args - volume_
id str - required string → The ID of the Volume to attach to an Instance.
- compute
Volume StringAttach Id - string → ID of the resource.
- instance
Id 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
- volume
Id String - required string → The ID of the Volume to attach to an Instance.
Supporting Types
ComputeVolumeAttachTimeouts, ComputeVolumeAttachTimeoutsArgs
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
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.