Implementation of an E-Commerce System on AWS in an automated way using Terraform and Ansible

Anurag Chawla
5 min readJun 2, 2023

--

In another project based in a real-world scenario, where created and implemented an e-Commerce MVP (Minimum Viable Product) on AWS in an automated way using Terraform and Ansible (Infrastructure as Code — IaC).

Cloud Project — AWS Provider with Services and Technologies

Here provisioned the infrastructure in an automated way using Terraform and Ansible to automate the configuration management process, software installation and package management of the EC2 instance. I also used Magento, PHP, MySQL, and Redis to complete this project.

Solution Architecture — Terraform, Ansible to automate configuration mgmt, installation of software

This has been implemented deploying an MVP e-commerce website using Magento on AWS. Here’s a breakdown of the steps you need to follow:

Create a free account on the Magento Marketplace: Go to https://marketplace.magento.com/ and create an account.

https://marketplace.magento.com

Generate and save the Public and Private Key from your Magento account when access under Markeyplace-> Access Keys

Magento Account- Click on Access Keys to Generate Public and Private Key

AWS Cloud Shell: AWS Cloud Shell is an integrated shell environment for managing resources on AWS. You can access it through the AWS Management Console.

Create a Terraform configuration file: Create a new file with a .tf extension (e.g., main.tf) and define the necessary resources and configurations.

Install Terraform on AWS Cloud Shell: Run the following commands in the Cloud Shell to install Terraform:

commands — Install Terraform

Download the Terraform files: Create a directory and navigate to it, then download and unzip the Terraform files using the following commands:

Edit the Terraform files: Open the main.tf file and modify the variables according to your requirements.

main.tf

Deploy the EC2 VM using Terraform: Navigate to the terraform directory and run the following commands:

Terraform Commands — Init, Plan & Apply to create resources
Rsources Created on AWS

Connect to your EC2 instance via SSH: Obtain the public IP address of your EC2 instance and use SSH to connect to it.

Install Ansible in the EC2 VM: Run the following commands in the EC2 instance to install Ansible:

Install Ansible in the EC2 VM
Install Completed — Ansible

Download the Ansible playbooks: Navigate back to the final_project directory and download and unzip the Ansible playbooks using the following commands:

Edit the Ansible file parameters: Open the group_vars/all.yml file and update the variables mentioned (magento_domain, server_hostname, repo_api_key, repo_secret_key) with the appropriate values.

all.yml file- update domain, server hostname, rep_api_key and repo_secret key

Deploy the stack of tools using Ansible: Run the following command to execute the Ansible playbook:

Excute command — Ansible Playbook
Ansible Playbook — Executed Successfully.

Test the E-commerce website: Copy the EC2 Public IP address and paste it into the browser. It may take a few minutes for the website to become available.

ecommerce — Instance Public IP Copy in Browser
Display — Default e-commerce website

Set up the e-commerce website: Access the secure location using the following URL: http://<EC2_PUBLIC_IP>/securelocation. Use the provided Magento Admin credentials to log in.

Magento- e- commerce ->Login- With appropriate credentials
Magento Admin — Dashboad

Download and personalize the e-commerce website: Download the provided images and follow the instructions to customize the website.

Open the configuration settings for the HTML head of the Default Store View. Ensure that the following changes have been made:

Default page title: The Cloud Bootcamp Store

Header > Logo image: The Cloud Bootcamp logo from images

Magento E-commerce Website- > Download and Personalize

Header > Welcome text: Welcome to The Cloud Bootcamp Store!

Flush the cache to ensure that the changes take effect. You can do this by navigating to Cache Refresh and selecting the option to flush the cache.

Go to the Catalog section and check if “The Cloud Bootcamp T-Shirt” has been added as a product. Ensure that the price is set to 80 and the quantity is 100.

Magento ->Under Catlog- Add New Product

Verify that images have been added for “The Cloud Bootcamp T-Shirt.” Navigate to Images And Videos and check if appropriate images are present.

Magento->Upload Images- For New Product
Magento->Save the changes

Insert a widget to display the Catalog New Products List. Select the Insert Widget option and choose the Widget type: Catalog New Products List. Insert the widget into the Home Page.

Magento->Insert Widget
Magento-> Widget Type — Catalog New Products List
Magento->Save the Widget

Finally, review the overall customization and optimize it if necessary. You can consider the following aspects for optimization:

Magento-> Go to Customer View Section — Under Admin

Visual appeal: Ensure that the logo, welcome text, and product images are visually appealing and aligned with the store’s branding.

Magento-> Home Page- E-commerce Website
Magento-> Browse the Product
Magento- Add to Shopping Cart

By following these steps, and considering the optimization aspects, you can verify if the customization is in place and enhance it further if needed.

--

--

Anurag Chawla
Anurag Chawla

Written by Anurag Chawla

Emerging Technologies - Power Virtual Agents | AI Chatbots | Multi-Cloud & DevOps | UI Technologies - React , Angular | Gaming Technolgies - Unity, XR- AR/VR

No responses yet