Creating Architecture using Cloud Front with AWS CLI


The AWS Command Line Interface (CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.

Cloud Front ?

Amazon CloudFront is a fast content delivery network (CDN) service that securely delivers data, videos, applications, and APIs to customers globally with low latency, high transfer speeds, all within a developer-friendly environment.

So lets begin this task. The architecture includes-

~~ Webserver configured on EC2 Instance

~~Document Root(/var/www/html) made persistent by mounting on EBS Block Device.

~~Static objects used in code such as pictures stored in S3

~~Setting up Content Delivery Network using CloudFront and using the origin domain as S3 bucket.

~~Finally place the Cloud Front URL on the webapp code for security and low latency.

💥Lets launch the EC2 Instance using this


aws ec2 run-instance — image-id ami-0e306788ff2473ccb — instance-type t2.micro — count 1 — subnet-id subnet-4d225201 — security-group-ids sg-0b661c0a3355410f1 — key-name cli_test

Lets check in webUI

💥Create EBS volume


aws ec2 create-volume — availability-zone ap-south-1b — volume-type gp2 — size 1

here we can see the new volume is created and it is available which means its is not attached to any instance

💥we gonna attach this newly created volume to an instance


aws ec2 attach-volume — device /dev/sdb — volume-id vol-0b4c2f27b905ca805 — instance-id i-0ff2ffd83ac0b7260

we an see in webUI that is attached

To user any raw hard disk or EBS volume we need to format it, for that we are going to follow 3 steps

  1. Create partition
  2. Format
  3. Mount it

STEP:1 To create partition

fdisk <disk name>

STEP:2 Format the newly created partition and command is

mkfs.ext4 <partition name>

STEP:3 Mount the newly created partition on /var/www/html

💥Configure apache webserver in this instance for that we need to follow 3 step fanda

  1. install the software
  2. configure the file
  3. start the service

STEP:1 In our case we need to install httpd software. Command is -

yum install httpd

y is used to confirm the installment

we can check the software is successfully in completed using #httpd -version command.

STEP:2 The configuration folder of httpd is /var/www/html. This is the folder to put all the web pages.

STEP:3 To use the software services first we need to start the services. Command is -

systemctl start httpd.service

💥we are going to put our static data of website in S3 so here we are going to create bucket in s3 service of aws using cli and command is-


aws s3api create-bucket — bucket <name of bucket> — region ap-south-1 — create-bucket-configuration LocationConstraint=ap-south-1

Let check the bucket in webUI

Upload image to S3 bucket.

Command :

aws s3 cp “<path of image>” s3://<name of bucket> — acl public-read-write

lets check in WebUI

💥Create web distribution link using cloud front service

Command :

aws cloudfront create-distribution — origin-domain-name <>— default-root-object <name of file>

let check in webUI

Put this cloud front link into web page

Here we finally get page whose code come from EBS volume, Static data like images store in S3 storage and the Cloud front link is used.

!!!Thank you !!!




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Beginners Exercise on OpenTelemetry — See Traces and Metrics for real!

My 2021 year recap!

Deploy Your Static Web App to S3 Using AWS CodePipeline & CDK

How To Fix Micromax Bharat Go Not Charging [Troubleshooting Guide]

This Week in TurtleCoin (October 8, 2019)

The freeCodeCamp Alumni Network: A homegrown mentorship network for FCC alumni

GO-vatar series: Integrate Cucumber scenario with JIRA Xray

Google In Dark Mode

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Akanksha Chhattri

Akanksha Chhattri

More from Medium

Access AWS Resources using IAM Role through AWS SDK of NodeJS

Automatically tag AWS EC2 Instances with the “Owner” tag upon creation

Using AWS EC2 Elastic Beanstalk? Give Yourself Some Credit

The back of a Printed Circuit Board (PCB) with a gold finish

How to Securely Share Files within AWS without a login