Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from edithcare/feature/export_bucket_arn_set_ttls
Browse files Browse the repository at this point in the history
added ttls and output for bucket arn.
  • Loading branch information
mgroeningEC authored Apr 17, 2020
2 parents 832302e + c6cb567 commit 54ad606
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
7 changes: 3 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ resource "aws_s3_bucket" "bucket_index" {
}

resource "aws_s3_bucket_object" "index" {
count = var.redirection_url == "" ? 1 : 0
count = var.redirection_url == "" && var.create_index ? 1 : 0
bucket = aws_s3_bucket.bucket_index[0].bucket
key = aws_s3_bucket.bucket_index[0].website[0].index_document
source = local.index_html_path
content_type = "text/html"
etag = filemd5(local.index_html_path)
}

resource "aws_s3_bucket" "bucket_redirect" {
Expand Down Expand Up @@ -102,8 +101,8 @@ resource "aws_cloudfront_distribution" "distribution" {
"HEAD",
]
compress = false
default_ttl = 86400
max_ttl = 31536000
default_ttl = var.cloudfront_default_ttl
max_ttl = var.cloudfront_max_ttl
min_ttl = 0
smooth_streaming = false
target_origin_id = local.distribution_origin_id
Expand Down
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ variable "redirection_url" {
description = "The target URL for redirection. Leave empty for static website hosting configuration."
}

variable "create_index" {
type = bool
default = true
description = "the index.html file is created when this variable is true. Also the index.html file will be overwritten each run, if this variable is true"
}

variable "enable_public_access" {
type = bool
default = false
Expand All @@ -51,3 +57,15 @@ variable "viewer_protocol_policy" {
default = "redirect-to-https"
description = "Viewer protocol policy of the AWS CloudFront distribution default cache behaviour."
}

variable "cloudfront_max_ttl" {
type = number
default = 31536000
description = "The maximum ttl of an Object delivered via Cloudfront"
}

variable "cloudfront_default_ttl" {
type = number
default = 86400
description = "The default ttl of an Object delivered via Cloudfront"
}

0 comments on commit 54ad606

Please sign in to comment.