【发布时间】:2018-10-21 21:39:54
【问题描述】:
我正在尝试在创建 ec2 期间安装多个卷。 CF 没有抱怨 yaml,堆栈没有错误地完成,实例被创建,设备通过“lsblk”显示,但没有安装发生。以下是精简后的 yaml:
对于本练习,我只是尝试安装一个,然后继续为其余部分编写 yaml。
AWSTemplateFormatVersion: '2010-09-09'
Description: "adding instances"
Resources:
Instance01:
Type: AWS::EC2::Instance
Properties:
SubnetId: subnet-xxxxxx
KeyName: 'awesome'
ImageId: ami-xxxxxxx
InstanceType: m5.2xlarge
SecurityGroupIds:
- sg-xxxxxx
- sg-xxxxxx
- sg-xxxxxx
IamInstanceProfile: 'MyRole'
Tags:
- Key: Name
Value: 'awesometag'
BlockDeviceMappings:
- DeviceName: '/dev/xvdb'
Ebs:
VolumeSize: 50
VolumeType: gp2
- DeviceName: '/dev/xvdc'
Ebs:
VolumeSize: 80
VolumeType: gp2
- DeviceName: '/dev/xvdd'
Ebs:
VolumeSize: 50
VolumeType: gp2
- DeviceName: '/dev/xvde'
Ebs:
VolumeSize: 50
VolumeType: gp2
- DeviceName: '/dev/xvdf'
Ebs:
VolumeSize: 50
VolumeType: gp2
- DeviceName: '/dev/xvdg'
Ebs:
VolumeSize: 50
VolumeType: gp2
UserData:
Fn::Base64:
!Sub |
#!/bin/bash -xe
mkfs -t ext4 /dev/xvdc
sleep 5
mkdir -p /mypartition
mount /dev/xvdc /mypartition
echo "/dev/xvdc /mypartition ext4 defaults,noatime 0 0" >> /etc/fstab
mount -a
(显然 yaml 间距不正确,但这是复制/粘贴问题:)
就像我说的;实例已创建,但 df -h 不显示 /mypartition 并且 /etc/fstab 没有条目。
谢谢!
【问题讨论】:
-
用户数据脚本的输出显示了什么?
-
您是否创建了目录“/mypartition”?
标签: amazon-ec2 yaml amazon-cloudformation