SAP-C02 Continuous Improvement for Existing Solutions Practice Question
A company uses AWS CloudFormation to deploy infrastructure. A recent change to a stack failed because an IAM role name already exists. The company wants to avoid this issue in the future. What should a solutions architect do?
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
✓
Use the Fn::Sub function with a reference to the AWS::StackName in the IAM role name.
Using `Fn::Sub` with `!Ref AWS::StackName` makes the IAM role name unique per stack, preventing naming conflicts when stacks are deployed in the same account. Option A is incorrect because enabling termination protection only prevents accidental deletion, not naming conflicts. Option B is incorrect because a `DeletionPolicy` of `Retain` preserves the resource after stack deletion, but does not influence naming uniqueness; a future stack deployment could still encounter the same name conflict. Option C is incorrect because a custom resource with a Lambda function unnecessarily adds complexity when a simpler built-in function (`Fn::Sub`) serves the purpose.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Enable termination protection on the stack.
Why it's wrong here
Termination protection prevents stack deletion, not naming conflicts.
- ✗
Use a DeletionPolicy of Retain on the IAM role resource.
Why it's wrong here
DeletionPolicy retains the role after stack deletion but does not prevent naming conflicts.
- ✗
Create a custom resource with an AWS Lambda function to generate a random role name.
Why it's wrong here
This adds unnecessary complexity; CloudFormation intrinsic functions suffice.
- ✓
Use the Fn::Sub function with a reference to the AWS::StackName in the IAM role name.
Why this is correct
This ensures unique role names across stacks.
Quick reference
Cloud Service Model Comparison
| Model | You Manage | Provider Manages | Examples |
|---|---|---|---|
| IaaS | OS, runtime, apps, data | Hardware, hypervisor, networking | EC2, Azure VMs, GCP Compute Engine |
| PaaS | Apps and data | OS, runtime, middleware, hardware | Elastic Beanstalk, Azure App Service |
| SaaS | Data and settings only | Everything else | Microsoft 365, Salesforce, Workday |
| FaaS / Serverless | Function code only | Infra, scaling, runtime | Lambda, Azure Functions, Cloud Run |
| CaaS | Containers and apps | Kubernetes, OS, hardware | EKS, AKS, GKE |
Go deeper
Related to this question
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 →
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.