In this subchapter, we look at two EC2 features that solve specific problems: Elastic IPs (to have a fixed IP address) and Placement Groups (to control where your instances are physically placed). You’ll use the first one very soon; the second is for more specialized cases, but it’s good to know about it.

The Problem of Changing IPs

Each EC2 instance has IP addresses to communicate over the network:

  • Private IP: to talk to other resources within your network (VPC). It remains as long as the instance exists.
  • Public IP: so the internet can access it. Here’s the problem: by default, this public IP changes every time you stop and start the instance.

Why this is a problem: Imagine you point your website’s name (myweb.com) to the public IP 54.12.34.56. You stop the instance at night to save money (subchapter 4.3) and, when you start it in the morning, AWS gives it another IP, for example 54.99.88.77. Now your website “doesn’t work” because the name still points to the old IP.

The Solution: Elastic IP

An Elastic IP (EIP) is a fixed public IP address that you reserve and can associate with an instance. Unlike a normal public IP, it doesn’t change, even if you stop and start the instance.

Analogy: A normal public IP is like a phone number that gets reassigned to you each time. An Elastic IP is like buying your own fixed number: it’s yours and you’re always reachable at it.

Advantages of an Elastic IP:

  • It’s constant: ideal for pointing domain names.
  • You can move it from one instance to another. If an instance fails, you associate the EIP to a backup and traffic keeps arriving at the same place. This is useful for failover.

⚠️ Cost detail (important): AWS charges you for Elastic IPs that you reserve but DO NOT use (those not associated with a running instance). The logic: IPv4 addresses are a scarce resource, so AWS penalizes hoarding them without use. Release Elastic IPs you don’t need to avoid unnecessary charges. Since 2024, AWS also charges for public IPv4s in general, so use them wisely.

Modern note: In current architectures, Elastic IPs are often not used directly. Instead, a load balancer (Chapter 13) or CloudFront (Chapter 16) is placed in front, providing a stable entry point without tying an IP to a specific instance. Still, you should know about EIPs because they’re useful in many cases.

Placement Groups: Controlling Physical Placement

By default, AWS decides where to physically place your instances within a datacenter. Normally that’s fine. But sometimes you want to influence that placement for performance or resilience reasons. That’s what Placement Groups are for.

There are three strategies, each solving a different need:

  1. Cluster — Maximum Performance

Places the instances very close together, in the same physical location, so they communicate with lowest latency and highest bandwidth possible.

  • Use case: applications requiring ultra-fast communication between instances (high-performance computing, big data, scientific calculations).
  • Risk: since they’re all together, a physical failure could affect them all at once. Less resilience in exchange for more speed.

  1. Spread — Maximum Resilience

Places each instance on different physical hardware, as far apart as possible.

  • Use case: critical applications where you don’t want two instances sharing the same point of failure. If a physical server dies, only one instance goes down.
  • Example: the few servers supporting a critical system, where losing two at once would be unacceptable.

  1. Partition — Large-Scale Balance

Divides instances into groups (partitions), each on separate hardware. Instances within a partition share infrastructure, but partitions themselves are isolated from each other.

  • Use case: large distributed systems (like Hadoop, Cassandra, Kafka databases) that already manage replicas and want to control which groups can fail together.

Quick Comparison

Strategy Places instances… Prioritizes Use case
Cluster Very close together Performance/latency HPC, big data
Spread Very far apart Resilience Few critical instances
Partition In isolated groups Large-scale balance Large distributed systems

Don’t worry if Placement Groups seem advanced: they are. Most projects don’t need them at first. What’s important now is to know that they exist and what each strategy is for.

What You Should Remember

  • The normal public IP of an instance changes when stopping/starting; this breaks domains pointing to it.
  • An Elastic IP is a fixed public IP that you reserve and can move between instances (useful for failover).
  • Watch out for costs: AWS charges for reserved and unused Elastic IPs. Release those you don’t need.
  • In modern architectures, a load balancer or CloudFront usually replaces the Elastic IP as a stable entry point.
  • Placement Groups control physical placement: Cluster (performance), Spread (resilience), and Partition (large-scale balance). They’re for advanced cases.

In the last EC2 subchapter, we’ll look at something that directly affects your bill: purchase models (On-Demand, Reserved, Savings Plans, and Spot) and when to use each one.

Cloud, AWS & Terraform — From Zero to Expert

Chapter 1 · What is cloud computing

Chapter 2 · The cloud market and major providers

Chapter 3 · Regions, availability zones and edge

Chapter 4 · Compute: EC2

Chapter 5 · Storage: S3

Chapter 6 · Networking: VPC

Chapter 7 · Identity and access: IAM

Chapter 8 · Managed databases

Chapter 9 · Why Infrastructure as Code

Chapter 10 · HCL: the Terraform language

Chapter 11 · Providers and state

Chapter 12 · Your first real infrastructure in Terraform

Chapter 13 · Load balancing and auto scaling

Chapter 14 · Serverless with Lambda

Chapter 15 · Messaging and events

Chapter 16 · Content delivery and DNS

Chapter 17 · Containers on AWS

Chapter 18 · Modules: reuse and composition

Chapter 19 · Workspaces and environment management

Chapter 20 · Remote backends and locking

Chapter 21 · Infrastructure testing

Chapter 22 · Terraform in CI/CD

Chapter 23 · Defense in depth

Chapter 24 · Observability: logs, metrics and traces

Chapter 25 · Cost optimization

Chapter 26 · High availability and disaster recovery

Chapter 27 · AWS Well-Architected Framework

Chapter 28 · Serverless architectures at scale

Chapter 29 · Data platforms on AWS

Chapter 30 · Multi-account and landing zones

Chapter 31 · Platform Engineering and Internal Developer Platform

Chapter 32 · Relevant AWS certifications

Chapter 33 · Projects to consolidate what you've learned

Chapter 34 · Resources and community

© Copyright 2024. All rights reserved