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"
            ]
          }
        }
      }
    }