Enterprise applications rarely fail because of business logic—they fail due to fragile deployments, poor observability, and infrastructure that resists automation.

In this post, I’ll walk through how we transformed a legacy CRM and Employee Engagement platform into a cloud-native, containerized, zero-downtime system on AWS, using:

  • Amazon ECS (Fargate)
  • Amazon RDS for MySQL
  • Amazon S3 (frontend hosting)
  • AWS CodePipeline, CodeBuild, CodeDeploy
  • Amazon ECR
  • AWS Secrets Manager
  • Amazon CloudWatch & CloudTrail

This is not just architecture theory—you’ll see how to build and deploy this system step-by-step.

The Problem: Legacy Constraints

The existing system had:

  • 2–3 hour deployments with downtime
  • No CI/CD automation
  • Hardcoded credentials
  • No centralized logging
  • No scalability

The goal was not lift-and-shift, but true cloud-native modernization.

Target Architecture Diagram

Target Architecture Diagram - Modernizing Enterprise CRM with ECS Fargate and End-to-End CI/CD on AWS

Step-by-Step Implementation

1. Containerizing the Application

Sample Dockerfile

DOCKERFILE

FROM node:18
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]

2. Push Image to Amazon ECR

BASH

aws ecr create-repository --repository-name crm-app
aws ecr get-login-password --region ap-south-1 | \
docker login --username AWS --password-stdin <account-id>.dkr.ecr.ap-south-1.amazonaws.com
docker build -t crm-app .
docker tag crm-app:latest <account-id>.dkr.ecr.ap-south-1.amazonaws.com/crm-app:latest
docker push <account-id>.dkr.ecr.ap-south-1.amazonaws.com/crm-app:latest

3. ECS Fargate Task Definition

JSON
{
  "family": "crm-task",
  "networkMode": "awsvpc",
  "requiresCompatibilities": ["FARGATE"],
  "cpu": "1024",
  "memory": "2048",
  "executionRoleArn": "arn:aws:iam::<account-id>:role/ecsTaskExecutionRole",
  "containerDefinitions": [
    {
      "name": "crm-container",
      "image": "<ECR-IMAGE-URI>",
      "portMappings": [
        {
          "containerPort": 3000
        }
      ],
      "secrets": [
        {
          "name": "DB_PASSWORD",
          "valueFrom": "arn:aws:secretsmanager:ap-south-1:<account-id>:secret:crm-db"
        }
      ]
    }
  ]
}

4. Create ECS Cluster (Fargate)

BASH

aws ecs create-cluster --cluster-name crm-cluster

5. Application Load Balancer Setup

  • Public subnets
  • Listener: HTTP/HTTPS
  • Target Group: ECS service

Health check path must be correct (e.g., /health) to avoid deployment failures.

6. CI/CD Pipeline (CodePipeline)

Pipeline Flow:

  • GitHub → Trigger
  • CodeBuild → Build & push Docker image
  • CodeDeploy → Blue/Green deployment

Sample buildspec.yml

YAML

version: 0.2
phases:
pre_build:
commands:
- aws ecr get-login-password --region ap-south-1 | docker login --username AWS --password-stdin $REPO_URI
build:
commands:
- docker build -t crm-app .
- docker tag crm-app:latest $REPO_URI:latest
post_build:
commands:
- docker push $REPO_URI:latest

7. Blue/Green Deployment (CodeDeploy)

  • New ECS task set is created
  • Traffic gradually shifts via ALB
  • Health checks validate deployment
  • Auto rollback on failure

This ensures zero downtime releases

8. Database Setup (Amazon RDS)

  • MySQL (Multi-AZ enabled)
  • Private subnet
  • Security group allows access only from ECS

9. Secrets Management

BASH
aws secretsmanager create-secret \
  --name crm-db \
  --secret-string '{"username":"admin","password":"your-secure-password"}'

Injected into ECS tasks securely—no hardcoding.

“Never use real credentials in CLI examples — use environment variables or a vault reference.”

Observability Setup

  • CloudWatch Logs → application logs
  • CloudWatch Alarms → CPU, memory
  • CloudTrail → API auditing
  • Amazon SNS (Alerts & Notifications) CloudWatch Alarms are configured to publish to an Amazon SNS topic, which routes alerts to the on-call engineering team via email and SMS. This ensures the right people are notified immediately when CPU breaches threshold, memory spikes, or a deployment health check fails — without anyone manually watching dashboards.

Enables faster MTTR and proactive monitoring.

Key Design Decisions

Why Fargate?

As a Presales professional evaluating modernization options with enterprise customers, the decision point I see most often is not Fargate vs EC2 — it’s Fargate vs EKS

Customers often arrive with EKS already in mind — drawn by its flexibility and ecosystem. But for most enterprise web applications and APIs, that flexibility comes at the cost of months of platform engineering. Fargate removes that burden entirely, letting teams focus on shipping features rather than managing cluster nodes. Unless a customer has strong Kubernetes expertise in-house or needs advanced scheduling, Fargate is almost always the faster path to production — and the safer recommendation.

Option Trade-off
EC2 Requires capacity management
EKS High operational overhead
Fargate Serverless, low ops

Fargate is ideal for:

  • Web apps
  • APIs
  • Teams avoiding infra management

