Skip to content

Commit

Permalink
Support cache behaviors (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
osterman authored Dec 13, 2017
1 parent 0a66af5 commit 198d276
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ aws acm request-certificate --domain-name example.com --subject-alternative-name
| `aliases` | `[]` | List of aliases. CAUTION! Names MUSTN'T contain trailing `.` | Yes |
| `custom_error_response` | `[]` | List of one or more custom error response element maps | No |
| `allowed_methods` | `["*"]` | List of allowed methods (e.g. ` GET, PUT, POST, DELETE, HEAD`) for AWS CloudFront | No |
| `cached_methods` | `["GET", "HEAD"]` | List of cached methods (e.g. ` GET, PUT, POST, DELETE, HEAD`) | No |
| `cached_methods` | `["GET", "HEAD"]` | List of cached methods (e.g. ` GET, PUT, POST, DELETE, HEAD`) | No |:
| `cache_behavior` | `[]` | List of cache behaviors to implement | No |
| `comment` | `Managed by Terraform` | Comment for the origin access identity | No |
| `compress` | `false` | Compress content for web requests that include Accept-Encoding: gzip in the request header | No |
| `default_root_object` | `index.html` | Object that CloudFront return when requests the root URL | No |
| `enabled` | `true` | State of CloudFront | No |
| `forward_cookies` | `none` | Forward cookies to the origin that is associated with this cache behavior | No |
| `forward_cookies_whitelisted_names` | `[]` | List of forwarded cookies | No |:
| `forward_headers` | `[]` | Specify headers that you want CloudFront to vary upon for this cache behavior. Specify `*` to include all headers. | No |
| `forward_query_string` | `false` | Forward query strings to the origin that is associated with this cache behavior | No |
| `geo_restriction_locations` | `[]` | List of country codes for which CloudFront either to distribute content (whitelist) or not distribute your content (blacklist) | No |
Expand Down
5 changes: 4 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ resource "aws_cloudfront_distribution" "default" {
query_string = "${var.forward_query_string}"

cookies {
forward = "${var.forward_cookies}"
forward = "${var.forward_cookies}"
whitelisted_names = ["${var.forward_cookies_whitelisted_names}"]
}
}

Expand All @@ -97,6 +98,8 @@ resource "aws_cloudfront_distribution" "default" {
max_ttl = "${var.max_ttl}"
}

cache_behavior = "${var.cache_behavior}"

restrictions {
geo_restriction {
restriction_type = "${var.geo_restriction_type}"
Expand Down
13 changes: 12 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,13 @@ variable "forward_headers" {
}

variable "forward_cookies" {
default = "none"
description = "Specifies whether you want CloudFront to forward cookies to the origin. Valid options are all, none or whitelist"
default = "none"
}

variable "forward_cookies_whitelisted_names" {
description = "List of forwarded cookie names"
default = []
}

variable "price_class" {
Expand Down Expand Up @@ -185,3 +191,8 @@ variable "parent_zone_id" {
variable "parent_zone_name" {
default = ""
}

variable "cache_behavior" {
description = "List of cache behaviors to implement"
default = []
}

0 comments on commit 198d276

Please sign in to comment.