Configures an S3 bucket for website hosting with a single routing rule to redirect requests from a specific path.

Terraform Template

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

  error_document {
    key = "error.html"
  }

  index_document {
    suffix = "index.html"
  }

  routing_rule {

    condition {
      key_prefix_equals = "docs/"
    }

    redirect {
      replace_key_prefix_with = "documents/"
    }
  }
}