Automated implementation of E-Commerce System on AWS
Deployed the EC2 instance usingTerraform.
Ansible to automate the process of e-commerce provisioning.
Project Overview
I have worked as Cloud Engineer on this project based on a real-world scenario, where I created and implemented an e-Commerce MVP (Minimum Viable Product) on AWS in an automated way using Terraform and Ansible (Infrastructure as Code — IaC).
I 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 have also used Magento, PHP, MySQL, and Redis to complete this project.
Mission: 👉 The CTO of The Cloud Bootcamp asked us to deploy an e-commerce system in the AWS Cloud in less than 2 hours. We need to validate whether it is a viable product for the market.
Process
I broke up the solution of this process into two parts,
i. Create the environment and deploy EC2 instance in our AWS environment using Terraform. We make sure that security rules of the security groups are also in place. So that the client can access e-commerce website after it gets running.
ii. When EC2 is running, Ansible will automatically install Magento, PHP, MySQL, and Redis inside the host. Or you can say that Ansible installing the software stack in a fully automated way inside the EC2 instance we have created.
First Part of implementation
I have created a free Magento account and downloaded the software so that I can use it whenever we need it. The next step was to signup to download both public and private keys.
I have started provisioning the infrastructure on AWS by opening a cloud shell.
Now, I installed terraform on AWS cloud shell as shown below:
After that, I configured the ‘main.tf’ file by updating VPC and ssh-key
Once the configuration was complete, I deployed the EC2 VM. I ran the following command in this order
- terraform init
-> To initialize the terraform environment - terraform plan
-> To review the execution plan and check for any p - terraform apply
-> To apply the changes and deploy the EC2 VM based on terraform configuration.
If you go to EC2 Console on AWS, you will find that it has created one EC2 instance
Created Security Group:
Second Part of implementation
In this part, I have deployed the software stack using Ansible inside the EC2 instance.
→ Connect to EC2 instance remotely via SSH
For this, I copied the Public IP Address from EC2 Instance shown below:
Next, I opened the Mac terminal and changed to the directory containing the file, ‘sshkey1.pem’, and connected to the EC2 instance by using the following command
Then, I proceeded to install Ansible and downloaded the Ansible playbooks.
I made necessary changes in the all.yml in the groups_vars directory, like values of magento_domain, server_hostname, repo_api_key, and repo_secret_key
Here are the necessary changes I made.
I ran the Ansible Playbook command so that Ansible started deploying software in an automated way. Ansible has completed all the tasks as shown below:
Copied the public IP Address from the EC2 instance shown below
Set up the e-commerce by using the following URL:
http://3.93.36.8/securelocation
I logged on to Magento by using admin credentials
I made a few changes in
- Content Page by uploading logo and welcome messages
- Added item, The Cloud Bootcamp T-Shirt, in the new Product page with Price, Quantities, Images
- Home Pages, Inserted Widget with widget type: Catalog New Products List
On the Home Page, click on the image as shown below
Click Add to Cart in the following image
Click Proceed to Checkout Button as shown below
After entering the Name, Address, and contact information, click the place order button.
The last part was to remove the resources by using destroy command.
Hope you enjoyed reading my hands-on project. Please claps for me, provide feedback and follow me.