alicloud.ecs.DiskAttachment
Explore with Pulumi AI
DEPRECATED: This resource has been renamed to alicloud.ecs.EcsDiskAttachment from version 1.122.0.
Provides an Alicloud ECS Disk Attachment as a resource, to attach and detach disks from ECS Instances.
Example Usage
Basic usage
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("ecs_sg", {
name: "terraform-test-group",
description: "New security group",
});
const ecsDisk = new alicloud.ecs.Disk("ecs_disk", {
availabilityZone: "cn-beijing-a",
size: 50,
tags: {
Name: "TerraformTest-disk",
},
});
const ecsInstance = new alicloud.ecs.Instance("ecs_instance", {
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.DiskAttachment("ecs_disk_att", {
diskId: ecsDisk.id,
instanceId: ecsInstance.id,
});
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("ecs_sg",
name="terraform-test-group",
description="New security group")
ecs_disk = alicloud.ecs.Disk("ecs_disk",
availability_zone="cn-beijing-a",
size=50,
tags={
"Name": "TerraformTest-disk",
})
ecs_instance = alicloud.ecs.Instance("ecs_instance",
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.DiskAttachment("ecs_disk_att",
disk_id=ecs_disk.id,
instance_id=ecs_instance.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 {
// Create a new ECS disk-attachment and use it attach one disk to a new instance.
ecsSg, err := ecs.NewSecurityGroup(ctx, "ecs_sg", &ecs.SecurityGroupArgs{
Name: pulumi.String("terraform-test-group"),
Description: pulumi.String("New security group"),
})
if err != nil {
return err
}
ecsDisk, err := ecs.NewDisk(ctx, "ecs_disk", &ecs.DiskArgs{
AvailabilityZone: pulumi.String("cn-beijing-a"),
Size: pulumi.Int(50),
Tags: pulumi.StringMap{
"Name": pulumi.String("TerraformTest-disk"),
},
})
if err != nil {
return err
}
ecsInstance, err := ecs.NewInstance(ctx, "ecs_instance", &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.NewDiskAttachment(ctx, "ecs_disk_att", &ecs.DiskAttachmentArgs{
DiskId: ecsDisk.ID(),
InstanceId: ecsInstance.ID(),
})
if err != nil {
return err
}
return nil
})
}
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("ecs_sg", new()
{
Name = "terraform-test-group",
Description = "New security group",
});
var ecsDisk = new AliCloud.Ecs.Disk("ecs_disk", new()
{
AvailabilityZone = "cn-beijing-a",
Size = 50,
Tags =
{
{ "Name", "TerraformTest-disk" },
},
});
var ecsInstance = new AliCloud.Ecs.Instance("ecs_instance", 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.DiskAttachment("ecs_disk_att", new()
{
DiskId = ecsDisk.Id,
InstanceId = ecsInstance.Id,
});
});
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.Disk;
import com.pulumi.alicloud.ecs.DiskArgs;
import com.pulumi.alicloud.ecs.Instance;
import com.pulumi.alicloud.ecs.InstanceArgs;
import com.pulumi.alicloud.ecs.DiskAttachment;
import com.pulumi.alicloud.ecs.DiskAttachmentArgs;
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) {
// Create a new ECS disk-attachment and use it attach one disk to a new instance.
var ecsSg = new SecurityGroup("ecsSg", SecurityGroupArgs.builder()
.name("terraform-test-group")
.description("New security group")
.build());
var ecsDisk = new Disk("ecsDisk", DiskArgs.builder()
.availabilityZone("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 DiskAttachment("ecsDiskAtt", DiskAttachmentArgs.builder()
.diskId(ecsDisk.id())
.instanceId(ecsInstance.id())
.build());
}
}
resources:
# Create a new ECS disk-attachment and use it attach one disk to a new instance.
ecsSg:
type: alicloud:ecs:SecurityGroup
name: ecs_sg
properties:
name: terraform-test-group
description: New security group
ecsDisk:
type: alicloud:ecs:Disk
name: ecs_disk
properties:
availabilityZone: cn-beijing-a
size: '50'
tags:
Name: TerraformTest-disk
ecsInstance:
type: alicloud:ecs:Instance
name: 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:DiskAttachment
name: ecs_disk_att
properties:
diskId: ${ecsDisk.id}
instanceId: ${ecsInstance.id}
Create DiskAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new DiskAttachment(name: string, args: DiskAttachmentArgs, opts?: CustomResourceOptions);
@overload
def DiskAttachment(resource_name: str,
args: DiskAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def DiskAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
disk_id: Optional[str] = None,
instance_id: Optional[str] = None,
bootable: Optional[bool] = None,
delete_with_instance: Optional[bool] = None,
key_pair_name: Optional[str] = None,
password: Optional[str] = None)
func NewDiskAttachment(ctx *Context, name string, args DiskAttachmentArgs, opts ...ResourceOption) (*DiskAttachment, error)
public DiskAttachment(string name, DiskAttachmentArgs args, CustomResourceOptions? opts = null)
public DiskAttachment(String name, DiskAttachmentArgs args)
public DiskAttachment(String name, DiskAttachmentArgs args, CustomResourceOptions options)
type: alicloud:ecs:DiskAttachment
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 DiskAttachmentArgs
- 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 DiskAttachmentArgs
- 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 DiskAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args DiskAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args DiskAttachmentArgs
- 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 diskAttachmentResource = new AliCloud.Ecs.DiskAttachment("diskAttachmentResource", new()
{
DiskId = "string",
InstanceId = "string",
Bootable = false,
DeleteWithInstance = false,
KeyPairName = "string",
Password = "string",
});
example, err := ecs.NewDiskAttachment(ctx, "diskAttachmentResource", &ecs.DiskAttachmentArgs{
DiskId: pulumi.String("string"),
InstanceId: pulumi.String("string"),
Bootable: pulumi.Bool(false),
DeleteWithInstance: pulumi.Bool(false),
KeyPairName: pulumi.String("string"),
Password: pulumi.String("string"),
})
var diskAttachmentResource = new DiskAttachment("diskAttachmentResource", DiskAttachmentArgs.builder()
.diskId("string")
.instanceId("string")
.bootable(false)
.deleteWithInstance(false)
.keyPairName("string")
.password("string")
.build());
disk_attachment_resource = alicloud.ecs.DiskAttachment("diskAttachmentResource",
disk_id="string",
instance_id="string",
bootable=False,
delete_with_instance=False,
key_pair_name="string",
password="string")
const diskAttachmentResource = new alicloud.ecs.DiskAttachment("diskAttachmentResource", {
diskId: "string",
instanceId: "string",
bootable: false,
deleteWithInstance: false,
keyPairName: "string",
password: "string",
});
type: alicloud:ecs:DiskAttachment
properties:
bootable: false
deleteWithInstance: false
diskId: string
instanceId: string
keyPairName: string
password: string
DiskAttachment 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 DiskAttachment 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
- Delete
With boolInstance - Key
Pair stringName - Password string
- Disk
Id string - ID of the Disk to be attached.
- Instance
Id string - ID of the Instance to attach to.
- Bootable bool
- Delete
With boolInstance - Key
Pair stringName - Password string
- disk
Id String - ID of the Disk to be attached.
- instance
Id String - ID of the Instance to attach to.
- bootable Boolean
- delete
With BooleanInstance - key
Pair StringName - password String
- disk
Id string - ID of the Disk to be attached.
- instance
Id string - ID of the Instance to attach to.
- bootable boolean
- delete
With booleanInstance - key
Pair stringName - password string
- disk_
id str - ID of the Disk to be attached.
- instance_
id str - ID of the Instance to attach to.
- bootable bool
- delete_
with_ boolinstance - key_
pair_ strname - password str
- disk
Id String - ID of the Disk to be attached.
- instance
Id String - ID of the Instance to attach to.
- bootable Boolean
- delete
With BooleanInstance - key
Pair StringName - password String
Outputs
All input properties are implicitly available as output properties. Additionally, the DiskAttachment resource produces the following output properties:
Look up Existing DiskAttachment Resource
Get an existing DiskAttachment 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?: DiskAttachmentState, opts?: CustomResourceOptions): DiskAttachment
@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) -> DiskAttachment
func GetDiskAttachment(ctx *Context, name string, id IDInput, state *DiskAttachmentState, opts ...ResourceOption) (*DiskAttachment, error)
public static DiskAttachment Get(string name, Input<string> id, DiskAttachmentState? state, CustomResourceOptions? opts = null)
public static DiskAttachment get(String name, Output<String> id, DiskAttachmentState 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
- Delete
With boolInstance - 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 - Password string
- Bootable bool
- Delete
With boolInstance - 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 - Password string
- bootable Boolean
- delete
With BooleanInstance - 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 - password String
- bootable boolean
- delete
With booleanInstance - 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 - password string
- bootable bool
- delete_
with_ boolinstance - 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 - password str
- bootable Boolean
- delete
With BooleanInstance - 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 - password String
Import
The disk attachment can be imported using the id, e.g.
$ pulumi import alicloud:ecs/diskAttachment:DiskAttachment example d-abc12345678:i-abc12355
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.