Skip to content

Commit

Permalink
Merge pull request #11 from Ibotta/TTSD-6447_redirect-ttl
Browse files Browse the repository at this point in the history
  • Loading branch information
Jdmorrisett authored Feb 4, 2025
2 parents 992cd4c + a530907 commit b4d4d4f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

### `1.2.9`
- Add variable `ttl` to allow setting the min, max, and default cache TTL for Cloudfront.
- Defaults to the original value of "31536000" (1 year).

### `1.2.8`

- Add variable `remove_trailing_slash` to allow removing trailing slash automatically added by S3 to the target URL.
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ No modules.
| <a name="input_remove_trailing_slash"></a> [remove\_trailing\_slash](#input\_remove\_trailing\_slash) | Remove trailing slash automatically added by S3 to the target URL. Conflicts with target\_url. | `map(string)` | `{}` | no |
| <a name="input_source_subdomain"></a> [source\_subdomain](#input\_source\_subdomain) | FQDN of subdomain that we want to redirect from. | `string` | `""` | no |
| <a name="input_target_url"></a> [target\_url](#input\_target\_url) | URL to redirect to | `string` | `null` | no |
| <a name="input_ttl"></a> [ttl](#input\_ttl) | TTL object to hold the TTL values for min, max and default for the record. | <pre>map(object({<br> min = number<br> max = number<br> default = number<br> }))</pre> | <pre>{<br> "default": 31536000,<br> "max": 31536000,<br> "min": 31536000<br>}</pre> | no |

## Outputs

No outputs.

## Changelog

### `1.2.9`
- Add variable `ttl` to allow setting the min, max, and default cache TTL for Cloudfront.
- Defaults to the original value of "31536000" (1 year).

### `1.2.8`

- Add variable `remove_trailing_slash` to allow removing trailing slash automatically added by S3 to the target URL.
Expand Down
6 changes: 3 additions & 3 deletions cloudfront.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ resource "aws_cloudfront_distribution" "redirect" {
target_origin_id = aws_s3_bucket.redirect_bucket.bucket
compress = true

min_ttl = 31536000
max_ttl = 31536000
default_ttl = 31536000
min_ttl = var.ttl.min
max_ttl = var.ttl.max
default_ttl = var.ttl.default

forwarded_values {
query_string = false
Expand Down
20 changes: 17 additions & 3 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ variable "target_url" {

variable "source_subdomain" {
description = "FQDN of subdomain that we want to redirect from."
default = ""
type = string
default = ""
}

variable "allow_overwrite" {
description = "Allow route53 to overwrite the current rule"
default = false
type = bool
default = false
}

variable "remove_trailing_slash" {
Expand All @@ -27,6 +27,20 @@ variable "remove_trailing_slash" {
default = {}
}

variable "ttl" {
description = "TTL object to hold the TTL values for min, max and default for the record."
type = map(object({
min = number
max = number
default = number
}))
default = {
min = 31536000
max = 31536000
default = 31536000
}
}

variable "tags" {
type = map(string)
}
}

0 comments on commit b4d4d4f

Please sign in to comment.