Hardening compute workloads
SCS-C03 · Lesson 9 of 22 · 1:18:01
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the SCS-C03 exam (AWS Certified Security – Specialty). In this lesson: golden images from EC2 Image Builder pipelines with STIG or CIS hardening components, container images, roles instead of keys (instance profiles, Lambda execution roles, ECS task roles and task execution roles, service roles), requiring IMDSv2, fetching secrets at run time, and administrative access with Session Manager or EC2 Instance Connect instead of an open port 22. Includes three original practice questions.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
Built secure from the start
Every instance and every container of the patient app starts from an image. If that image has open ports, default passwords, or old packages, every copy has them too. This lesson covers hardened images, roles for compute workloads, and secure administrative access.
Hardened images
A golden image is a hardened, approved base image that every team must use. EC2 Image Builder builds it with a pipeline: a recipe starts from a parent image, build components install and configure software, test components check the result, and the pipeline distributes the image to the Regions and accounts that need it, on a schedule. For hardening, Amazon provides managed STIG hardening components, and CIS hardening components, from AWS Marketplace, apply the CIS Benchmarks Level 1 in AMI recipes, but container recipes do not support them. Image Builder can also scan each new image with Amazon Inspector, and build in the Systems Manager agent and the CloudWatch agent, so that every instance is managed and monitored from its first boot.
Container images
Container images follow the same rules. Start from a minimal base image, run the application as a user that is not root, and never write secrets into a layer, where anyone who pulls the image can find them. Amazon ECR can scan each image when it is pushed, and Amazon Inspector can keep scanning it, so that new vulnerabilities in old images are found too.
Roles for compute
Compute workloads get their permissions from roles, never from access keys stored on the instance. An EC2 instance gets its role through an instance profile, and the applications on it receive temporary credentials that rotate on their own. A Lambda function uses an execution role, which grants what the function itself can do, for example write logs and get objects from one bucket. For Amazon ECS, the task role gives permissions to the application in the containers, while the task execution role lets ECS pull the image from Amazon ECR, send logs, and fetch secrets. A service role is a role that a service assumes to act on your behalf, such as CloudFormation creating resources, and passing a role to a service needs the iam:PassRole permission.
Metadata and secrets
On EC2, require IMDSv2, the session-oriented version of the instance metadata service: each request needs a token, obtained with a PUT request. This adds defense against open firewalls, reverse proxies, and server-side request forgery, which could otherwise steal the credentials of the instance role. And keep secrets out of images and user data: fetch them at run time from Secrets Manager or Parameter Store.
Administrative access
Administrators still need to reach instances, but port 22 open to the internet is a classic way in. Session Manager, a capability of Systems Manager, opens a shell or a port forward with no open inbound port, no bastion host, and no SSH keys, controlled by IAM policies, and it can log every session to S3 or CloudWatch Logs. EC2 Instance Connect controls SSH with IAM: it pushes a one-time public key to the instance metadata, where it stays for sixty seconds, and CloudTrail logs every connection request. An EC2 Instance Connect Endpoint reaches instances in private subnets over SSH or RDP, without a public IP address, as long as the security group of the instance allows the endpoint.
Recap
Let's recap. Golden images come from Image Builder pipelines, with STIG or CIS hardening components, Inspector scans, and the agents built in. Roles, not keys: instance profiles for EC2, execution roles for Lambda, task roles and task execution roles for ECS, and service roles for services. Require IMDSv2, and fetch secrets at run time. And reach instances with Session Manager or EC2 Instance Connect, never with port 22 open to the internet.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
Every new AMI must follow the CIS Benchmarks Level 1, be scanned for vulnerabilities, and be rebuilt every week with the latest patches, with no manual step. What should the security engineer use?
- An Image Builder pipeline with CIS hardening
- A Systems Manager document run at each launch
- An AWS Config rule on running instances
- A Lambda function that patches each instance
Show the answer
An Image Builder pipeline with CIS hardening
An Image Builder pipeline runs on a schedule, applies the CIS hardening component in its recipe, and scans the image with Inspector. “A Systems Manager document run at each launch” would repeat the hardening at every launch, without a tested image. “An AWS Config rule on running instances” would only detect drift on instances that already run. And “A Lambda function that patches each instance” would patch instances one by one, without a hardened, tested image.
In an ECS task, the application must get objects from one S3 bucket, and ECS must pull the image from a private ECR repository. Which role should carry the S3 permission?
- The task execution role
- The instance profile of the hosts
- The task role
- The service-linked role of ECS
Show the answer
The task role
The task role gives permissions to the application in the containers, so the S3 access belongs there. “The task execution role” is for ECS itself, to pull the image, send logs, and fetch secrets. “The instance profile of the hosts” would give the permission to every task on the host, far beyond one application. And “The service-linked role of ECS” is managed by AWS for ECS itself, not for your application.
Administrators must open a shell on instances in private subnets, with no inbound port, no bastion host, and no SSH keys, and every session must be logged. What should the security engineer use?
- A bastion host in a public subnet
- Systems Manager Session Manager
- Port 22 open to the office IP range
- Instance Connect with public IP addresses
Show the answer
Systems Manager Session Manager
Session Manager needs no inbound port, no bastion, and no SSH keys, access is controlled by IAM, and each session can be logged. “A bastion host in a public subnet” would add a host to patch and to expose. “Port 22 open to the office IP range” would still open an inbound port and need SSH keys. And “Instance Connect with public IP addresses” would need public addresses and an open SSH port.