swa*_*709 0 amazon-ec2 amazon-ebs amazon-web-services aws-cloudformation
我尝试使用 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
Run Code Online (Sandbox Code Playgroud)
对于上面的代码,仅创建 100Gb /dev/sdh。
我认为 Cloudformation 正在覆盖 EBS 卷。
有人知道为什么吗?请帮忙!
您错过了-每个设备名称前面的 。就像这样:
BlockDeviceMappings:
- DeviceName: "/dev/xvda"
Ebs:
VolumeSize: 16
VolumeType: gp2
- DeviceName: "/dev/xvdf"
Ebs:
VolumeSize: 12
VolumeType: gp2
Run Code Online (Sandbox Code Playgroud)
如果-您实际上定义了一个包含具有冲突键的单个元素的数组,则 yaml 的默认行为是使用它在对象中找到的最后一个键。