Reputation: 167
I am using below script to re-attach the "available" volumes when the instance starts but somehow it's not working.I have attached snippet of my cloud formation template. 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>
Upvotes: 0
Views: 512
Reputation: 36073
I see the following problems:
ec2-attach-volume
commands./dev/sdb
, next time through /dev/sdc
, etc.Upvotes: 1