ALIYUN::ECS::DiskAttachment用于挂载ECS磁盘。

语法

{
  "Type": "ALIYUN::ECS::DiskAttachment",
  "Properties": {
    "InstanceId": String,
    "Device": String,
    "DeleteWithInstance": Boolean,
    "DiskId": String,
    "DeleteAutoSnapshot": Boolean
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
InstanceId String 需挂载磁盘的实例ID
DiskId String 磁盘ID 磁盘和ECS实例必须在同一个可用区。
Device String 磁盘设备名 如不指定,则默认由系统按顺序分配,即从 /dev/xvdb 到 /dev/xvdz。
DeleteWithInstance Boolean 磁盘是否随实例释放 取值:
  • true:释放实例时,该磁盘随实例一起释放。
  • false:释放实例时,保留该磁盘,不随实例一起释放。
DeleteAutoSnapshot Boolean 删除磁盘时是否删除自动快照 取值:
  • true(默认值)
  • false

返回值

Fn::GetAtt

  • DiskId:新建磁盘的ID。
  • Status:新建磁盘的状态。
  • Device:磁盘设备名。

示例

  • YAML格式

    ROSTemplateFormatVersion: '2015-09-01'
    Parameters:
      InstanceId:
        Type: String
        AssociationProperty: ALIYUN::ECS::Instance::InstanceId
      DiskId:
        Type: String
        AssociationProperty: ALIYUN::ECS::Disk::DiskId
    Resources:
      DiskAttachment:
        Type: ALIYUN::ECS::DiskAttachment
        Properties:
          InstanceId:
            Ref: InstanceId
          Device: /dev/xvda
          DiskId:
            Ref: DiskId
    Outputs:
      Status:
        Description: The disk status now.
        Value:
          Fn::GetAtt:
            - DiskAttachment
            - Status
      Device:
        Description: The device where the volume is exposed on ecs instance.
        Value:
          Fn::GetAtt:
            - DiskAttachment
            - Device
      DiskId:
        Description: The disk id of created disk
        Value:
          Fn::GetAtt:
            - DiskAttachment
            - DiskId                   
  • JSON格式

    {
      "ROSTemplateFormatVersion": "2015-09-01",
      "Parameters": {
        "InstanceId": {
          "Type": "String",
          "AssociationProperty": "ALIYUN::ECS::Instance::InstanceId"
        },
        "DiskId": {
          "Type": "String",
          "AssociationProperty": "ALIYUN::ECS::Disk::DiskId"
        }
      },
      "Resources": {
        "DiskAttachment": {
          "Type": "ALIYUN::ECS::DiskAttachment",
          "Properties": {
            "InstanceId": {
              "Ref": "InstanceId"
            },
            "Device": "/dev/xvda",
            "DiskId": {
              "Ref": "DiskId"
            }
          }
        }
      },
      "Outputs": {
        "Status": {
          "Description": "The disk status now.",
          "Value": {
            "Fn::GetAtt": [
              "DiskAttachment",
              "Status"
            ]
          }
        },
        "Device": {
          "Description": "The device where the volume is exposed on ecs instance.",
          "Value": {
            "Fn::GetAtt": [
              "DiskAttachment",
              "Device"
            ]
          }
        },
        "DiskId": {
          "Description": "The disk id of created disk",
          "Value": {
            "Fn::GetAtt": [
              "DiskAttachment",
              "DiskId"
            ]
          }
        }
      }
    }