EC2
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
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.
Storage
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_TERMINATING
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:
Resources:
MyInstance:
Type: AWS::EC2::Instance
Metadata:
AWS::CloudFormation::Init:
config:
# There are many other keys here
packages:
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 itsSUCCESS
/FAILURE
state to the platform usingcfn-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
EC2-Classic is the legacy EC2 service which existed prior to VPC.
Children
Backlinks
- Get Packing (public)
- API Gateway (public)
- CodeDeploy (public)
- DMS (public)
- ECS (public)
- EKS (public)
- Elastic Beanstalk (public)
- IAM (public)
- RDS (public)
- X-Ray (public)
- Alarms (public)
- Logs (public)
- Metrics (public)
- Clone an instance (public)
- EBS (public)
- ALB (public)
- Classic (public)
- NLB (public)
- Streams (public)
- Instance types (public)
- Logs Agent (public)
- 2022-08-30 (internal) (Private)