1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. ecs
  5. DiskAttachment
Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi

alicloud.ecs.DiskAttachment

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi

    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.Map{
    				"Name": pulumi.Any("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:

    DiskId string
    ID of the Disk to be attached.
    InstanceId string
    ID of the Instance to attach to.
    Bootable bool
    DeleteWithInstance bool
    KeyPairName string
    Password string
    DiskId string
    ID of the Disk to be attached.
    InstanceId string
    ID of the Instance to attach to.
    Bootable bool
    DeleteWithInstance bool
    KeyPairName string
    Password string
    diskId String
    ID of the Disk to be attached.
    instanceId String
    ID of the Instance to attach to.
    bootable Boolean
    deleteWithInstance Boolean
    keyPairName String
    password String
    diskId string
    ID of the Disk to be attached.
    instanceId string
    ID of the Instance to attach to.
    bootable boolean
    deleteWithInstance boolean
    keyPairName string
    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_instance bool
    key_pair_name str
    password str
    diskId String
    ID of the Disk to be attached.
    instanceId String
    ID of the Instance to attach to.
    bootable Boolean
    deleteWithInstance Boolean
    keyPairName String
    password String

    Outputs

    All input properties are implicitly available as output properties. Additionally, the DiskAttachment resource produces the following output properties:

    Device string
    Id string
    The provider-assigned unique ID for this managed resource.
    Device string
    Id string
    The provider-assigned unique ID for this managed resource.
    device String
    id String
    The provider-assigned unique ID for this managed resource.
    device string
    id string
    The provider-assigned unique ID for this managed resource.
    device str
    id str
    The provider-assigned unique ID for this managed resource.
    device String
    id String
    The provider-assigned unique ID for this managed resource.

    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.
    The following state arguments are supported:
    Bootable bool
    DeleteWithInstance bool
    Device string
    DiskId string
    ID of the Disk to be attached.
    InstanceId string
    ID of the Instance to attach to.
    KeyPairName string
    Password string
    Bootable bool
    DeleteWithInstance bool
    Device string
    DiskId string
    ID of the Disk to be attached.
    InstanceId string
    ID of the Instance to attach to.
    KeyPairName string
    Password string
    bootable Boolean
    deleteWithInstance Boolean
    device String
    diskId String
    ID of the Disk to be attached.
    instanceId String
    ID of the Instance to attach to.
    keyPairName String
    password String
    bootable boolean
    deleteWithInstance boolean
    device string
    diskId string
    ID of the Disk to be attached.
    instanceId string
    ID of the Instance to attach to.
    keyPairName string
    password string
    bootable bool
    delete_with_instance bool
    device str
    disk_id str
    ID of the Disk to be attached.
    instance_id str
    ID of the Instance to attach to.
    key_pair_name str
    password str
    bootable Boolean
    deleteWithInstance Boolean
    device String
    diskId String
    ID of the Disk to be attached.
    instanceId String
    ID of the Instance to attach to.
    keyPairName String
    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.
    alicloud logo
    Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi