AWS Zero to Hero Day - 06


Task for Day 6
What is Elastic Container Service?
Amazon Elastic Container Services (Amazon ECS) is a fully managed container orchestration service that helps organizations easily deploy, manage, and scale containerized applications.
What is Elastic Container Registry?
Amazon Elastic Container Registry (ECR) is a fully managed Docker container registry service provided by Amazon Web Services (AWS). In simple terms, it's a place where you can store, manage, and deploy Docker container images, making it easier for you to run applications in the cloud using containers.
What is Route 53?
Amazon Route 53 is a scalable and highly available Domain Name System (DNS) web service provided by Amazon Web Services (AWS). It is named after the TCP/IP port 53, which is used for DNS services. Route 53 is designed to provide reliable and cost-effective domain registration, DNS routing, and health checking of resources within your AWS infrastructure.
How Does DNS Route Traffic To Your Web Application? See the diagram below:
Tasks:
1) Deploy a two-tier application on Elastic Container Service (ECS) and configure Elastic Container Registry (ECR) to push Docker images.
Note:
The Docker image must be fetched from ECR.
ANS:
Task 1 done - Application running ss:
EC2 instance used to build and push an image
Repository where the image is pushed.
The Docker image:
Task Definition:
Task inside cluster:
That task configuration:
Accessed the app at that public IP with port 8000
2) Understand the concept of CloudFront and try to perform below sub-tasks:
- What is caching in CloudFront?
- Create an EC2 instance with an Apache web server
- Create a CloudFront distribution and attach it to an EC2 instance to access the Apache webpage.
ANS:
To learn about AWS CloudFront, read this blog
1. What is Caching in CloudFront?
Caching in AWS CloudFront involves storing copies of your content at over 600 edge locations globally, as noted in the AWS CloudFront Documentation. When a user requests content, CloudFront checks the nearest edge location for a cached copy. If available, it delivers the content immediately, reducing latency. If not, it fetches the content from the origin (e.g., an EC2 instance), caches it, and serves it. Key aspects include:
Cache Key: Determines what’s cached, based on headers, cookies, or query strings.
TTL Settings: Controls how long content stays cached (default or custom via cache policies).
Cache Hit Ratio: The proportion of requests served from the cache, which you can optimize using tools like Origin Shield.
This caching mechanism improves performance, reduces origin server load, and enhances reliability by distributing content closer to users.
2. Creating an EC2 Instance with Apache Web Server
Follow these steps to launch an EC2 instance and install Apache:
Log into AWS Management Console:
- Access the AWS Console at AWS Management Console and navigate to the EC2 dashboard.
Launch an EC2 Instance:
Click “Launch Instance” and select an AMI, such as Amazon Linux 2 or Ubuntu Server 20.04.
Choose the t2.micro instance type (free tier eligible).
Configure instance details (use defaults unless specific needs arise).
Add storage (8 GB default is sufficient).
Add optional tags (e.g., Name: Apache-Server).
Configure a security group:
Create a new security group.
Add rules for:
SSH (port 22) from your IP for secure access.
HTTP (port 80) from 0.0.0.0/0 to allow web traffic.
Review and launch, selecting or creating a key pair (e.g., my-key.pem) for SSH access.
Connect to the Instance:
Once the instance is running, note its public DNS (e.g., ec2-xx-xx-xx-xx.compute-1.amazonaws.com).
Use SSH to connect: bashCopy
ssh -i /path/to/my-key.pem ec2-user@public-dns-name
- For Amazon Linux, use ec2-user; for Ubuntu, use ubuntu.
Install and Configure Apache:
For Amazon Linux: bashCopy
sudo yum update -y udo yum install httpd -y sudo systemctl start httpd sudo systemctl enable httpd
For Ubuntu: bashCopy
sudo apt update sudo apt install apache2 -y sudo systemctl start apache2 sudo systemctl enable apache2
Verify Apache is running by accessing the instance’s public DNS in a browser (e.g., http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com). You should see the Apache default page.
Optional: Customize Webpage:
Edit the default webpage (e.g., /var/www/html/index.html) to add custom content, ensuring it’s accessible via the browser.
3. Creating a CloudFront Distribution for EC2
To serve the Apache webpage through CloudFront, create a distribution with the EC2 instance as the origin:
Access CloudFront Console:
- Navigate to CloudFront in the AWS Console at CloudFront Console.
Create a Distribution:
- Click “Create Distribution” and select “Web” delivery method.
Configure Origin Settings:
Origin Domain Name: Enter the EC2 instance’s public DNS (e.g., ec2-xx-xx-xx-xx.compute-1.amazonaws.com).
Origin Path: Leave blank.
Origin Protocol Policy: Select “HTTP Only” (unless your EC2 supports HTTPS).
Minimum Origin SSL Protocol: Use default settings.
Configure Default Cache Behavior:
Viewer Protocol Policy: Choose “Redirect HTTP to HTTPS” for security or “HTTP and HTTPS”.
Allowed HTTP Methods: Select “GET, HEAD” for static content.
Cache Policy: Use “Managed-CachingOptimized” for typical static content caching, or customize TTL settings (e.g., Minimum TTL: 0, Default TTL: 86400 seconds).
Origin Request Policy: Select “Managed-AllViewer” to forward all viewer headers.
Configure Distribution Settings:
Price Class: Select “Use All Edge Locations” or restrict based on your audience’s location.
Alternate Domain Names (CNAMEs): Leave blank (no custom domain specified).
SSL Certificate: Use the default CloudFront certificate.
Leave other settings as default unless specific requirements apply.
Create and Deploy:
Click “Create Distribution”. Deployment may take 5–20 minutes.
Once the status changes to “Deployed”, note the distribution’s domain name (e.g., d1234567890.cloudfront.net).
Test the Distribution:
Open a browser and enter the CloudFront domain name (e.g., http://d1234567890.cloudfront.net).
Verify that the Apache webpage displays, matching the EC2 instance’s content.
EC2 DNS URL:
Cloud Front Domain Name:
You can check the URL in both SS.
3) Learn about AWS's fully managed DNS Service (Route53) and write a detailed blog post and post it on LinkedIn.
ANS:
AWS Route 53 is a highly available and scalable Domain Name System (DNS) web service, as detailed in the AWS Route 53 Documentation. It translates domain names (e.g., example.com) into IP addresses, enabling users to access websites and applications. Key features include:
Domain Registration: Register or transfer domains directly through Route 53.
DNS Management: Create hosted zones to manage DNS records (e.g., A, CNAME, MX).
Traffic Routing: Supports policies like simple, weighted, latency-based, geolocation, and failover routing.
Health Checking: Monitors resource health and reroutes traffic from unhealthy endpoints.
Integration: Works seamlessly with AWS services like EC2, S3, and CloudFront.
Route 53’s global network of DNS servers ensures reliability, and its pay-as-you-go pricing makes it cost-effective for businesses of all sizes.
To Learn more about AWS Route 53, read this blog
Subscribe to my newsletter
Read articles from Amitabh soni directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Amitabh soni
Amitabh soni
DevOps Enthusiast | Passionate Learner in Tech | BSc IT Student I’m a second-year BSc IT student with a deep love for technology and an ambitious goal: to become a DevOps expert. Currently diving into the world of automation, cloud services, and version control, I’m excited to learn and grow in this dynamic field. As I expand my knowledge, I’m eager to connect with like-minded professionals and explore opportunities to apply what I’m learning in real-world projects. Let’s connect and see how we can innovate together!