5. You want to create multiple AWS IAM users from a list, but only for those names that start with "dev". Which meta-argument combination best controls this behavior?
hard
A. Use count with a conditional expression filtering names starting with "dev"
B. Use for_each with a filtered map of users starting with "dev"
C. Use depends_on to wait for user list creation
D. Use lifecycle with ignore_changes on user names
Solution
Step 1: Understand filtering with meta-arguments
for_each allows iterating over a map or set, so filtering the list first and passing it to for_each creates resources only for desired items.
Step 2: Why not count or depends_on
count with condition is less flexible and can cause index issues; depends_on controls order, not filtering; lifecycle controls resource changes, not creation filtering.
Final Answer:
Use for_each with a filtered map of users starting with "dev" -> Option B
Quick Check:
for_each with filtered map controls selective resource creation [OK]
Hint: Use for_each with filtered map for selective resources [OK]
Common Mistakes:
Using count with condition causing resource indexing errors
Misusing depends_on for filtering
Confusing lifecycle with creation control
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.