You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -197,6 +197,9 @@ The following inputs can be used as `step.with` keys
197
197
| `aws_site_cdn_aliases` | String | Extra CNAMEs (alternate domain names), if any, for this distribution. Defaults to defined domain if none passed. (See note). |
198
198
| `aws_site_cdn_custom_error_codes` | JSON | Custom error codes to define in CDN. Like `[{\"error_caching_min_ttl\":\"0\",\"error_code\":\"403\",\"response_code\":\"200\",\"response_page_path\":\"/index.html\"}]`. See [this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudfront_distribution.html#custom-error-response-arguments). |
199
199
| `aws_site_cdn_response_headers_policy_id` | String | Comma separated list of response headers policy IDs for CloudFront. Eg. `Managed-CORS-with-preflight-and-SecurityHeadersPolicy` is `eaab4381-ed33-4a86-88ca-d9558dc6cd63`. |
200
+
| `aws_site_cdn_min_ttl` | Number | Minimum TTL (in seconds) for CloudFront cache. Default is `0`. |
201
+
| `aws_site_cdn_default_ttl` | Number | Default TTL (in seconds) for CloudFront cache. (CloudFront default is `86400` - 24 hours), but defaults to `0` (disabled) |
202
+
| `aws_site_cdn_max_ttl` | Number | Maximum TTL (in seconds) for CloudFront cache. (CloudFront default is `31536000` 365 days), but defaults to `0` (disabled). |
200
203
<hr/>
201
204
<br/>
202
205
@@ -243,6 +246,23 @@ If that's the case, `aws_site_cdn_aliases` should be set to: `site.bitovi.com,si
243
246
244
247
If they alternate domain names are child of the same domain, you can use a root cert for both.
245
248
249
+
## CloudFront Caching
250
+
251
+
For deployments or applications that rotate files on each deployment, the default cache TTL settings help ensure a smooth transition between deployments:
252
+
253
+
- **`aws_site_cdn_default_ttl`**: Set to 24 hours (86400 seconds)
254
+
- **`aws_site_cdn_max_ttl`**: Set to 365 days (31536000 seconds)
255
+
256
+
These settings allow CloudFront to cache files even after they've been deleted from S3, reducing 404 errors during deployment transitions. Files remain cached at edge locations for the specified TTL period, giving users time to gradually transition to the new version.
257
+
258
+
Example with custom TTL settings:
259
+
```yaml
260
+
aws_site_cdn_enabled: true
261
+
aws_site_cdn_min_ttl: 0
262
+
aws_site_cdn_default_ttl: 172800 # 48 hours
263
+
aws_site_cdn_max_ttl: 604800 # 7 days
264
+
```
265
+
246
266
## Contributing
247
267
We would love for you to contribute to [bitovi/github-actions-deploy-static-site-to-aws](https://github.com/bitovi/github-actions-deploy-static-site-to-aws).
248
268
Would you like to see additional features? [Create an issue](https://github.com/bitovi/github-actions-deploy-static-site-to-aws/issues/new) or a [Pull Requests](https://github.com/bitovi/github-actions-deploy-static-site-to-aws/pulls). We love discussing solutions!
Copy file name to clipboardExpand all lines: action.yaml
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -76,6 +76,15 @@ inputs:
76
76
aws_site_cdn_response_headers_policy_id:
77
77
description: 'Comma separated list of response headers policy IDs for CloudFront. Eg. Managed-CORS-with-preflight-and-SecurityHeadersPolicy is 67f7725c-6f97-4210-82d7-5512b31e9d42.'
78
78
required: false
79
+
aws_site_cdn_min_ttl:
80
+
description: 'Minimum TTL (in seconds) for CloudFront cache. Default is 0.'
81
+
required: false
82
+
aws_site_cdn_default_ttl:
83
+
description: 'Default TTL (in seconds) for CloudFront cache. Default is 86400 (24 hours).'
84
+
required: false
85
+
aws_site_cdn_max_ttl:
86
+
description: 'Maximum TTL (in seconds) for CloudFront cache. Default is 31536000 (365 days).'
description="Minimum amount of time (in seconds) that objects stay in CloudFront cache before CloudFront forwards another request to the origin. Default is 0."
72
+
type=number
73
+
default=0
74
+
}
75
+
76
+
variable"aws_site_cdn_default_ttl" {
77
+
description="Default amount of time (in seconds) that an object is in a CloudFront cache before CloudFront forwards another request to the origin. Default is 86400 (24 hours)."
78
+
type=number
79
+
default=0
80
+
}
81
+
82
+
variable"aws_site_cdn_max_ttl" {
83
+
description="Maximum amount of time (in seconds) that an object is in a CloudFront cache before CloudFront forwards another request to the origin. Default is 31536000 (365 days)."
84
+
type=number
85
+
default=0
86
+
}
87
+
70
88
variable"aws_r53_domain_name" {
71
89
description="root domain name without any subdomains"
0 commit comments