1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. ecs
  5. EcsDiskAttachment
Alibaba Cloud v3.45.1 published on Thursday, Dec 7, 2023 by Pulumi

alicloud.ecs.EcsDiskAttachment

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.45.1 published on Thursday, Dec 7, 2023 by Pulumi

    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.Map{
    				"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:

    DiskId string

    ID of the Disk to be attached.

    InstanceId string

    ID of the Instance to attach to.

    Bootable bool

    Whether to mount as a system disk. Default to: false.

    DeleteWithInstance bool

    Indicates whether the disk is released together with the instance. Default to: false.

    KeyPairName string

    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.

    DiskId string

    ID of the Disk to be attached.

    InstanceId string

    ID of the Instance to attach to.

    Bootable bool

    Whether to mount as a system disk. Default to: false.

    DeleteWithInstance bool

    Indicates whether the disk is released together with the instance. Default to: false.

    KeyPairName string

    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.

    diskId String

    ID of the Disk to be attached.

    instanceId String

    ID of the Instance to attach to.

    bootable Boolean

    Whether to mount as a system disk. Default to: false.

    deleteWithInstance Boolean

    Indicates whether the disk is released together with the instance. Default to: false.

    keyPairName String

    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.

    diskId string

    ID of the Disk to be attached.

    instanceId string

    ID of the Instance to attach to.

    bootable boolean

    Whether to mount as a system disk. Default to: false.

    deleteWithInstance boolean

    Indicates whether the disk is released together with the instance. Default to: false.

    keyPairName string

    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_instance bool

    Indicates whether the disk is released together with the instance. Default to: false.

    key_pair_name str

    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.

    diskId String

    ID of the Disk to be attached.

    instanceId String

    ID of the Instance to attach to.

    bootable Boolean

    Whether to mount as a system disk. Default to: false.

    deleteWithInstance Boolean

    Indicates whether the disk is released together with the instance. Default to: false.

    keyPairName String

    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:

    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 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.
    The following state arguments are supported:
    Bootable bool

    Whether to mount as a system disk. Default to: false.

    DeleteWithInstance bool

    Indicates whether the disk is released together with the instance. Default to: false.

    Device string
    DiskId string

    ID of the Disk to be attached.

    InstanceId string

    ID of the Instance to attach to.

    KeyPairName string

    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.

    DeleteWithInstance bool

    Indicates whether the disk is released together with the instance. Default to: false.

    Device string
    DiskId string

    ID of the Disk to be attached.

    InstanceId string

    ID of the Instance to attach to.

    KeyPairName string

    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.

    deleteWithInstance Boolean

    Indicates whether the disk is released together with the instance. Default to: false.

    device String
    diskId String

    ID of the Disk to be attached.

    instanceId String

    ID of the Instance to attach to.

    keyPairName String

    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.

    deleteWithInstance boolean

    Indicates whether the disk is released together with the instance. Default to: false.

    device string
    diskId string

    ID of the Disk to be attached.

    instanceId string

    ID of the Instance to attach to.

    keyPairName string

    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_instance bool

    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_name str

    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.

    deleteWithInstance Boolean

    Indicates whether the disk is released together with the instance. Default to: false.

    device String
    diskId String

    ID of the Disk to be attached.

    instanceId String

    ID of the Instance to attach to.

    keyPairName String

    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.

    alicloud logo
    Alibaba Cloud v3.45.1 published on Thursday, Dec 7, 2023 by Pulumi