Skip to content
This repository has been archived by the owner on Jun 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #3 from MeteoGroup/enable_s3_website
Browse files Browse the repository at this point in the history
⭐ Optionally enable static website hosting
  • Loading branch information
Peter Lohmann authored Dec 18, 2019
2 parents 8c05fae + b3f89bb commit 73db4b1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
7 changes: 7 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 73db4b1

Please sign in to comment.