L10. Container & Compute Hardening: ECS/EKS Security & Patch Manager
Video generating
Check back soon for the video lesson on Container & Compute Hardening: ECS/EKS Security & Patch Manager
Course outlineLesson 10 of 18
Task roles vs execution roles in ECS, IRSA for pod-level least privilege in EKS, continuous image scanning with ECR and Inspector, and fleet-wide patching automation.
Exam scope: Use the current SCS-C03 guide linked below; this lesson covers the topic rather than the complete exam syllabus.
Two IAM Roles, One ECS Task
ECS tasks are governed by two distinct IAM roles that are easy to confuse and frequently tested. The task execution role is used by the ECS agent itself, for infrastructure-level work like pulling the container image from ECR and writing logs to CloudWatch. The task role is what the application code running inside the container assumes at runtime to call AWS APIs, such as reading from S3 or writing to DynamoDB. Least privilege means scoping the task role tightly to exactly what that one service needs, since it is the role your actual application code exercises against production data.
Pod-Level Least Privilege in EKS
Pods that can reach EC2 Instance Metadata Service (IMDS) may obtain the node role credentials. IAM Roles for Service Accounts (IRSA) associates a Kubernetes service account with an IAM role through an OIDC trust relationship. EKS Pod Identity is another supported way to associate service accounts with IAM roles, using the Pod Identity Agent. Give each workload a narrowly scoped role and restrict pod access to IMDS. IRSA alone does not isolate credentials from the node role if IMDS remains reachable.
Scanning That Never Stops
Amazon ECR enhanced scanning, powered by Amazon Inspector, supports scan-on-push and continuous scanning through repository filters. With continuous scanning selected, it rescans eligible stored container images for OS package and programming-language package vulnerabilities as new CVEs are published, not only at the moment an image is pushed. A vulnerability disclosed six months after an image was pushed and deployed would be missed by a push-time-only scan; continuous scanning keeps checking images within the configured Inspector monitoring duration. Verify repository filters and coverage rather than assuming every image is monitored indefinitely.
Kubernetes-Native Guardrails
Two more Kubernetes controls come up on the exam alongside IRSA and image scanning:
| Control | What it restricts |
|---|---|
| Network policies | Pod-to-pod traffic within the cluster |
| Pod Security Standards / admission controls | Privileged containers, host network access, host path mounts |
Patching the Fleet, Not Just the Image
For EC2-based workloads outside containers, AWS Systems Manager Patch Manager automates OS and application patching across a fleet using patch baselines (which define which patches are approved) and scheduled maintenance windows, removing the need to patch instances by hand one at a time. EC2 Image Builder complements this by automating the creation of hardened, pre-patched "golden" AMIs, so new instances launch already compliant instead of needing Patch Manager to catch them up after the fact. Exam tip: When a scenario says "a pod needs its own scoped permission, not the node's," use IRSA or EKS Pod Identity, depending on the supported workload and question constraints. When it says "catch a CVE published after the image was already deployed," the answer is ECR enhanced scanning, not a one-time push scan.
References
- ECS execution role
- IRSA and metadata isolation
- EKS Pod Identity
- Enhanced scanning configuration
- Kubernetes NetworkPolicy enforcement
- AWS SCS-C03 exam guide
Continue Learning
- ✓ECS separates the task execution role (used by the ECS agent to pull images and write logs) from the task role (used by application code at runtime): least privilege means scoping the task role tightly
- ✓IAM Roles for Service Accounts (IRSA) lets individual EKS pods assume a specific IAM role via their Kubernetes service account, with IMDS access restricted to prevent access to node credentials
- ✓ECR enhanced scanning supports continuous and scan-on-push modes; repository filters and Inspector monitoring duration determine coverage
- ✓Kubernetes network policies restrict pod-to-pod traffic, and Pod Security Standards/admission controls restrict privileged or host-network-access containers
- ✓Systems Manager Patch Manager automates EC2 OS/application patching via patch baselines and maintenance windows; EC2 Image Builder produces pre-hardened golden AMIs so new instances launch already compliant
1. A container application running on EKS needs to read from a specific S3 bucket, but the exam wants the most tightly scoped permission model. What is the best approach?
2. What is the difference between an ECS task execution role and a task role?
3. Why is ECR enhanced scanning (powered by Amazon Inspector) preferred over a one-time scan at image push?