【问题标题】:Mounting multiple BlockDeviceMappings to an EC2 instance using Cloudformation使用 Cloudformation 将多个 BlockDeviceMappings 挂载到 EC2 实例
【发布时间】:2018-07-20 16:44:18
【问题描述】:

我正在尝试使用 cloudformation 将多个 EBS 卷挂载到我的 EC2 实例,但由于某种原因,只有我指定的最后一个 EBS 卷被挂载。

EG:
NewEC2Instance:
    Type: AWS::EC2::Instance
    DependsOn: OldSecurityGroup
    Properties:
      ImageId: !Ref pImageId
      InstanceType: !Ref pInstanceType
      BlockDeviceMappings:
        -
          DeviceName: /dev/sda1
          Ebs:
            VolumeSize: 10
          DeviceName: /dev/sdf
          Ebs:
            VolumeSize: 11
            Encrypted: true
          DeviceName: /dev/sdg
          Ebs:
            VolumeSize: 12
            Encrypted: true 
          DeviceName: /dev/sdh
          Ebs:
            VolumeSize: 100
            Encrypted: true 

对于上述代码,只创建了 100Gb /dev/sdh。

我认为 Cloudformation 正在覆盖 EBS 卷。

有人知道为什么吗?请帮忙!

【问题讨论】:

  • 请粘贴到记事本中查看代码

标签: amazon-web-services amazon-ec2 amazon-cloudformation amazon-ebs


【解决方案1】:

您错过了每个设备名称前面的-。像这样:

  BlockDeviceMappings:
  - DeviceName: "/dev/xvda"
    Ebs:
      VolumeSize: 16
      VolumeType: gp2
  - DeviceName: "/dev/xvdf"
    Ebs:
      VolumeSize: 12
      VolumeType: gp2

只有一个-,您实际上是在定义一个数组,其中包含一个带有冲突键的元素,yaml 的默认行为是使用它在对象中找到的最后一个键。

【讨论】:

    猜你喜欢
    • 2017-04-25
    • 2013-03-01
    • 2022-11-10
    • 2012-03-10
    • 1970-01-01
    • 1970-01-01
    • 2019-06-22
    • 2019-01-01
    • 2017-07-25
    相关资源
    最近更新 更多