This template sets up an S3 bucket with versioning enabled and creates an S3 object that depends on the versioning configuration.

Terraform Template

resource "aws_s3_bucket" "example" {
  bucket = "yotto"
}

resource "aws_s3_bucket_versioning" "example" {
  bucket = aws_s3_bucket.example.id

  versioning_configuration {
    status = "Enabled"
  }
}

resource "aws_s3_object" "example" {
  bucket = aws_s3_bucket_versioning.example.id
  key = "droeloe"
  source = "example.txt"
}