DVA-C02 Deployment Practice Question
A developer is creating a CloudFormation template to deploy a microservices architecture. The template includes an Amazon ECS service with an Application Load Balancer. The developer wants to ensure that the load balancer is created before the ECS service. How should the developer achieve this?
⚠ Common exam trap
Test-takers frequently assume the order of resource definitions in the template dictates creation order, but CloudFormation only guarantees order through explicit DependsOn or implicit dependencies from intrinsic functions like Ref or Fn::GetAtt used in resource properties.
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 DependsOn attribute in the ECS service resource to reference the load balancer.
The DependsOn attribute explicitly defines resource creation order in AWS CloudFormation. By setting DependsOn on the ECS service to reference the load balancer, the template ensures the load balancer is fully created before the ECS service attempts to register with it, preventing deployment failures due to missing dependencies.
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 the Ref function in the ECS service to reference the load balancer.
Why it's wrong here
Using the Ref function in the ECS service to reference the load balancer primarily retrieves the logical ID or a default attribute (like ARN for some resources) of the load balancer. While CloudFormation often infers implicit dependencies from Ref to ensure the referenced resource exists before its value is needed, it does not explicitly guarantee that the referenced resource is fully provisioned and operational before the dependent resource begins its creation. For critical operational readiness, DependsOn is more explicit and reliable.
- ✓
Use the DependsOn attribute in the ECS service resource to reference the load balancer.
Why this is correct
The DependsOn attribute explicitly defines a creation, update, and deletion dependency between resources. By adding DependsOn: MyLoadBalancer to the ECS service resource, CloudFormation is instructed to ensure that MyLoadBalancer is completely provisioned and stable before it attempts to create or update the ECS service. This guarantees the load balancer is ready to accept registrations from ECS tasks, preventing deployment failures due to timing issues.
- ✗
Define the load balancer before the ECS service in the template.
Why it's wrong here
The order in which resources are declared within a CloudFormation template's Resources section is purely for human readability and template organization. CloudFormation's engine determines the actual resource creation order based on an internal dependency graph, which is primarily built from explicit DependsOn attributes and implicit dependencies inferred from intrinsic functions like Ref or Fn::GetAtt. Without explicit instructions, the engine may attempt concurrent creation or an arbitrary order, leading to potential race conditions.
- ✗
Use the Fn::GetAtt function to reference the load balancer.
Why it's wrong here
The Fn::GetAtt function is used to retrieve a specific attribute value from a resource, such as the DNSName or CanonicalHostedZoneName of a load balancer. While using Fn::GetAtt creates a data dependency, ensuring the attribute value is available when needed, it does not explicitly enforce the creation order or guarantee that the referenced resource is fully operational before the dependent resource starts. For strict operational sequencing, DependsOn is the appropriate mechanism.
Go deeper
Related to this question
About these practice questions
Courseiva writes every DVA-C02 question from scratch — 1,135 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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 DVA-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 DVA-C02 exam.