Skip to content

Magento 2 AWS autoscaling cluster with Terraform and Packer or ImageBuilder. Adobe Commerce Cloud alternative. The best ecommerce infrastructure. Drive more sales online. Transparent billing. Developer-friendly. No hidden bottlenecks.

Notifications You must be signed in to change notification settings

magenx/Magento-2-aws-cluster-terraform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Magento 2 auto scaling cluster with Terraform on AWS cloud only

Deploy a full-scale secure and flexible e-commerce infrastructure based on Magento 2 in a matter of seconds.
Enterprise-grade solution for companies of all sizes, B2B B2C, providing the best customer experience.


AWS Graviton3 Processor - Enabling the best performance in EC2:

aws-graviton3

Amazon EC2 C7g instances upgrade
Best price performance for compute-intensive workloads in Amazon EC2


❓ Why we need Adobe Commerce Cloud alternative:

The biggest issue is that ACC pricing based on GMV % and AOV %, you overpay up to 80%, while the bill between Adobe and AWS remains at a minimum. With this approach, you invest money in the development of a third-party business, but not your own. Why spend so much money without having control over your business in the cloud? Configuring your own infrastructure these days is the most profitable way. You manage the resources, you have a complete overview how it works and you have full control over the money invested in your own infrastructure. At any time you can make changes to both infrastructure and application design without thinking about restrictions, 3rd party platform limitations and unforeseen costs. There are no hidden bills and payments for excess resources, which, as a result, you will not need.

Adobe Commerce Cloud has lots of technical problems due to the fact that many services compete on the same server and share the processor time, memory, network and I/O. Bad architectural solution using monolitic servers, not cloud native solution, that was not made specifically for Magento, but adapted in rush using many wrappers, with manual pseudo scaling and 48 hours to 5 days to accept and deploy new settings.

Obviously, PaaS intermediaries also use AWS Cloud. But concealing its cheap solutions with a marketing, 
trying to hook you up on a dodgy contract and making you pay 10 times more.

AWS cloud account pros:

  • Open source Magento
  • Pay as You Go
  • Transparent billing
  • No draconian contracts
  • No sudden overage charges
  • No hardware restrictions
  • No services limitations
  • No hidden bottlenecks
  • No time waste for support tickets

 

Amazon Web Services offers an ecommerce cloud computing solutions to small and large businesses that want a flexible, secured, highly scalable infrastructure. All the technologies online retailers need to manage growth—instantly. With technologies like automatic scaling compute resources, networking, storage, content distribution, and a PCI-compliant environment, retailers can always provide great customer experiences and capitalize on growth opportunities.

The biggest benefits of using your own AWS Cloud account: Reserved Instances
Reserved Instances provide you with significant savings on your Amazon EC2 costs compared to On-Demand Instance pricing. With Savings Plans, you make a commitment to a consistent usage amount, measured in USD per hour. This provides you with the flexibility to use the instance configurations that best meet your needs and continue to save money.


📖 ECS webstack custom configuration and Auto Scaling management

NGINX is optimized and fully supported on the latest generation of 64-bit ARM Servers utilizing the architecture. PHP using socket connection.

Amazon Linux ECS Optimized ARM, will be supported for the next 5 years. Includes support for ECS and the very latest ARM-based server systems powered by certified 64-bit processors. Develop and deploy at scale. Webstack delivers top performance on ARM.

AWS Systems Manager is an AWS service that you can use to view and control your infrastructure on AWS. Using the Systems Manager console, you can view operational data from multiple AWS EC2 instances and automate operational tasks across your AWS resources. Systems Manager helps you maintain security and compliance. No SSH connections from outside, no need to track passwords and private keys. If you are familiar with shell scripting, yaml and json syntax, create SSM Documents, this is the easiest and most complete way to send instructions to an instance to perform common automated configuration tasks and even run scripts after the instance starts. From default stack optimization to changing any application and service settings.


Developer documentation to read:

https://devdocs.magento.com/
https://docs.aws.amazon.com/index.html
https://www.terraform.io/docs/
https://aws.amazon.com/cloudshell/

The terraform configuration language and all the files in this repository are intuitively simple and straightforward. They are written in simple text and functions that any beginner can understand. Terraform deployment with zero dependency, no prerequisites, no need to install additional software, no programming required.

The idea was to create a full-fledged turnkey infrastructure, with deeper settings, so that any ecommerce manager could deploy it and immediately use it for his brand.


