Amazon EC2 is a virtualisation service.

It supports two approaches to first-boot customisation of machines:

  • User Data Scripts provide a platform-agnostic means of shipping files, usually shell scripts, to the machine.
  • CloudFormation helpers allow reporting back provisioning script status.


AMIs are base images used for virtual machines in AWS. They're comprised of:

  • 1 or more EBS snapshots or, for instance-store-backed AMIs, a template of the root volume.
  • Launch permissions that determine which AWS accounts can launch instances.
  • A block device mapping that specifies the volumes that should be attached to the instance when it's launched.

Custom AMIs can be built with Packer (Private).

Key pairs

Key pairs secure access to instances, either via SSH or for encryption of the instance's Windows password.


All persistent disks will be backed by EBS volumes. Instance store volumes provide ephemeral local storage on the EC2 host which is lost whenever the instance hibernates, stops, or terminates; or the underlying disk drive fails. Instance store volumes can't be detached from one instance and attached to another, and their configuration may only be changed at instance start time.

Lifecycle event hooks

Lifecycle event hooks provide early warning of scaling actions via AWS SNS. Notifications are received for all impending scale-out and scale-in events, then the service will wait for the hook to signal that it's able to proceed.

There are two notification types, indicated via the message's LifecycleTransition property:

  • autoscaling:EC2_INSTANCE_LAUNCHING

EC2 Systems Manager

SSM providers configuration management and provisioning for EC2 instances:

  • Run command
  • Automation tasks
  • State management
  • Patch management
  • Inventory management
  • Parameter Store

Parameter store supports SecureString for storing secrets in AWS KMS.

Provisioning with CloudFormation

CloudFormation can be used for VM provisioning by including the AWS::CloudFormation::Init metadata key:

    Type: AWS::EC2::Instance
          # There are many other keys here
            vim: []

CloudFormation provides some helper scripts:

  • cfn-init is a provisioning tool, usually launched from a User Data Script, which accepts a declarative YAML input describing the actions to take.
  • cfn-signal signals its SUCCESS/FAILURE state to the platform using cfn-signal.
  • cfn-get-metadata retrieves instance metadata defined in the template.
  • cfn-hup deals with changes to metadata.

Placement groups

Placement groups allow high performance compute applications to indicate to the AWS platform that their workloads need to be placed close together. There's no additional charge for the service.


EC2-Classic is the legacy EC2 service which existed prior to VPC.

  1. Auto Scaling
  2. Bare Metal
  3. Clone an instance
  4. Dedicated
  5. EBS
  6. Instance types
  7. Spot Instances
  8. Status checks