I would like to create a CloudWatch alarm to recover my EC2 instance under certain conditions. I would also like for the alarm to send a notification to designated recipients. I have followed all prerequisites for enabling this functionality at Recover Your Instance and Create Alarms That Stop, Terminate, Reboot, or Recover an Instance. When I attempt to create a CloudWatch alarm for this purpose, both alarm notification options (topic name and recipients) and the "Recover this instance" option displayed by "Take the action:" are disabled.

Currently, the recover action is not supported for EC2 instances that use ephemeral instance store volumes, including those launched with block device mappings for instance store volumes.

Determine if the EC2 instance is configured to use instance store volumes

Use one of the following methods to determine if the EC2 instance is configured to use instance store volumes.

  • If the EC2 instance is running Linux, connect to the instance and run the following from a command shell to determine if any instance store volumes are mapped to the EC2 instance:

curl http://169.254.169.254/latest/meta-data/block-device-mapping/

 

[ec2-user@ip-172.31.2.161 ~]$ curl http://169.254.169.254/latest/meta-data/block-device-mapping/

ami

ephemeral0

ephemeral2

root

Volumes that begin with "ephemeral" are instance store volumes that are mapped to the EC2 instance.

Volumes that begin with "ephemeral" are instance store volumes that are mapped to the EC2 instance.

  • This information can also be seen by checking the Amazon Machine Image (AMI) for your EC2 instance in the EC2 console. View the details tab for the AMI in the EC2 console, and look for any block device instance store volumes with the designation "=ephemeral#" where # is some integer from 0 to 23.
  • Run the following command from the AWS Command Line Interface (CLI) to return information that includes the BlockDeviceMappings for the AMI by providing the appropriate value for the --image-ids parameter:

aws ec2 describe-images --image-ids ami-11112222

   

"BlockDeviceMappings": [

   {

      "DeviceName": "/dev/xvda",

      "Ebs": {

         "DeleteOnTermination": true,

         "SnapshotId": "snap-        ",

         "VolumeSize": 8,

         "VolumeType": "gp2",

         "Encrypted": false

      }

   },

   {

      "DeviceName": "/dev/sdb",

      "VirtualName": "ep0hemeral0"

   },

   {

      "DeviceName": "/dev/sdc",

      "VirtualName": "ephemeral2"

   }

],

Again, instance store volumes have the designation "ephemeral#" where # is some integer from 0 to 23.

Block Device Mapping of instance store volumes can occur on either Linux or Windows, even if the instance type does not officially support the use of instance store volumes.

This can occur when using the AWS CLI, an SDK, or a service such as CloudFormation to launch an EC2 instance based upon an AMI with a block device mapping that includes instance store volumes. If the EC2 console is used to launch an EC2 instance type that does not support instance store volumes (such as T2, M4, or C4), modified block device mappings are simply ignored.

Remove or override any references to instance store volumes in the AMI, and relaunch the EC2 instance

If you verify that your EC2 instance is using an instance store volume, you must relaunch the instance because instance store volumes cannot be added or removed from an existing EC2 instance. You can remove references to instance store volumes from the AMI and relaunch the instance, or use one of the following methods to override references to instance store volumes in the AMI when you relaunch the EC2 instance:

  • Launch the EC2 instance from the EC2 console to override the AMI for those EC2 instance types that do not support instance store volumes.
  • Launch the EC2 instance from the AWS CLI and manually override each device in the AMI that references an instance store volume. In the example AWS CLI output shown earlier, the devices mapped to instance store volumes are '/dev/sdb' and '/dev/sdc'. To override mapping of these devices to instance store volumes, you can launch the EC2 instance from the CLI using the following syntax:

aws ec2 run-instances --image-id ami-11112222 --subnet-id subnet-11112222 --instance-type t2.medium --key-name my_key --associate-public-ip-address --block-device-mappings '[{"DeviceName": "/dev/sdb","NoDevice": ""},{"DeviceName": "/dev/sdc","NoDevice": ""}]'

For more information about using the AWS CLI to run EC2 instances, see aws.ec2 run-instances.

  • If the EC2 instance is launched by using CloudFormation, create a CloudFormation template to override mapping of any devices to instance store volumes:

{

  "AWSTemplateFormatVersion": "2010-09-09",

  "Resources": {

    "I4EY8I": {

      "Type": "AWS::EC2::Instance",

      "Properties": {

        "ImageId" : "ami-11112222",

        "InstanceType" : "t2.medium",

        "SubnetId" : "subnet-11112222",

        "KeyName" : "my_key",

    "BlockDeviceMappings" : [

        {

             "DeviceName":"/dev/sdb",

            "NoDevice": {}

        },

        {

            "DeviceName":"/dev/sdc",

            "NoDevice": {}

        }

    ]

      }

    }

  }

}

  • If the EC2 instance is launched using an SDK, check the relevant SDK documentation for information about overriding any mapping of devices to instance store volumes.

CloudWatch, alarm, recovery, EC2, Linux, Windows, instance store, ephemeral, block device mapping, disabled


Did this page help you? Yes | No

Back to the AWS Support Knowledge Center

Need help? Visit the AWS Support Center

Published: 2016-02-30