Deployment and CI/CD Concepts on AWS
By the end of this lesson, you'll be able to:
- Trace the path from a code change to a running, updated ECS task
- Explain the rolling-update concept and why old tasks are only replaced after new ones pass health checks
- Explain why configuration should be separated from secrets, and why neither belongs baked into an image
Prerequisites: "AWS Fargate: Serverless Containers"
The deployment path, end to end
Deploying a code change to an ECS-based application follows a repeatable path:
Code change
→ build a new image
→ push the image to ECR
→ register a new task definition revision
→ ECS service deployment
→ new tasks start
→ health checks
→ old tasks replaced
Each step builds directly on this module's earlier lessons: the image-build step (Lesson 1), pushing to ECR (Lesson 2), and the task-definition-revision-to-service-deployment steps (Lesson 3).
Rolling updates: new tasks earn their place before old ones leave
The key idea worth internalizing: a new version's tasks have to prove themselves healthy first, before the old version's tasks are removed. This protects against deploying a broken update straight into production — if the new tasks never become healthy, the old ones can keep serving traffic instead of the deployment silently taking the application down.
Immutability: redeploy, don't patch a running container
This connects directly to Lesson 1's image/container distinction: the correct way to fix or update a running application is to build a new image and deploy it through this same path — not to open a shell into a running container and manually patch it in place. A manual in-place fix disappears the moment that container is replaced (which happens routinely), isn't reflected in the image other tasks were started from, and isn't tracked anywhere the way a new image build and deployment is. Treating deployments as immutable — build once, deploy the same artifact everywhere — is what makes the rolling-update path above actually trustworthy.
Configuration and secrets: what goes in the image, and what never does
Building on Module 7's environment-variable guidance: ordinary, non-sensitive configuration (a table name, a feature flag, a target Region) is a reasonable fit for environment variables passed into a task. Production secrets — database passwords, AWS access keys, API tokens — should never be baked into a container image or committed alongside its source. An image is something that gets stored in ECR, potentially pulled by multiple people and systems, and kept around across versions; a secret baked into it is effectively distributed everywhere that image goes, indefinitely. Where a genuine secret is needed, an appropriate secrets-management mechanism is the right fit conceptually — this lesson doesn't require building one, but the distinction (configuration in environment variables; secrets somewhere designed to protect them) matters just as much here as it did for Lambda.
Task IAM roles, briefly
An ECS task can be given its own IAM role (following Module 2's least-privilege principle, applied here as it was to Lambda's execution role in Module 7) — granting the application code running inside the task only the specific AWS permissions it actually needs, rather than anything broader. This lesson introduces the concept briefly rather than walking through every configuration detail; the important habit is the same one this entire course has repeated: scope permissions to exactly what the workload needs, never anything wider "to be safe."
Noticing a failed deployment: observability
A container's logs (its standard output and standard error) and metrics (CPU, memory, task health) flow into CloudWatch, giving the same kind of observability Module 7 introduced for Lambda. During a deployment specifically, watching these signals is what lets a team notice a failed rollout — new tasks repeatedly failing their health check, for example — quickly, rather than discovering it only once users start reporting problems.
Exercise
A developer needs to fix a bug in a running production container. Using this lesson's immutability principle, explain why opening a shell into the running container and patching it directly is the wrong approach, and describe the correct path the fix should follow instead. Then explain why a database password should never be baked into the container image, even though a table name reasonably can be.
Show hint
For the first part, think about what happens to a manual in-place fix the next time that container is replaced. For the second, think about everywhere an image (and anything baked into it) ends up stored and pulled.
Deployment and CI/CD Concepts on AWS Quiz
My Notes
Log in to keep private notes on this lesson.
Questions about this lesson
No questions yet — be the first to ask.
Log in to ask a question about this lesson.
Summary
A container deployment follows a repeatable path — build a new image, push it to ECR, register a new task definition revision, and let the ECS service roll out new tasks only after they pass health checks, replacing the old ones once the new ones are confirmed healthy — with configuration and secrets deliberately kept out of the image itself, and CloudWatch providing the observability to notice a failed rollout rather than only a user's bug report.