我正在使用下面的脚本在实例启动时重新附加“可用”卷但不知何故它不起作用。我已经附加了我的云形成模板的片段。 TQ
Under LaunchConfiguration I am creating the EBS volumes
BlockDeviceMappings:
- DeviceName: /dev/sda1
Ebs:
VolumeType: gp2
VolumeSize: '100'
- DeviceName: /dev/sdb
Ebs:
DeleteOnTermination: "false"
VolumeSize: '50'
VolumeType: gp2
- DeviceName: /dev/sdc
Ebs:
DeleteOnTermination: "false"
VolumeSize: '50'
VolumeType: gp2
Here I am calling those volume to reattach
UserData: !Base64
'Fn::Join':
- ''
- - |
<script>
- 'cfn-init.exe -v -c config -s '
- !Ref 'AWS::StackId'
- ' -r ServerLaunchConfig'
- ' --region '
- !Ref 'AWS::Region'
- |+
- |
</script>
|
<powershell>
"$instanceId = Invoke-RestMethod -Uri http://169.254.169.254/latest/meta-data/instance-id \n";
$available = Get-EC2Volume -Filter @{ Name="status"; Values="available" }
Foreach ($instance in $available) {
ec2-attach-volume --instance-id $instanceId /dev/sdb --device vol-VVVVVVVV
ec2-attach-volume --instance-id $instanceId /dev/sdc --device vol-VVVVVVVV
}
</powershell>
答案 0 :(得分:1)
我看到以下问题:
ec2-attach-volume
命令中引用EBS卷ID。/dev/sdb
,下次通过/dev/sdc
等等。