Why Blue/Green over In-Place Deployment?

  • In-place deployments are generally simpler to configure and set up — CodeDeploy stops the old version, installs the new one, and restarts. For non-critical internal tools, that simplicity is acceptable. For a CRM handling active user sessions, in-place deployment creates a hard problem: the application is unavailable during the swap window, and there is no fast rollback path if the new version fails.
  • Blue/Green deployment eliminates both risks. The new version is deployed to a fresh task set and validated by ALB health checks before a single user request touches it. Traffic switches in one atomic operation — a listener rule update on the ALB. If anything fails post-switch, rollback is equally instant: point the listener back at the blue environment. No re-deployment, no downtime, no manual intervention.
  • The approximately 5-minute overhead of spinning up a parallel task set is the only cost. For an enterprise CRM where a failed deployment during business hours directly affects customer-facing operations, that trade-off closes in seconds.

Edge Protection & Encryption (AWS WAF + AWS KMS) While the core implementation focuses on network-layer security through VPC segmentation and IAM least-privilege, two additional controls are recommended for production hardening:

  • AWS WAF is placed in front of the Application Load Balancer to protect against common web exploits — SQL injection, XSS, and malicious bot traffic. For a CRM platform handling customer and employee data, this is a non-negotiable layer.
  • AWS KMS is used to encrypt data at rest — both the RDS database and any sensitive artifacts stored in S3. Combined with Secrets Manager for credentials, this eliminates all plaintext sensitive data from the system.

Common Pitfalls (Real Lessons)

1. ALB Health Check Failures

  • Wrong endpoint → deployment rollback
  • ✔ Fix: Always expose /health

2. IAM Misconfiguration

  • ECS task unable to pull secrets
  • ✔ Fix: Attach correct execution role

3. Cold Start Delays

  • Fargate task startup time
  • ✔ Fix: Use minimum running tasks

4. CI/CD Failures

  • Docker push permission issues
  • ✔ Fix: Validate ECR access in CodeBuild role

Cost Considerations

Fargate vs EC2

Factor Fargate EC2
Cost Model Pay-per-use Fixed
Ops Overhead Low High
Control Medium High

For this use case:

  • Fargate reduced ops cost
  • Slightly higher compute cost, but justified by agility

Business Impact

  • Deployment time: 2–3 hours → <10 - 15 minutes
  • Downtime: Zero
  • Manual effort: ↓ 80%
  • Security risk: Eliminated hardcoded secrets

Key Takeaways

  • Containers alone ≠ modernization
  • CI/CD is the real accelerator
  • Blue/Green is essential for enterprise apps
  • Secrets management must be built-in
  • Serverless containers reduce operational burden

Reusability (Starter Checklist)

You can reuse this architecture if you need:

  • Web application modernization
  • DevOps transformation
  • Secure container deployment
  • Zero-downtime releases

Developer Workflow (Day-to-Day Experience)

One of the biggest improvements in this modernization was the developer experience.

Before Modernization

  • Developers manually shared builds with operations teams
  • Deployments required coordinated downtime
  • Debugging issues required accessing servers directly
  • Releases were infrequent and risky

After Modernization

The workflow is now fully automated and developer-driven:

  1. Developer pushes code to GitHub
  2. AWS CodePipeline is triggered automatically
  3. AWS CodeBuild:
    • Builds the application
    • Creates Docker image
    • Runs basic validations
  4. Image is pushed to Amazon ECR
  5. AWS CodeDeploy:
    • Deploys new version using blue/green strategy
    • Shifts traffic gradually via ALB
    • Performs health checks
  6. If validation passes → deployment completes
  7. If failure occurs → automatic rollback

What This Enables

  • Faster releases (multiple per day possible)
  • Safe deployments with rollback built-in
  • Developer ownership of deployments
  • Easy debugging via centralized logs (CloudWatch)
  • Consistent environments using containers

Developers no longer “request deployments”—they trigger them with every commit.

Future Improvements & Enhancements

While the current architecture delivers strong scalability, security, and automation, there are several enhancements that can further improve maturity and efficiency.

1. Infrastructure as Code (IaC)

Current state:

  • Infrastructure partially managed via console/manual setup

Improvement:

  • Use Terraform or AWS CDK to define:
  • ECS services
  • Load balancers
  • RDS
  • CI/CD pipelines

Benefits:

  • Fully reproducible environments
  • Version-controlled infrastructure
  • Faster environment provisioning

2. Observability Maturity

Current:

  • CloudWatch logs and alarms

Enhancements:

  • Distributed tracing using AWS X-Ray
  • Structured logging (JSON format)
  • Business-level metrics (e.g., user actions, transactions)

Benefits:

  • Faster root cause analysis
  • Better performance insights

3. CI/CD Pipeline Enhancements

Improvements:

  • Add automated testing stages:
  • Unit tests
  • Integration tests
  • Security scans
  • Introduce:
  • Manual approval gates (for production)
  • Artifact versioning

Result: More robust and enterprise-grade pipeline

Final Thought on Evolution

Modernization is not a one-time effort—it’s a continuous journey.

This architecture establishes a strong foundation, but true cloud maturity comes from:

  • Continuous optimization
  • Automation expansion
  • Observability improvements
  • Security evolution

The goal is not just to run workloads in the cloud, but to continuously improve how they are built, deployed, and operated.

Author

Rajat Jindal

VP – Presales

AeonX Digital Technology Limited