An application instance reads configuration files that a provisioning script writes into an S3 bucket, but nothing in the aws_instance block references the aws_s3_bucket. The practitioner needs Terraform to always create the bucket before the instance, even though no attribute links them. Which change expresses this requirement correctly?
resource "aws_s3_bucket" "config" {
bucket = "app-config-store"
}
resource "aws_instance" "app" {
ami = var.ami_id
instance_type = "t3.small"
}- AAdd depends_on = aws_s3_bucket.config to the aws_instance.app block, passing the bucket as a single reference.
- BAdd depends_on = [aws_s3_bucket.config] to the aws_instance.app block to declare an explicit dependency. Correct
- CAdd a lifecycle block with create_before_destroy = true to the aws_s3_bucket.config so it is provisioned earlier.
- DInterpolate aws_s3_bucket.config.bucket into a tag on the instance so an implicit dependency forms automatically.
Why A is wrong: The intent is right but the syntax is wrong; depends_on takes a list of references in square brackets, so an unbracketed single reference is invalid.
Why B is correct: depends_on states an ordering that Terraform cannot infer from expressions, forcing the bucket to be created before the instance for this hidden runtime relationship.
Why C is wrong: create_before_destroy governs replacement ordering of a single resource, not the relative creation order of two separate resources, so it does not express this dependency.
Why D is wrong: This would work technically by creating a reference, but it forces an artificial attribute link that misrepresents the design when depends_on is the intended tool for hidden dependencies.