alicloud.ecs.EcsDiskAttachment
Explore with Pulumi AI
Provides an Alicloud ECS Disk Attachment as a resource, to attach and detach disks from ECS Instances.
For information about ECS Disk Attachment and how to use it, see What is Disk Attachment.
NOTE: Available in v1.122.0+.
Example Usage
Basic usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
// Create a new ECS disk-attachment and use it attach one disk to a new instance.
var ecsSg = new AliCloud.Ecs.SecurityGroup("ecsSg", new()
{
Description = "New security group",
});
var ecsDisk = new AliCloud.Ecs.EcsDisk("ecsDisk", new()
{
ZoneId = "cn-beijing-a",
Size = 50,
Tags =
{
{ "Name", "TerraformTest-disk" },
},
});
var ecsInstance = new AliCloud.Ecs.Instance("ecsInstance", new()
{
ImageId = "ubuntu_18_04_64_20G_alibase_20190624.vhd",
InstanceType = "ecs.n4.small",
AvailabilityZone = "cn-beijing-a",
SecurityGroups = new[]
{
ecsSg.Id,
},
InstanceName = "Hello",
InternetChargeType = "PayByBandwidth",
Tags =
{
{ "Name", "TerraformTest-instance" },
},
});
var ecsDiskAtt = new AliCloud.Ecs.EcsDiskAttachment("ecsDiskAtt", new()
{
DiskId = ecsDisk.Id,
InstanceId = ecsInstance.Id,
});
});
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
ecsSg, err := ecs.NewSecurityGroup(ctx, "ecsSg", &ecs.SecurityGroupArgs{
Description: pulumi.String("New security group"),
})
if err != nil {
return err
}
ecsDisk, err := ecs.NewEcsDisk(ctx, "ecsDisk", &ecs.EcsDiskArgs{
ZoneId: pulumi.String("cn-beijing-a"),
Size: pulumi.Int(50),
Tags: pulumi.AnyMap{
"Name": pulumi.Any("TerraformTest-disk"),
},
})
if err != nil {
return err
}
ecsInstance, err := ecs.NewInstance(ctx, "ecsInstance", &ecs.InstanceArgs{
ImageId: pulumi.String("ubuntu_18_04_64_20G_alibase_20190624.vhd"),
InstanceType: pulumi.String("ecs.n4.small"),
AvailabilityZone: pulumi.String("cn-beijing-a"),
SecurityGroups: pulumi.StringArray{
ecsSg.ID(),
},
InstanceName: pulumi.String("Hello"),
InternetChargeType: pulumi.String("PayByBandwidth"),
Tags: pulumi.StringMap{
"Name": pulumi.String("TerraformTest-instance"),
},
})
if err != nil {
return err
}
_, err = ecs.NewEcsDiskAttachment(ctx, "ecsDiskAtt", &ecs.EcsDiskAttachmentArgs{
DiskId: ecsDisk.ID(),
InstanceId: ecsInstance.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.alicloud.ecs.SecurityGroup;
import com.pulumi.alicloud.ecs.SecurityGroupArgs;
import com.pulumi.alicloud.ecs.EcsDisk;
import com.pulumi.alicloud.ecs.EcsDiskArgs;
import com.pulumi.alicloud.ecs.Instance;
import com.pulumi.alicloud.ecs.InstanceArgs;
import com.pulumi.alicloud.ecs.EcsDiskAttachment;
import com.pulumi.alicloud.ecs.EcsDiskAttachmentArgs;
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 ecsSg = new SecurityGroup("ecsSg", SecurityGroupArgs.builder()
.description("New security group")
.build());
var ecsDisk = new EcsDisk("ecsDisk", EcsDiskArgs.builder()
.zoneId("cn-beijing-a")
.size("50")
.tags(Map.of("Name", "TerraformTest-disk"))
.build());
var ecsInstance = new Instance("ecsInstance", InstanceArgs.builder()
.imageId("ubuntu_18_04_64_20G_alibase_20190624.vhd")
.instanceType("ecs.n4.small")
.availabilityZone("cn-beijing-a")
.securityGroups(ecsSg.id())
.instanceName("Hello")
.internetChargeType("PayByBandwidth")
.tags(Map.of("Name", "TerraformTest-instance"))
.build());
var ecsDiskAtt = new EcsDiskAttachment("ecsDiskAtt", EcsDiskAttachmentArgs.builder()
.diskId(ecsDisk.id())
.instanceId(ecsInstance.id())
.build());
}
}
import pulumi
import pulumi_alicloud as alicloud
# Create a new ECS disk-attachment and use it attach one disk to a new instance.
ecs_sg = alicloud.ecs.SecurityGroup("ecsSg", description="New security group")
ecs_disk = alicloud.ecs.EcsDisk("ecsDisk",
zone_id="cn-beijing-a",
size=50,
tags={
"Name": "TerraformTest-disk",
})
ecs_instance = alicloud.ecs.Instance("ecsInstance",
image_id="ubuntu_18_04_64_20G_alibase_20190624.vhd",
instance_type="ecs.n4.small",
availability_zone="cn-beijing-a",
security_groups=[ecs_sg.id],
instance_name="Hello",
internet_charge_type="PayByBandwidth",
tags={
"Name": "TerraformTest-instance",
})
ecs_disk_att = alicloud.ecs.EcsDiskAttachment("ecsDiskAtt",
disk_id=ecs_disk.id,
instance_id=ecs_instance.id)
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
// Create a new ECS disk-attachment and use it attach one disk to a new instance.
const ecsSg = new alicloud.ecs.SecurityGroup("ecsSg", {description: "New security group"});
const ecsDisk = new alicloud.ecs.EcsDisk("ecsDisk", {
zoneId: "cn-beijing-a",
size: 50,
tags: {
Name: "TerraformTest-disk",
},
});
const ecsInstance = new alicloud.ecs.Instance("ecsInstance", {
imageId: "ubuntu_18_04_64_20G_alibase_20190624.vhd",
instanceType: "ecs.n4.small",
availabilityZone: "cn-beijing-a",
securityGroups: [ecsSg.id],
instanceName: "Hello",
internetChargeType: "PayByBandwidth",
tags: {
Name: "TerraformTest-instance",
},
});
const ecsDiskAtt = new alicloud.ecs.EcsDiskAttachment("ecsDiskAtt", {
diskId: ecsDisk.id,
instanceId: ecsInstance.id,
});
resources:
# Create a new ECS disk-attachment and use it attach one disk to a new instance.
ecsSg:
type: alicloud:ecs:SecurityGroup
properties:
description: New security group
ecsDisk:
type: alicloud:ecs:EcsDisk
properties:
zoneId: cn-beijing-a
size: '50'
tags:
Name: TerraformTest-disk
ecsInstance:
type: alicloud:ecs:Instance
properties:
imageId: ubuntu_18_04_64_20G_alibase_20190624.vhd
instanceType: ecs.n4.small
availabilityZone: cn-beijing-a
securityGroups:
- ${ecsSg.id}
instanceName: Hello
internetChargeType: PayByBandwidth
tags:
Name: TerraformTest-instance
ecsDiskAtt:
type: alicloud:ecs:EcsDiskAttachment
properties:
diskId: ${ecsDisk.id}
instanceId: ${ecsInstance.id}
Create EcsDiskAttachment Resource
new EcsDiskAttachment(name: string, args: EcsDiskAttachmentArgs, opts?: CustomResourceOptions);
@overload
def EcsDiskAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
bootable: Optional[bool] = None,
delete_with_instance: Optional[bool] = None,
disk_id: Optional[str] = None,
instance_id: Optional[str] = None,
key_pair_name: Optional[str] = None,
password: Optional[str] = None)
@overload
def EcsDiskAttachment(resource_name: str,
args: EcsDiskAttachmentArgs,
opts: Optional[ResourceOptions] = None)
func NewEcsDiskAttachment(ctx *Context, name string, args EcsDiskAttachmentArgs, opts ...ResourceOption) (*EcsDiskAttachment, error)
public EcsDiskAttachment(string name, EcsDiskAttachmentArgs args, CustomResourceOptions? opts = null)
public EcsDiskAttachment(String name, EcsDiskAttachmentArgs args)
public EcsDiskAttachment(String name, EcsDiskAttachmentArgs args, CustomResourceOptions options)
type: alicloud:ecs:EcsDiskAttachment
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args EcsDiskAttachmentArgs
- 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 EcsDiskAttachmentArgs
- 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 EcsDiskAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args EcsDiskAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args EcsDiskAttachmentArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
EcsDiskAttachment 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 EcsDiskAttachment resource accepts the following input properties:
- Disk
Id string ID of the Disk to be attached.
- Instance
Id string ID of the Instance to attach to.
- Bootable bool
Whether to mount as a system disk. Default to:
false
.- Delete
With boolInstance Indicates whether the disk is released together with the instance. Default to:
false
.- Key
Pair stringName The name of key pair
- Password string
When mounting the system disk, setting the user name and password of the instance is only effective for the administrator and root user names, and other user names are not effective.
- Disk
Id string ID of the Disk to be attached.
- Instance
Id string ID of the Instance to attach to.
- Bootable bool
Whether to mount as a system disk. Default to:
false
.- Delete
With boolInstance Indicates whether the disk is released together with the instance. Default to:
false
.- Key
Pair stringName The name of key pair
- Password string
When mounting the system disk, setting the user name and password of the instance is only effective for the administrator and root user names, and other user names are not effective.
- disk
Id String ID of the Disk to be attached.
- instance
Id String ID of the Instance to attach to.
- bootable Boolean
Whether to mount as a system disk. Default to:
false
.- delete
With BooleanInstance Indicates whether the disk is released together with the instance. Default to:
false
.- key
Pair StringName The name of key pair
- password String
When mounting the system disk, setting the user name and password of the instance is only effective for the administrator and root user names, and other user names are not effective.
- disk
Id string ID of the Disk to be attached.
- instance
Id string ID of the Instance to attach to.
- bootable boolean
Whether to mount as a system disk. Default to:
false
.- delete
With booleanInstance Indicates whether the disk is released together with the instance. Default to:
false
.- key
Pair stringName The name of key pair
- password string
When mounting the system disk, setting the user name and password of the instance is only effective for the administrator and root user names, and other user names are not effective.
- disk_
id str ID of the Disk to be attached.
- instance_
id str ID of the Instance to attach to.
- bootable bool
Whether to mount as a system disk. Default to:
false
.- delete_
with_ boolinstance Indicates whether the disk is released together with the instance. Default to:
false
.- key_
pair_ strname The name of key pair
- password str
When mounting the system disk, setting the user name and password of the instance is only effective for the administrator and root user names, and other user names are not effective.
- disk
Id String ID of the Disk to be attached.
- instance
Id String ID of the Instance to attach to.
- bootable Boolean
Whether to mount as a system disk. Default to:
false
.- delete
With BooleanInstance Indicates whether the disk is released together with the instance. Default to:
false
.- key
Pair StringName The name of key pair
- password String
When mounting the system disk, setting the user name and password of the instance is only effective for the administrator and root user names, and other user names are not effective.
Outputs
All input properties are implicitly available as output properties. Additionally, the EcsDiskAttachment resource produces the following output properties:
Look up Existing EcsDiskAttachment Resource
Get an existing EcsDiskAttachment 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?: EcsDiskAttachmentState, opts?: CustomResourceOptions): EcsDiskAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
bootable: Optional[bool] = None,
delete_with_instance: Optional[bool] = None,
device: Optional[str] = None,
disk_id: Optional[str] = None,
instance_id: Optional[str] = None,
key_pair_name: Optional[str] = None,
password: Optional[str] = None) -> EcsDiskAttachment
func GetEcsDiskAttachment(ctx *Context, name string, id IDInput, state *EcsDiskAttachmentState, opts ...ResourceOption) (*EcsDiskAttachment, error)
public static EcsDiskAttachment Get(string name, Input<string> id, EcsDiskAttachmentState? state, CustomResourceOptions? opts = null)
public static EcsDiskAttachment get(String name, Output<String> id, EcsDiskAttachmentState 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.
- Bootable bool
Whether to mount as a system disk. Default to:
false
.- Delete
With boolInstance Indicates whether the disk is released together with the instance. Default to:
false
.- Device string
- Disk
Id string ID of the Disk to be attached.
- Instance
Id string ID of the Instance to attach to.
- Key
Pair stringName The name of key pair
- Password string
When mounting the system disk, setting the user name and password of the instance is only effective for the administrator and root user names, and other user names are not effective.
- Bootable bool
Whether to mount as a system disk. Default to:
false
.- Delete
With boolInstance Indicates whether the disk is released together with the instance. Default to:
false
.- Device string
- Disk
Id string ID of the Disk to be attached.
- Instance
Id string ID of the Instance to attach to.
- Key
Pair stringName The name of key pair
- Password string
When mounting the system disk, setting the user name and password of the instance is only effective for the administrator and root user names, and other user names are not effective.
- bootable Boolean
Whether to mount as a system disk. Default to:
false
.- delete
With BooleanInstance Indicates whether the disk is released together with the instance. Default to:
false
.- device String
- disk
Id String ID of the Disk to be attached.
- instance
Id String ID of the Instance to attach to.
- key
Pair StringName The name of key pair
- password String
When mounting the system disk, setting the user name and password of the instance is only effective for the administrator and root user names, and other user names are not effective.
- bootable boolean
Whether to mount as a system disk. Default to:
false
.- delete
With booleanInstance Indicates whether the disk is released together with the instance. Default to:
false
.- device string
- disk
Id string ID of the Disk to be attached.
- instance
Id string ID of the Instance to attach to.
- key
Pair stringName The name of key pair
- password string
When mounting the system disk, setting the user name and password of the instance is only effective for the administrator and root user names, and other user names are not effective.
- bootable bool
Whether to mount as a system disk. Default to:
false
.- delete_
with_ boolinstance Indicates whether the disk is released together with the instance. Default to:
false
.- device str
- disk_
id str ID of the Disk to be attached.
- instance_
id str ID of the Instance to attach to.
- key_
pair_ strname The name of key pair
- password str
When mounting the system disk, setting the user name and password of the instance is only effective for the administrator and root user names, and other user names are not effective.
- bootable Boolean
Whether to mount as a system disk. Default to:
false
.- delete
With BooleanInstance Indicates whether the disk is released together with the instance. Default to:
false
.- device String
- disk
Id String ID of the Disk to be attached.
- instance
Id String ID of the Instance to attach to.
- key
Pair StringName The name of key pair
- password String
When mounting the system disk, setting the user name and password of the instance is only effective for the administrator and root user names, and other user names are not effective.
Import
The disk attachment can be imported using the id, e.g.
$ pulumi import alicloud:ecs/ecsDiskAttachment:EcsDiskAttachment example d-abc12345678:i-abc12355
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
alicloud
Terraform Provider.