A CloudFormation template currently creates an EC2 instance and an RDS instance. You must update the template so CloudFormation always creates the DB instance before it launches the EC2 instance. What change should you make to the template?
Choose an answer
Tap an option to check your answer.
Correct answer: Add a DependsOn attribute to the EC2 resource and set its value to the logical name of the RDS resource..
Why this is the answer
The DependsOn attribute explicitly defines a dependency between resources, ensuring that the specified resource (the RDS instance in this case) is created and stable before the dependent resource (the EC2 instance) is launched. This guarantees the desired order of creation. Reordering resource definitions in the template does not guarantee creation order; CloudFormation processes resources in parallel where possible, unless explicit dependencies are defined. Using a wait condition is for signaling success from an instance, not for enforcing creation order between different resource types. Splitting into separate templates and using StackSets adds unnecessary complexity for a simple dependency and doesn't inherently guarantee the order of creation between stacks without additional orchestration.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed