Enforcing EC2 Tagging at Launch with IAM Policy Conditions
A security engineer notices that an IAM user has permissions to launch EC2 instances but the engineer wants to ensure that all new instances are automatically tagged with the creator's user name. What is the most efficient way to enforce this?
Quick Answer
This works because IAM policy conditions can be evaluated against the specific values in a request, and aws:RequestTag/Creator checks the tag value the caller is attempting to apply, while the aws:username policy variable resolves dynamically to whichever IAM user is actually making the call. Combining them means the policy denies the RunInstances request unless the Creator tag exactly matches the calling user's own username, forcing correct, automatic attribution the moment the instance is created rather than relying on the user to type it in accurately. The reason this beats the alternatives is about timing: CloudTrail only records what happened after the fact, so it can tell you who launched an instance without a tag, but cannot stop that launch; AWS Config rules can detect untagged resources after they exist and even trigger remediation, but that is inherently reactive; and while an SCP can deny actions missing a required tag key, SCPs operate at the organization or account level, are not designed to validate that a tag's value matches a specific caller, and suit account-wide guardrails rather than per-user enforcement. Whenever a question asks for the most efficient way to enforce that a tag value matches something about the specific caller, look for an IAM policy condition referencing a dynamic variable like aws:username, since that enforces correctness at the moment of the request rather than after the fact.
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
✓
Add an IAM policy to the user that uses a condition key 'aws:RequestTag/Creator' with a value '${aws:username}'.
Using an IAM policy with a condition key 'aws:RequestTag/Creator' set to '${aws:username}' ensures that any EC2 RunInstances request must include the tag 'Creator' with the IAM user's name, otherwise the request is denied. This enforces tagging at the time of instance creation. Option A (CloudTrail) only provides auditing, not enforcement. Option C (AWS Config rules) can detect and remediate after creation but is less efficient than proactive enforcement. Option D (SCP) can deny based on missing tags but cannot enforce the tag value to match the user name; also, SCPs are used for account-wide policies, not per-user.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Use AWS CloudTrail to monitor and alert on untagged instances.
Why it's wrong here
CloudTrail only logs, it does not enforce tagging.
- ✓
Add an IAM policy to the user that uses a condition key 'aws:RequestTag/Creator' with a value '${aws:username}'.
Why this is correct
This condition forces the user to include the tag with their username.
- ✗
Use AWS Config rules to automatically tag resources after creation.
Why it's wrong here
This is reactive and may allow untagged resources temporarily.
- ✗
Create an SCP that denies EC2:RunInstances unless the request includes a 'Creator' tag with the user name.
Why it's wrong here
SCPs cannot enforce tagging; they can only deny requests that lack required tags.
Go deeper
Related to this question
About these practice questions
One of 376 original SCS-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on SCS-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. A security engineer needs to ensure that all EC2 instances launched in a development account are tagged with a cost center. What is the most effective way to enforce this?
medium- A.Use AWS Config to detect untagged instances and send alerts
- B.Use AWS Systems Manager to tag instances after launch
- C.Create a tag policy in AWS Organizations requiring the cost center tag
- ✓ D.Use an IAM policy that denies ec2:RunInstances unless the request includes the cost center tag
Why D: Using an IAM policy with a condition key (e.g., `aws:RequestTag`) that denies `ec2:RunInstances` unless the `cost center` tag is specified in the API call enforces tagging at launch time. This prevents any untagged instance from being created, providing proactive enforcement rather than reactive detection or remediation.
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This SCS-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 SCS-C02 exam.