🚀 Deployment into isolated VPC:

  • Login to AWS Console
  • Choose an AWS Region
  • Start AWS CloudShell [fastest way to deploy and debug]
  • Install Terraform:
   sudo yum install -y yum-utils
   sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
   sudo yum -y install terraform
  • Create deployment directory:
  sudo -i
  cd /home
  mkdir magento && cd magento
  • Clone repo:
  git clone -b module https://github.com/magenx/Magento-2-aws-cluster-terraform.git .

❗ Right after terraform apply you will receive email from amazon to approve resources

  • Create backend state.config with your s3 bucket
  • Adjust your settings, edit your [cidr], [brand], [domain], [email]
  • Define either [production] or [developer] environment config

For production deployment make sure to enable deletion protection and backup retention

  • Run:
   terraform init -backend-config=./state.config
   terraform workspace new developer
   terraform plan -out developer.plan.out -no-color 2>&1 > developer.plan.out.txt
   terraform apply

to destroy infrastructure: terraform destroy
resources created outside of terraform must be deleted manually!


Complete setup:

2 ecs autoscaling groups with launch templates configuration 2 ecs target groups for load balancer (varnish)
1 ecr repository 1 load internal balancers with listeners / rules
1 rds/aurora databases multi AZ option
1 opensearch domain for Magento catalog search
2 redis elasticache cluster for sessions and cache
1 rabbitmq broker to manage queue messages
4 s3 buckets for [releases], [media], [system], and [logs] (with access policy)
1 cloudfront distribution with [s3] and [alb vpc origin]
1 s3 endpoin
1 efs file system for shared folders, with mount target per AZ
1 sns topic default subscription to receive email alerts
1 ses user access details for smtp module

resources are grouped into a virtual network, VPC dedicated to your brand
the settings initially imply a large store, and are designed for huge traffic.
services are clustered and replicated thus ready for failover.

  • Deployment into isolated Virtual Private Cloud
  • Autoscaling policy per each group
  • Managed with Systems Manager agent
  • Instance Profile assigned to simplify management
  • Create and use ssm documents and EventBridge rules to automate tasks
  • Simple Email Service authentication for SMTP Magento module
  • CloudWatch agent configured to stream logs
  • All Magento files managed with git only
  • Configuration settings saved in Parameter Store
  • Live shop in production mode / read-only
  • Security groups configured for every service and instances
  • Lambda images optimization with imgproxy
  • Enhanced security in AWS
  • AWS WAF Protection rules

💰 Infracost - shows cloud infrastructure cost estimates:

infracost breakdown --path .
INFO Autodetected 1 Terraform project across 1 root module
INFO Found Terraform project main at directory .

Project: main

OVERALL TOTAL       **$681.87 

──────────────────────────────────
294 cloud resources were detected:
∙ 50 were estimated
∙ 238 were free
∙ 6 are not supported

** conditionally approximate price per month of this infrastructure.


🛠️ Magento 2 development | source code:

https://github.com/magenx/Magento-2-server-installation

Replaced over 200+ useless modules. Minimal Magento 2 package can be extended anytime. modules configuration here: https://github.com/magenx/Magento-2-server-installation/blob/master/composer_replace

Performance and security enhancements

  • Faster backend and frontend from 14% upto 50%
  • Better memory management upto 15%
  • Easy deployments
  • Less dependencies
  • Zero maintenance
  • Low security risks

CI/CD scenario:

Magento 2 deployment pipeline - Fully automated Magento 2 development and deployment pipeline with code review, composer check and pre-release => release workflow | MVP
[ just create your own repository, add your magento files, copy only .github folder to your reposity, it will auto init ]


📧 Contact us for installation and support:

We can launch this project for your store in a short time. Many big retailers have already migrated to this architecture.

  • Open an issue to help make it better.
  • Send a private message on Linkedin

😻 Support the project

This takes time and research. You can use this for free. But its not free to create it. If you are using this project, there are few ways you can support it:

❤️ Opensource

Magento 2 on the AWS Cloud: Quick Start Deployment

About

Magento 2 AWS autoscaling cluster with Terraform and Packer or ImageBuilder. Adobe Commerce Cloud alternative. The best ecommerce infrastructure. Drive more sales online. Transparent billing. Developer-friendly. No hidden bottlenecks.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages