Skip to content

Commit

Permalink
Merge pull request #2 from eabdelmaqsod/feature/add_custom_error_resp…
Browse files Browse the repository at this point in the history
…once

Feature/add custom error responce
  • Loading branch information
Geartrixy authored Oct 11, 2019
2 parents cea68f2 + db983b7 commit a25f31a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## 0.0.2 (Unreleased)
ENHANCEMENTS:

* Add custom response error referrenced in issue ([#3](https://github.com/zoitech/terraform-aws-cloudfront/issues/3))
* Add default_cache_behavior ( header )
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,20 @@ module "my_cloudfront" {
# Default Cache Behavior Settings
default_cache_behavior_allowed_methods = ["GET", "HEAD"]
default_cache_behavior_cached_methods = ["GET", "HEAD"]
default_cache_behavior_forwarded_values_headers = ["origin"]
target_origin_id = "s3-my-origin-id"
viewer_protocol_policy = "redirect-to-https"
price_class = "PriceClass_100"
# Custom Error Response
custom_error_response = [
{
error_caching_min_ttl = "86400" #Optional
error_code = "404" #Required
response_code = "200" #Optional
response_page_path = "/index.html"} #Optional
]
# Geo Restrictions
restriction_type = "none"
Expand Down
7 changes: 6 additions & 1 deletion cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ resource "aws_cloudfront_distribution" "distribution" {
bucket = "${var.logging_config_bucket}"
prefix = "${var.logging_config_prefix}"
}

aliases = "${var.aliases}" #list

# Custom Error response
custom_error_response = ["${var.custom_error_response}" ] #list

default_cache_behavior {
allowed_methods = "${var.default_cache_behavior_allowed_methods}" #list
cached_methods = "${var.default_cache_behavior_cached_methods}" #list
Expand All @@ -32,6 +35,8 @@ resource "aws_cloudfront_distribution" "distribution" {
cookies {
forward = "none"
}

headers = "${var.default_cache_behavior_forwarded_values_headers}" #list
}

viewer_protocol_policy = "${var.viewer_protocol_policy}"
Expand Down
11 changes: 11 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ variable "default_cache_behavior_cached_methods" {
description = "(Required) - Controls whether CloudFront caches the response to requests using the specified HTTP methods."
}

variable "default_cache_behavior_forwarded_values_headers" {
type = "list"
description = "(Required) - Specifies the Headers, if any, that you want CloudFront to vary upon for this cache behavior. Specify * to include all headers."
}

variable "target_origin_id" {
description = "(Required) - The value of ID for the origin that you want CloudFront to route requests to when a request matches the path pattern either for a cache behavior or for the default cache behavior."
}
Expand Down Expand Up @@ -91,3 +96,9 @@ variable "minimum_protocol_version" {
variable "ssl_support_method" {
description = "Specifies how you want CloudFront to serve HTTPS requests. One of vip or sni-only. Required if you specify acm_certificate_arn or iam_certificate_id. NOTE: vip causes CloudFront to use a dedicated IP address and may incur extra charges."
}

variable "custom_error_response" {
description = "(Optional) - One or more custom error response elements (multiples allowed)."
type = "list"
default = []
}

0 comments on commit a25f31a

Please sign in to comment.