CI/CD Pipeline to Amazon ECS Fargate

Source-triggered CodePipeline with CodeBuild build and image-scan stages, S3 artifacts, ECR, a manual approval gate, and CloudFormation deployment to a private Fargate service behind an ALB.

Explore diagram

Explore on mobile. Create and edit manually or with AI on a computer.

AWS CI/CD pipeline architecture diagram from GitHub through CodePipeline, CodeBuild, image scanning, ECR, manual approval, CloudFormation, and ECS FargateExplore diagram

AWS CI/CD pipeline architecture diagram from GitHub through CodePipeline, CodeBuild, image scanning, ECR, manual approval, CloudFormation, and ECS Fargate. Open the image to explore this ready-made diagram.

Overview

A GitHub push starts AWS CodePipeline, which uses CodeBuild to build and test the application before storing a scanned container image in Amazon ECR and deployment artifacts in Amazon S3. A manual approval gate controls promotion. AWS CloudFormation then deploys the release to an ECS Fargate service behind an Application Load Balancer.

Components

  • Source: A GitHub push starts the pipeline; developers also act as release approvers.
  • Delivery: CodePipeline sequences build, image scan, approval, and deploy stages.
  • Artifacts: S3 holds build artifacts and pipeline state; ECR holds scanned, tagged images.
  • Runtime: CloudFormation updates the Fargate service, which serves traffic behind an ALB.
  • Approval: A CodePipeline manual approval action pauses deployment and sends approver notifications through SNS.

Delivery Flow

  1. A developer pushes to GitHub, triggering CodePipeline.
  2. CodeBuild compiles and tests, then the scan stage promotes the image to ECR and artifacts to S3.
  3. The pipeline notifies approvers and waits at the manual approval gate.
  4. On approval, CloudFormation deploys the new task definition to the Fargate service.
  5. The ALB routes traffic to the updated service.

Customize First

  • Add blue/green or canary deployment with CodeDeploy and automated rollback alarms.
  • Insert integration/e2e test stages and enforce image-scan severity gates.
  • Parameterize per-environment (staging/prod) pipelines and cross-account deploy roles.

Related AWS guides

Use these practical explanations to compare services, failure boundaries, and operating tradeoffs before adapting the architecture.

Design rationale

Decisions that shape this architecture

1

Promote an immutable image

Build and scan the image once, store it in ECR, and deploy the approved digest. Rebuilding between environments can produce a different artifact than the one that passed tests.

2

Keep deployment configuration in code

CloudFormation applies the task definition and service changes through a reviewable, repeatable contract instead of console edits.

3

Place approval after evidence exists

Approvers should see test, scan, and staging evidence before promoting the release. Approval without useful evidence becomes ceremony rather than risk control.

Before production

Operational checks

Fail the pipeline on agreed vulnerability severity and policy violations.

Run integration tests against the same image digest intended for production.

Configure deployment rollback from health and application alarms.

Use separate roles and accounts for build, artifact, and production deployment access.

Scope and tradeoffs

What this diagram does not solve

The starter uses a manual production gate

High-confidence teams may prefer automated canary analysis. Regulated or high-impact environments may require additional approval and evidence controls.

A rolling deployment is not always enough

Add CodeDeploy blue/green or canary behavior when rollback speed, connection draining, and pre-traffic validation are important.

Common questions

Frequently asked questions

Why store images in ECR and artifacts in S3?

ECR is the container image registry. S3 stores pipeline artifacts such as packaged templates, manifests, reports, and intermediate build outputs.

Should the pipeline deploy the latest image tag?

No. Deploy a versioned tag or digest so the released artifact is immutable, auditable, and identical to the artifact that passed validation.

How can this pipeline support multiple environments?

Promote one immutable artifact through environment-specific stages and roles, with separate configuration, tests, approvals, and deployment targets.

Keep exploring

Explore the library
Amazon ECS Fargate web architecture diagram with CloudFront, WAF, a multi-AZ ALB, private Fargate tasks, RDS, and ElastiCache
Containersadvanced

Containerized Web Service with Amazon ECS and Fargate

This architecture shows the running service: a protected global edge, a Multi-AZ load balancer, private Fargate tasks, and managed data services. It is a useful starting point for teams outgrowing a single server or a function-based API; deployment, credential delivery, and monitoring can be added around that request path.

Explore the architecture
AWS web platform with Route 53, CloudFront, WAF, ALB, multi-AZ web and API fleets, zonal NAT gateways, ElastiCache, and distinct RDS primary, standby, and read replica
Web Applicationadvanced

Production-Grade Highly Available Web Platform on AWS

This reference expands the three-tier baseline with a global edge, separate scaling domains, caching, read scaling, and private egress. Secrets management, backup policies, and observability are important additions to design around the visible application path.

Explore the architecture
AWS batch inference diagram with EventBridge, Step Functions, private VPC compute, job definitions, ECR, SageMaker model registry, and S3 inputs and predictions
ML Platformadvanced

Machine Learning Batch Inference Platform on AWS

This architecture runs scheduled or on-demand scoring as a durable workflow. Step Functions coordinates jobs, AWS Batch supplies container compute, ECR pins the runtime, an approved SageMaker model supplies the artifact, and S3 preserves inputs and predictions.

Explore the architecture

Ready-made AWS diagram

Explore this AWS architecture

Open the diagram from this guide and explore how it works. Create and edit manually or with AI on a computer.

Explore diagram