A c5 instance recovery from snapshot may fail

A c5 instance recovery from snapshot may fail

If CPM didn't backup a c5 instance with initial ami (snapshots only), the recovery may fail with the following error:

To recover a c5 instance you will need to use the AWS CLI to create an AMI to be used during recovery.

The examples below are performed in Powershell and the full commands are one-liners. If you are using other AWS CLI tool or other methods (JSON file for example), please be aware that syntax may change.

To create the image, please use the command below (make sure to give the image the name you wish and to provide the correct snapshot-id(snapshot ID of the exact root volume’s snapshot you want to recover):

aws ec2 register-image --region us-east-1 --name Mycliimage2 --architecture x86_64 --ena-support --virtualization-type hvm --root-device-name /dev/xvda --block-device-mappings '[{\"DeviceName\": \"/dev/xvda\", \"Ebs\": { \"SnapshotId\": \" snap-00f4223c8ec62fc76\"} }]'

Powershell will return the value of the image id created like the example below:

{

"ImageId": "ami-c3d9f9b9"

}

To recover the instance from the image and attach its volumes from snapshots use the following command:

aws ec2 run-instances --region us-east-1 --image-id ami-a0dfebda --count 1 --instance-type c5.large --key-name NVirginiaKP --security-group-ids sg-eaba249e --subnet-id subnet-a18558fb --block-device-mappings '[{\"DeviceName\": \"/dev/sdb\", \"Ebs\": { \"SnapshotId\": \"snap-0dd8a4ee636e27d60\"} },{\"DeviceName\": \"/dev/sdb\", \"Ebs\": { \"SnapshotId\": \"snap-0dd8a4ee636e27d60\"} }]'

Make sure you set the correct values to match your desired:

  • Region
  • Image
  • Instance type
  • Key name
  • Security group
  • Subnet
  • Block device mapping is properly mapped to additional volume(s) or omitted if you don’t wish to attach additional volumes.

Powershell should return a response with all instance details if command was successful