DOP-C02 Configuration Management and IaC Practice Question
A developer is writing an AWS CloudFormation template to create an Amazon S3 bucket. The bucket name must be unique across all AWS accounts. Which property should the developer use to ensure the name is unique?
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
✓
Omit the BucketName property so CloudFormation generates a unique name.
Omit the BucketName property so CloudFormation generates a unique name. Amazon S3 bucket names must be globally unique across all AWS accounts. If you specify a custom BucketName, you must ensure its uniqueness yourself, which is error-prone. By omitting BucketName, CloudFormation automatically generates a unique name that includes a random suffix, guaranteeing global uniqueness. Option A (DeletionPolicy) controls what happens when the stack is deleted, not naming. Option B (setting BucketName to a unique value via parameter) still requires manual uniqueness and is not a property that ensures uniqueness automatically. Option C (UpdateReplacePolicy) controls replacement behavior on updates, not naming. Therefore, omitting BucketName is the simplest way to ensure a unique name.
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 DeletionPolicy attribute to retain the bucket.
Why it's wrong here
The DeletionPolicy attribute is a stack-level lifecycle policy that determines the fate of the resource when the entire stack is deleted—Retain preserves the bucket after stack teardown, Snapshot captures its state, and Delete removes it. It operates on an already-created physical resource and has absolutely no influence over how CloudFormation names the bucket during initial creation. Bucket naming is driven solely by the BucketName property: if omitted, CloudFormation auto-generates a unique name, but DeletionPolicy never enters that decision. Therefore, this approach cannot prevent the naming conflict the developer is trying to solve.
- ✗
Set the BucketName property to a unique value using a parameter.
Why it's wrong here
Setting BucketName to a parameter value delegates the uniqueness problem to the user—CloudFormation will not validate or alter the provided value, so the parameter must already be globally unique or the bucket creation fails with a BucketAlreadyExists or BucketAlreadyOwnedByYou error. Even if a parameter is used, the same value can be reused across different stacks or accounts, causing collisions, and it requires the developer to manually devise a naming scheme (e.g., appending random strings) rather than letting CloudFormation handle uniqueness automatically. This merely shifts the burden without providing any guarantee, making it no more robust than hardcoding a static name.
- ✗
Use the UpdateReplacePolicy attribute to control replacement.
Why it's wrong here
The UpdateReplacePolicy attribute controls what happens to the original physical resource when CloudFormation must replace it during a stack update because of a property change that requires a new resource. It does not affect the naming of the bucket at creation time, nor does it influence the generation of unique identifiers. Its purpose is to dictate whether the old bucket is retained, snapshotted, or deleted when a replacement occurs—not to resolve naming collisions. Since the developer's scenario is about the initial creation of a bucket with a unique name, this update-time policy is entirely irrelevant.
- ✓
Omit the BucketName property so CloudFormation generates a unique name.
Why this is correct
When the BucketName property is omitted from an S3 bucket resource, CloudFormation automatically generates a globally unique name by combining the stack name with a random suffix (e.g., my-stack-s3bucket-1a2b3c4d5e6f). This generated name guarantees uniqueness across all AWS accounts and regions, because the random component virtually eliminates collision risk. CloudFormation then exposes this generated name through the Ref function and the resource's physical ID, allowing other resources to reference it without ever needing to know the exact value beforehand. This is the simplest and most reliable way to avoid bucket-name conflicts without manual input.
Quick reference
AWS S3 Storage Class Comparison
| Storage Class | Min Duration | Retrieval | Use Case |
|---|---|---|---|
| S3 Standard | None | Immediate | Frequently accessed data |
| S3 Standard-IA | 30 days | Immediate | Infrequent access, rapid retrieval |
| S3 One Zone-IA | 30 days | Immediate | Non-critical infrequent data |
| S3 Intelligent-Tiering | None | Immediate–hours | Unknown or changing access patterns |
| S3 Glacier Instant | 90 days | Milliseconds | Archive with instant retrieval |
| S3 Glacier Flexible | 90 days | Minutes–hours | Archive, flexible retrieval |
| S3 Glacier Deep Archive | 180 days | Hours | Long-term compliance archive |
Go deeper
Related to this question
About these practice questions
Courseiva writes every DOP-C02 question from scratch — 1,298 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 DOP-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 DOP-C02 exam.