【问题标题】:Using !FindInMap when creating a blockdevice创建块设备时使用 !FindInMap
【发布时间】:2019-04-23 02:31:15
【问题描述】:

所以我只是在创建磁盘时尝试使用 FindInMap。

我得到了结构,但我得到了错误:

“属性 BlockDeviceMappings 的值必须是 List 类型”

所以很明显我没有完全理解布局。

只是尝试我能想到的一切。不幸的是,AWS 的示例主要参考了在区域中使用它。如您所见,它并没有太大帮助。

 ec2Map:                         ---(my map)
    test:                         ----(outter key)
      InstanceType: t2.small
      volsize: 20                ----(inner key)
    dev:
      InstanceType: t2.small
      volsize: 40

Note: there is parameter that references 'myec2instances' so I can pick the size in a drop down.

#here is where I am lost. How to I  reference the other items needed like device name and volumetype? 

So I get rid of the error mentioned above..


 BlockDeviceMappings: !FindInMap
        - ec2Map
        - !Ref 'myec2instance'
        - volsize
           DeviceName: "/dev/sdf"
      #       Ebs:
      #         VolumeSize: 
      #         VolumeType: gpa

我基本上是在努力做到这一点,所以当配置测试 ec2 时,它会额外增加 20gb 卷,而对于 dev 来说,它将获得 40gb 卷。

【问题讨论】:

    标签: amazon-cloudformation


    【解决方案1】:

    您需要将 !FindInMap 在结构中向下移动并重复,如下所示:

    BlockDeviceMappings:
      - DeviceName: '/dev/sdf' # additional volume
        Ebs:
          VolumeSize: !FindInMap [ec2Map, !Ref myec2instance, volsize]
          VolumeType: !FindInMap [ec2Map, !Ref myec2instance, voltype]
          ...    
    

    【讨论】:

      猜你喜欢
      • 2022-01-18
      • 2010-12-07
      • 1970-01-01
      • 2017-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多