Courseiva
Design Solutions for Organizational ComplexitymediumMultiple ChoiceObjective-mapped

Preventive Control for ECS Task VPC Enforcement Using SCP

A financial services company is migrating its trading platform to AWS. The platform consists of hundreds of microservices deployed in containers using Amazon ECS with Fargate launch type. Each service has its own IAM role for fine-grained permissions. The security team requires that all ECS tasks use a specific VPC (vpc-12345) and cannot run in any other VPC. During a recent audit, it was discovered that some tasks are running in a different VPC (vpc-67890). The solutions architect must implement a preventive control to ensure that ECS tasks only run in the approved VPC. The company uses AWS Organizations and has Service Control Policies (SCPs) in place. What should the solutions architect do?

Quick Answer

The correct answer is to create an SCP that denies ecs:RunTask and ecs:CreateService unless the networkConfiguration.awsvpcConfiguration.subnets belong to the approved VPC. This works because Service Control Policies (SCPs) act as a preventive control at the AWS Organizations level, setting a guardrail that overrides any permissive IAM roles or account-level configurations. On the AWS Certified Solutions Architect Professional SAP-C02 exam, this scenario tests your understanding of how SCPs enforce organization-wide boundaries for resource usage, often appearing as a distractor against IAM policies or VPC endpoints. A common trap is to suggest using IAM conditions alone, but those can be bypassed by other accounts in the organization; SCPs cannot be overridden by account administrators. Memory tip: think of SCPs as the "bouncer at the door" for your entire org—they check the VPC ID on every task launch request before letting it through.

⚠ Common exam trap

Many exam-takers confuse detective controls (AWS Config) with preventive controls (SCPs), or they mistakenly think IAM policies on task roles can control the launch VPC, when in fact the launch VPC is determined by the caller's permissions and SCPs, not the task's IAM role.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Create an SCP that denies ecs:RunTask and ecs:CreateService unless the networkConfiguration.awsvpcConfiguration.subnets are in the approved VPC.

Service Control Policies (SCPs) in AWS Organizations provide a preventive control that applies across all accounts in the organization. By denying ecs:RunTask and ecs:CreateService unless the subnets specified in networkConfiguration.awsvpcConfiguration belong to the approved VPC (vpc-12345), the SCP enforces the VPC constraint at the organization level, preventing any task from launching in a non-approved VPC regardless of individual IAM roles or account configurations.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Tag the approved VPC and use IAM policies to allow ECS actions only when the VPC tag matches.

    Why it's wrong here

    Tag-based IAM policies are not sufficient to prevent task launches in other VPCs.

  • Add an IAM policy to each ECS task role that denies the action if the VPC is not the approved one.

    Why it's wrong here

    Task roles apply to tasks but don't prevent creation of tasks in other VPCs by administrators.

  • Create an SCP that denies ecs:RunTask and ecs:CreateService unless the networkConfiguration.awsvpcConfiguration.subnets are in the approved VPC.

    Why this is correct

    SCPs provide preventive controls at the organization level.

  • Use AWS Config rules to detect tasks running in non-approved VPCs and trigger a remediation action.

    Why it's wrong here

    Config is detective, not preventive.

Visual reference

192.168.1.0 /24 256 addresses (254 usable) 192.168.1.0 /25 Subnet A 128 addr (126 usable) 192.168.1.128 /25 Subnet B 128 addr (126 usable) Borrowing 1 bit from host portion creates 2 subnets (/25)

About these practice questions

This SAP-C02 question is part of Courseiva's 1,660-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

3 more ways this is tested on SAP-C02

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. Which THREE components are required to set up a centralized logging solution for multiple AWS accounts using Amazon S3? (Choose THREE.)

hard
  • A.Amazon CloudWatch Logs subscription filter in each account.
  • B.AWS CloudTrail in the central account only.
  • C.A central S3 bucket in the logging account.
  • D.A bucket policy on the central bucket that grants write access to the source accounts.
  • E.IAM roles in each source account with permissions to write to the central bucket.

Why C: A central S3 bucket in a dedicated logging account is the foundational component for aggregating logs from multiple AWS accounts. This bucket serves as the single destination for all log data, enabling centralized storage, analysis, and retention without exposing logs to individual source accounts.

Variation 2. A company uses AWS Organizations and wants to centrally manage VPC flow logs for all VPCs across all accounts. Which TWO steps are required to achieve this?

medium
  • A.Configure cross-account CloudWatch Logs subscription.
  • B.Create a centralized S3 bucket in the logging account.
  • C.Use VPC Flow Logs with Amazon Kinesis Data Firehose.
  • D.Apply an SCP that requires VPC Flow Logs to be enabled.
  • E.Use AWS Config rules to enable flow logs automatically.

Why B: Centralizing VPC flow logs requires a single S3 bucket in a dedicated logging account to aggregate logs from all accounts. This bucket must have a bucket policy that grants the necessary permissions for the flow log service to write logs from member accounts, enabling centralized storage and management.

Variation 3. A company wants to implement a data perimeter to ensure that only authorized accounts can access their S3 buckets. Which TWO steps should they take?

medium
  • A.Use SCPs to deny access from external accounts.
  • B.Use VPC endpoints with bucket policies.
  • C.Use S3 bucket policy with aws:SourceAccount condition.
  • D.Enable CloudTrail to log access.
  • E.Use AWS Network Firewall.

Why A: SCPs can deny access from external accounts, limiting S3 bucket access to authorized accounts. Option C is correct because S3 bucket policy with aws:SourceAccount condition restricts access to specific AWS accounts. Options B, D, and E are incorrect: B (VPC endpoints with bucket policies) controls network-level access but not account-level; D (CloudTrail logging) only logs access, does not enforce perimeter; E (AWS Network Firewall) is for network traffic inspection, not account-based control.

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This SAP-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the SAP-C02 exam.