From b3f89bbfc0189c773d16d337f428fa960afd3fef Mon Sep 17 00:00:00 2001 From: Peter Lohmann Date: Wed, 18 Dec 2019 13:22:30 +0100 Subject: [PATCH] :star: Optionally enable static website hosting --- README.md | 6 ++++++ main.tf | 7 +++++++ variables.tf | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/README.md b/README.md index de86051..ef54776 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,9 @@ to it Account numbers of other AWS accounts which should get read access to the bucket - and *subscribe* access to its SNS topic +`read_prefix` (str)\ +Prefix of object keys to restrict cross-account reads to + `write_accounts` (list(str))\ Account numbers of other AWS accounts which should get write access to the bucket @@ -52,3 +55,6 @@ to transition / expire old objects in the bucket Whether to protect the bucket (and the SNS topic if created) from deletion by creating a restrictive [bucket policy](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-bucket-policy.html) + +`enable_website` (bool, Default: `false`)\ +Whether to make the bucket available as a static website diff --git a/main.tf b/main.tf index 67847a5..9cabdd0 100644 --- a/main.tf +++ b/main.tf @@ -26,6 +26,13 @@ resource "aws_s3_bucket" "this" { force_destroy = true request_payer = "BucketOwner" + dynamic "website" { + for_each = var.enable_website ? [{index_document = "index.html"}] : [] + content { + index_document = website.value.index_document + } + } + dynamic "lifecycle_rule" { for_each = var.lifecycle_rules content { diff --git a/variables.tf b/variables.tf index 4e457de..44163c5 100644 --- a/variables.tf +++ b/variables.tf @@ -58,3 +58,9 @@ variable "protect" { type = bool default = false } + +variable "enable_website" { + description = "Whether to make the bucket available as a static website" + type = bool + default = false +}