Hand-built servers are fragile: nobody remembers exactly how they were configured, staging differs from production, and disaster recovery is a hope rather than a plan. Infrastructure as code (IaC) fixes this, and Terraform is our default tool for it.
What a reference Magento architecture looks like on AWS
- VPC with public, private and data subnets across multiple AZs.
- Application Load Balancer, WAF and CloudFront.
- Auto Scaling groups or EKS for PHP-FPM / Nginx application nodes.
- Aurora MySQL or RDS, ElastiCache for Redis, OpenSearch Service.
- S3 for media and backups, EFS only where unavoidable.
- Dedicated cron and queue-consumer workers.
Structure your code as modules
infra/
modules/ network/ app/ database/ cache/ search/ observability/
envs/ dev/ staging/ prod/
Small, versioned modules reviewed once and reused across environments keep drift and duplication out.
Remote state and locking
Store state in S3 with versioning and encryption, and use DynamoDB (or the S3 native locking available in recent Terraform versions) so two engineers never apply at once.
CI/CD for infrastructure
- Pull request runs
fmt,validate, tflint and a security scanner (tfsec / Checkov). planoutput is posted to the PR with an Infracost estimate.- Merge to main applies to staging, then production after approval.
Guardrails that prevent expensive mistakes
- Policy as code (OPA / Sentinel) to enforce tags, encryption and approved instance types.
- Service control policies at the organisation level.
- Budget alerts as code, created with the environment.
Disaster recovery you can actually test
When the environment is code, rebuilding in another region is a pipeline run plus data restore. Schedule DR drills and measure real recovery time against your RTO.
Adopting IaC on an existing estate
Do not big-bang it. Import existing resources gradually, start with network and IAM, and freeze manual changes once a layer is codified.
Need this done properly?
Our DevOps team codifies, secures and operates ecommerce infrastructure. Talk to a cloud architect →