Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Elastic IP addresses
📖 Scenario: You are managing a small web application hosted on AWS. You want to assign a fixed public IP address to your EC2 instance so that users can always reach your server at the same IP, even if the instance is stopped and started.
🎯 Goal: Create an Elastic IP address resource and associate it with an EC2 instance using AWS CloudFormation.
📋 What You'll Learn
Create an Elastic IP resource with the name MyElasticIP.
Create an EC2 instance resource with the name MyEC2Instance.
Associate the Elastic IP MyElasticIP with the EC2 instance MyEC2Instance.
Use valid AWS CloudFormation syntax.
💡 Why This Matters
🌍 Real World
Elastic IPs are used to keep a fixed public IP for cloud servers, useful for DNS records and stable access.
💼 Career
Understanding Elastic IPs and CloudFormation templates is essential for cloud engineers managing AWS infrastructure.
Progress0 / 4 steps
1
Create an EC2 instance resource
Create a resource called MyEC2Instance of type AWS::EC2::Instance with the property ImageId set to ami-0abcdef1234567890.
AWS
Hint
The Resources section defines AWS resources. Use the exact resource name MyEC2Instance and set ImageId to the given AMI ID.
2
Create an Elastic IP resource
Add a resource called MyElasticIP of type AWS::EC2::EIP under Resources.
AWS
Hint
Elastic IPs are defined with type AWS::EC2::EIP. Use the exact resource name MyElasticIP.
3
Associate the Elastic IP with the EC2 instance
Add a resource called MyEIPAssociation of type AWS::EC2::EIPAssociation that associates MyElasticIP with MyEC2Instance using the properties AllocationId and InstanceId referencing the correct resources.
AWS
Hint
Use AWS::EC2::EIPAssociation to link the Elastic IP to the EC2 instance. Use !GetAtt MyElasticIP.AllocationId and !Ref MyEC2Instance for properties.
4
Add Outputs for the Elastic IP address
Add an Outputs section with an output called ElasticIPAddress that returns the public IP of MyElasticIP using !Ref MyElasticIP.
AWS
Hint
The Outputs section lets you see the Elastic IP after deployment. Use !Ref MyElasticIP to get the IP address.
Practice
(1/5)
1. What is the main purpose of an Elastic IP address in AWS?
easy
A. To provide a fixed public IP address that can be reassigned to different instances
B. To increase the storage capacity of an EC2 instance
C. To encrypt data in transit between AWS services
D. To automatically scale the number of EC2 instances
Solution
Step 1: Understand Elastic IP purpose
An Elastic IP is a static public IP address designed to be associated with AWS resources like EC2 instances.
Step 2: Identify its main use
It allows you to keep the same public IP even if you stop and start or replace the instance, ensuring consistent reachability.
Final Answer:
To provide a fixed public IP address that can be reassigned to different instances -> Option A
Quick Check:
Elastic IP = Fixed public IP for instances [OK]
Hint: Elastic IP means fixed public IP for your server [OK]
Common Mistakes:
Confusing Elastic IP with storage or encryption
Thinking Elastic IP auto-scales instances
Assuming Elastic IP changes on instance restart
2. Which AWS CLI command correctly allocates a new Elastic IP address?
easy
A. aws ec2 create-elastic-ip
B. aws ec2 assign-elastic-ip
C. aws ec2 new-ip-address
D. aws ec2 allocate-address
Solution
Step 1: Recall AWS CLI syntax for Elastic IP allocation
The correct command to allocate a new Elastic IP is 'aws ec2 allocate-address'.
Step 2: Verify other options
Other options are invalid AWS CLI commands and will cause errors.
Final Answer:
aws ec2 allocate-address -> Option D
Quick Check:
Allocate Elastic IP = aws ec2 allocate-address [OK]
Hint: Allocate Elastic IP with 'allocate-address' command [OK]
Common Mistakes:
Using non-existent commands like create-elastic-ip
Confusing allocation with assignment commands
Misspelling the command name
3. Consider this AWS CLI output after associating an Elastic IP to an instance:
A. The Elastic IP 203.0.113.25 is now linked to the instance i-0abcd1234efgh5678
B. The instance i-0abcd1234efgh5678 has been terminated
C. The Elastic IP has been released and is no longer usable
D. The instance has no public IP assigned
Solution
Step 1: Analyze the output fields
The output shows an AssociationId, a PublicIp, and an InstanceId, indicating a link between the IP and instance.
Step 2: Interpret the meaning
This means the Elastic IP 203.0.113.25 is assigned to the instance i-0abcd1234efgh5678.
Final Answer:
The Elastic IP 203.0.113.25 is now linked to the instance i-0abcd1234efgh5678 -> Option A
Quick Check:
AssociationId means IP linked to instance [OK]
Hint: AssociationId means IP linked to instance [OK]
Common Mistakes:
Thinking the instance is terminated
Assuming the IP is released
Ignoring the AssociationId meaning
4. You tried to associate an Elastic IP to an instance but got an error: "AddressLimitExceeded". What is the likely cause?
medium
A. The instance does not have an internet gateway attached
B. You have reached the maximum number of Elastic IPs allowed in your AWS account
C. The Elastic IP is not in the same region as the instance
D. The instance is already terminated
Solution
Step 1: Understand the error message
"AddressLimitExceeded" means you have hit the limit of Elastic IPs you can allocate in your AWS account.
Step 2: Check other options
Instance termination or region mismatch cause different errors; internet gateway absence affects connectivity but not this error.
Final Answer:
You have reached the maximum number of Elastic IPs allowed in your AWS account -> Option B
Quick Check:
AddressLimitExceeded = Max Elastic IPs reached [OK]
Hint: AddressLimitExceeded means max Elastic IPs reached [OK]
Common Mistakes:
Confusing region mismatch with limit error
Assuming instance termination causes this error
Thinking internet gateway absence triggers this error
5. You have an Elastic IP associated with an EC2 instance. You stop and start the instance. What happens to the Elastic IP and the instance's public IP?
hard
A. The Elastic IP remains but the instance loses its public IP until reassigned
B. The Elastic IP is released automatically and the instance gets a new public IP
C. The Elastic IP remains associated and the instance keeps the same public IP
D. The Elastic IP dissociates and you must manually re-associate it
Solution
Step 1: Recall Elastic IP behavior on instance stop/start
Elastic IPs remain allocated and associated with the instance even if it is stopped and started.
Step 2: Understand public IP behavior
Without Elastic IP, the public IP changes on stop/start, but with Elastic IP, the public IP stays the same.
Final Answer:
The Elastic IP remains associated and the instance keeps the same public IP -> Option C
Quick Check:
Elastic IP keeps public IP fixed on stop/start [OK]
Hint: Elastic IP keeps public IP fixed after stop/start [OK]