1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. ecs
  5. DiskAttachment
Alibaba Cloud v3.50.0 published on Wednesday, Mar 6, 2024 by Pulumi

alicloud.ecs.DiskAttachment

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.50.0 published on Wednesday, Mar 6, 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

    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.Disk("ecsDisk", new()
        {
            AvailabilityZone = "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.DiskAttachment("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 {
    		// Create a new ECS disk-attachment and use it attach one disk to a new instance.
    		ecsSg, err := ecs.NewSecurityGroup(ctx, "ecsSg", &ecs.SecurityGroupArgs{
    			Description: pulumi.String("New security group"),
    		})
    		if err != nil {
    			return err
    		}
    		ecsDisk, err := ecs.NewDisk(ctx, "ecsDisk", &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, "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.NewDiskAttachment(ctx, "ecsDiskAtt", &ecs.DiskAttachmentArgs{
    			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.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) {
            var ecsSg = new SecurityGroup("ecsSg", SecurityGroupArgs.builder()        
                .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());
    
        }
    }
    
    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.Disk("ecsDisk",
        availability_zone="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.DiskAttachment("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.Disk("ecsDisk", {
        availabilityZone: "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.DiskAttachment("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:Disk
        properties:
          availabilityZone: 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:DiskAttachment
        properties:
          diskId: ${ecsDisk.id}
          instanceId: ${ecsInstance.id}
    

    Create DiskAttachment Resource

    new DiskAttachment(name: string, args: DiskAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def DiskAttachment(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 DiskAttachment(resource_name: str,
                       args: DiskAttachmentArgs,
                       opts: Optional[ResourceOptions] = 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.
    
    
    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.

    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
    

    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.50.0 published on Wednesday, Mar 6, 2024 by Pulumi