Implementation of an e-commerce system on AWS in an automated way using Terraform and Ansible

Billy Baquera
5 min readOct 4, 2023

--

In a different real-world project, I assumed the role of a Cloud Engineer within a DevOps context. In this capacity, I undertook the task of developing and deploying an e-commerce Minimum Viable Product (MVP) on the Amazon Web Services (AWS) platform, accomplishing the entire process in under two hours. My approach was highly automated, utilizing both Terraform and Ansible, which are part of the Infrastructure as Code (IaC) paradigm.

To streamline the project, I orchestrated the provisioning of infrastructure resources using Terraform and Ansible, effectively automating tasks related to configuration management, software installation, and package management for the EC2 instance. To achieve the project’s objectives, I worked with a technology stack that included Magento, PHP, MySQL, and Redis.

The first thing that needs to be done is to create Access Keys that need to be used for Magento on the Adobe Marketplace site. Note: in order to get the access, you must have an Adobe account..

After selecting “Create A New Access Key”, I named the key, “Key1”..

After the creation, 2 keys are generated, “Public” and “Private”. I then copied these keys to a blank notepad to be used for later..

Remove the word “Copy” from the end of the keys

Next I started the preparation steps for provisioning the EC2 infrastructure on AWS by installing Terraform on the AWS Cloudshell..

Commands needed for Terraform installation on AWS Cloudshell
Terraform successfully installed

I created a folder and then downloaded the Terraform files that are going to be used to create the infrastructure on AWS..

Modifications needed to be made to the unzipped “main.tf” file using VisualStudio..

The key pair we’ve used in previous projects will be used here and we will also be using a t3a.large for the instance type

After uploading the newly modified zip file, I ran Terraform to deploy the EC2 VM..

After the successful deployment, the EC2 instance will show up in the management console..

I then used GitBash to SSH into the EC2 instance using the key pair..

sshkey1.pem

Ansible now needs to be installed using the following commands..

Ansible Playbook files then need to be downloaded and modified. Using VI in GitBash, the domain, hostname, repo_api_key, and repo_secret_key needed to be changed to the appropriate values..

The two keys were the keys copied earlier

I then ran the Ansible playbook with the command below..

If running the Ansible Playbook is successful, it should tell you that there are 0 errors..

Now we need to test to see if the e-Commerce website is up and running by pasting the public IP address in a new browser..

Successful opening page

Changes need to be made using the admin login..

“The Cloud Bootcamp Store” inserted into “Default Page Title” section
In “Welcome Text”, I entered “Welcome to The Cloud Bootcamp Store!”
3 sections changed
Images added for the product

You can now see inventory of 100 along with the price and images for the Catalog

A new widget was also added to the homepage

And finally this is what the homepage now looks like..

This concluding project truly demonstrated to me the remarkable capabilities of Terraform and Ansible in swiftly deploying an e-commerce website with remarkable ease. I believe that such situations are commonplace in the real world, and I am enthusiastic about having gained this valuable learning experience.

Thank you for watching until the end!!

--

--

Billy Baquera
Billy Baquera

Written by Billy Baquera

0 Followers

Experienced IT Leader looking for the next challenge in my career!

No responses yet