📖 Scenario: You are setting up a simple multi-tier web application on AWS. This application has three layers: a web layer, an application layer, and a database layer. Each layer will be represented by an AWS resource group.We will create the infrastructure step-by-step using AWS CloudFormation syntax in YAML format to define the resources.
🎯 Goal: Create a CloudFormation template that defines a multi-tier architecture with three layers: WebTier, AppTier, and DBTier. Each tier will be represented by an AWS EC2 instance with specific tags to identify the tier.
📋 What You'll Learn
Define three EC2 instances named WebTierInstance, AppTierInstance, and DBTierInstance.
Each instance must have a Tags property with a Key of Tier and a Value matching its tier name.
Use the Amazon Linux 2 AMI ID ami-0c55b159cbfafe1f0 for all instances.
Set the instance type to t2.micro for all instances.
💡 Why This Matters
🌍 Real World
Multi-tier architectures are common in web applications where separation of concerns improves security, scalability, and maintenance. AWS CloudFormation helps automate the deployment of such architectures.
💼 Career
Understanding how to define multi-tier architectures using Infrastructure as Code is a key skill for cloud engineers and architects working with AWS.
Progress0 / 4 steps
1
Create the Web Tier EC2 Instance
Create a resource called WebTierInstance of type AWS::EC2::Instance with the AMI ID ami-0c55b159cbfafe1f0 and instance type t2.micro. Add a tag with Key set to Tier and Value set to WebTier.
AWS
Hint
Use the Resources section to define the EC2 instance. Remember to add the Tags property with the correct key and value.
2
Add the Application Tier EC2 Instance
Add a resource called AppTierInstance of type AWS::EC2::Instance with the same AMI ID ami-0c55b159cbfafe1f0 and instance type t2.micro. Add a tag with Key set to Tier and Value set to AppTier. Keep the existing WebTierInstance resource unchanged.
AWS
Hint
Define the AppTierInstance resource similarly to the WebTierInstance, changing only the tag value to AppTier.
3
Add the Database Tier EC2 Instance
Add a resource called DBTierInstance of type AWS::EC2::Instance with the AMI ID ami-0c55b159cbfafe1f0 and instance type t2.micro. Add a tag with Key set to Tier and Value set to DBTier. Keep the existing WebTierInstance and AppTierInstance resources unchanged.
AWS
Hint
Define the DBTierInstance resource similarly to the other instances, with the tag value set to DBTier.
4
Complete the CloudFormation Template
Add the AWSTemplateFormatVersion set to 2010-09-09 at the top of the template. Keep all three EC2 instance resources unchanged.
AWS
Hint
The AWSTemplateFormatVersion should be the very first line in the template.
Practice
(1/5)
1. What is the main purpose of using a multi-tier architecture in AWS?
easy
A. To combine all application components into a single server
B. To reduce the number of servers needed by merging databases and web servers
C. To separate an application into layers for better security and scalability
D. To allow direct internet access to all parts of the application
Multi-tier architecture divides an app into layers such as web, application, and database tiers.
Step 2: Identify benefits of layering
This separation improves security by isolating layers and helps scale parts independently.
Final Answer:
To separate an application into layers for better security and scalability -> Option C
Quick Check:
Multi-tier = layers for security and scaling [OK]
Hint: Think layers for security and growth, not one big block [OK]
Common Mistakes:
Thinking all parts should be on one server
Assuming all components need internet access
Confusing multi-tier with single-tier or monolithic
2. Which AWS subnet type is typically used to host internet-facing web servers in a multi-tier architecture?
easy
A. Public subnet
B. Isolated subnet
C. Private subnet
D. VPN subnet
Solution
Step 1: Recall subnet types in AWS
Public subnets have a route to the internet gateway, allowing internet access.
Step 2: Match subnet to web servers
Internet-facing web servers need public subnets to receive traffic from users.
Final Answer:
Public subnet -> Option A
Quick Check:
Internet-facing = public subnet [OK]
Hint: Public subnet means internet access for web servers [OK]
Common Mistakes:
Choosing private subnet which blocks internet access
Confusing isolated subnet with public
Thinking VPN subnet is for public web servers
3. In a multi-tier AWS architecture, which tier is usually placed in a private subnet to protect sensitive data?
medium
A. Database tier
B. Application tier
C. Web tier
D. Load balancer tier
Solution
Step 1: Identify tiers and their security needs
The database tier holds sensitive data and needs strong protection.
Step 2: Determine subnet placement
Private subnets restrict internet access, ideal for databases to prevent direct exposure.
Final Answer:
Database tier -> Option A
Quick Check:
Database = private subnet for security [OK]
Hint: Sensitive data stays in private subnet (database) [OK]
Common Mistakes:
Placing web tier in private subnet
Assuming load balancer is in private subnet
Confusing application tier with database tier
4. You deployed a multi-tier app but the application tier in the private subnet cannot connect to the database tier. What is the most likely cause?
medium
A. The load balancer is not configured
B. The web tier is in a public subnet
C. The application tier has a public IP address
D. The database security group does not allow inbound traffic from the application tier
Solution
Step 1: Analyze connectivity between application and database tiers
Application tier must be allowed by database security group to connect on required ports.
Step 2: Check common misconfigurations
If security group blocks inbound traffic, connection fails despite correct subnet placement.
Final Answer:
The database security group does not allow inbound traffic from the application tier -> Option D
Quick Check:
Security group rules control traffic between tiers [OK]
Hint: Check security group rules for inter-tier traffic [OK]
Common Mistakes:
Blaming web tier subnet for app-db connection
Assuming public IP needed for private subnet
Ignoring security group inbound rules
5. You want to design a multi-tier AWS app with a public web tier, private application tier, and private database tier. Which setup best follows best practices?
hard
A. Place all tiers in public subnets with direct internet access for simplicity
B. Place web servers in public subnet with internet gateway; app and database servers in private subnets with NAT gateway for outbound internet
C. Place web and app tiers in private subnets; database in public subnet for easy access
D. Place web tier in private subnet; app and database tiers in public subnets
Solution
Step 1: Assign subnet types based on tier roles
Web tier needs public subnet for user access; app and database tiers should be private for security.
Step 2: Provide outbound internet for private tiers
Use NAT gateway so private tiers can access internet for updates without exposing them inbound.
Final Answer:
Place web servers in public subnet with internet gateway; app and database servers in private subnets with NAT gateway for outbound internet -> Option B
Quick Check:
Public web, private app/db, NAT for outbound [OK]
Hint: Public web, private app/db, NAT gateway outbound [OK]
Common Mistakes:
Putting database in public subnet
Giving private tiers direct internet access
Mixing subnet roles incorrectly
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.