Terraform module for S3 static website hosting

Terraform module for S3 static website hosting


module "s3_website_bucket" {
  source                   = "terraform-aws-modules/s3-bucket/aws"
  bucket                   = "test.dev.net"
  acl                      = "public-read"
  control_object_ownership = true
  object_ownership         = "BucketOwnerPreferred"
  force_destroy            = false
  block_public_acls        = false
  block_public_policy      = false
  ignore_public_acls       = false
  restrict_public_buckets  = false
  tags                     = var.tags[var.world]

  website = {
    index_document = "index.html"
    error_document = "error.html"
  }

  # Allow public read access
  attach_policy = true
  policy = jsonencode({
    Version = "2012-10-17"
    Statement = [
      {
        Sid       = "PublicReadGetObject"
        Effect    = "Allow"
        Principal = "*"
        Action    = "s3:GetObject"
        Resource  = "arn:aws:s3:::test.dev.net/*"
      },
    ]
  })

}
Enter fullscreen mode

Exit fullscreen mode



Source link
lol

By stp2y

Leave a Reply

Your email address will not be published. Required fields are marked *

No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.