Bird
0
0

You wrote this Terraform code to enable versioning but it does not work as expected:

medium📝 Debug Q14 of 15
AWS - S3 Fundamentals
You wrote this Terraform code to enable versioning but it does not work as expected:
resource "aws_s3_bucket" "mybucket" {
  bucket = "mybucket"
  versioning = {
    enabled = true
  }
}
What is the error and how to fix it?
Aenabled must be a string "true", not boolean true
BVersioning cannot be enabled during bucket creation
CBucket name must be unique globally
Dversioning should be a block, not an assignment; remove '='
Step-by-Step Solution
Solution:
  1. Step 1: Identify syntax error in versioning block

    The code uses versioning = { ... } which is incorrect syntax for a block.
  2. Step 2: Correct syntax for versioning block

    Versioning must be declared as a block without '=' like versioning { enabled = true }.
  3. Final Answer:

    versioning should be a block, not an assignment; remove '=' -> Option D
  4. Quick Check:

    Blocks use braces without '=' [OK]
Quick Trick: Blocks use braces without '=' sign [OK]
Common Mistakes:
  • Using '=' with blocks
  • Using string instead of boolean for enabled
  • Ignoring bucket name uniqueness errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes