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
+25-6Lines changed: 25 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,6 +130,21 @@ module "cdn" {
130
130
}
131
131
```
132
132
133
+
### Using an S3 Static Website Origin
134
+
135
+
When variable `website_enabled` is set to `true`, the S3 origin is configured
136
+
as a static website. The S3 static website has the advantage of redirecting
137
+
URL `subdir/` to `subdir/index.html` without requiring a
138
+
[Lambda@Edge function to perform the redirection](https://aws.amazon.com/blogs/compute/implementing-default-directory-indexes-in-amazon-s3-backed-amazon-cloudfront-origins-using-lambdaedge/).
139
+
The S3 static website responds only to CloudFront, preventing direct access to
140
+
S3.
141
+
142
+
In addition to setting `website_enabled=true`, you must also:
143
+
144
+
* Specify at least one `aliases`, like `["example.com"]` or
145
+
`["example.com", "www.example.com"]`
146
+
* Specify an ACM certificate
147
+
133
148
### Generating ACM Certificate
134
149
135
150
```hcl
@@ -176,8 +191,6 @@ Or use the AWS cli to [request new ACM certifiates](http://docs.aws.amazon.com/a
Although AWS Certificate Manager is supported in many AWS regions, to use an SSL certificate with CloudFront, it should be requested only in US East (N. Virginia) region.
|[aws_iam_policy_document.origin](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
247
263
|[aws_iam_policy_document.origin_website](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document)| data source |
248
264
|[aws_s3_bucket.selected](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/s3_bucket)| data source |
@@ -272,7 +288,7 @@ Available targets:
272
288
| <aname="input_cors_max_age_seconds"></a> [cors\_max\_age\_seconds](#input\_cors\_max\_age\_seconds)| Time in seconds that browser can cache the response for S3 bucket |`number`|`3600`| no |
273
289
| <aname="input_custom_error_response"></a> [custom\_error\_response](#input\_custom\_error\_response)| List of one or more custom error response element maps | <pre>list(object({<br> error_caching_min_ttl = string<br> error_code = string<br> response_code = string<br> response_page_path = string<br> }))</pre> |`[]`| no |
274
290
| <aname="input_custom_origin_headers"></a> [custom\_origin\_headers](#input\_custom\_origin\_headers)| A list of origin header parameters that will be sent to origin |`list(object({ name = string, value = string }))`|`[]`| no |
275
-
| <aname="input_custom_origins"></a> [custom\_origins](#input\_custom\_origins)|One or more custom origins for this distribution (multiples allowed). See documentation for configuration options description https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html#origin-arguments| <pre>list(object({<br> domain_name = string<br> origin_id = string<br> origin_path = string<br> custom_headers = list(object({<br> name = string<br> value = string<br> }))<br> custom_origin_config = object({<br> http_port = number<br> https_port = number<br> origin_protocol_policy = string<br> origin_ssl_protocols = list(string)<br> origin_keepalive_timeout = number<br> origin_read_timeout = number<br> })<br> }))</pre> |`[]`| no |
291
+
| <aname="input_custom_origins"></a> [custom\_origins](#input\_custom\_origins)|A list of custom origins (such as apps or S3 websites) for this distribution.<br>See the Terraform documentation for configuration options<br>https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html#origin-arguments| <pre>list(object({<br> domain_name = string<br> origin_id = string<br> origin_path = string<br> custom_headers = list(object({<br> name = string<br> value = string<br> }))<br> custom_origin_config = object({<br> http_port = number<br> https_port = number<br> origin_protocol_policy = string<br> origin_ssl_protocols = list(string)<br> origin_keepalive_timeout = number<br> origin_read_timeout = number<br> })<br> }))</pre> |`[]`| no |
276
292
| <aname="input_default_root_object"></a> [default\_root\_object](#input\_default\_root\_object)| Object that CloudFront return when requests the root URL |`string`|`"index.html"`| no |
277
293
| <aname="input_default_ttl"></a> [default\_ttl](#input\_default\_ttl)| Default amount of time (in seconds) that an object is in a CloudFront cache |`number`|`60`| no |
278
294
| <aname="input_delimiter"></a> [delimiter](#input\_delimiter)| Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. |`string`|`null`| no |
@@ -321,14 +337,15 @@ Available targets:
321
337
| <aname="input_redirect_all_requests_to"></a> [redirect\_all\_requests\_to](#input\_redirect\_all\_requests\_to)| A hostname to redirect all website requests for this distribution to. If this is set, it overrides other website settings |`string`|`""`| no |
322
338
| <aname="input_regex_replace_chars"></a> [regex\_replace\_chars](#input\_regex\_replace\_chars)| Regex to replace chars with empty string in `namespace`, `environment`, `stage` and `name`.<br>If not set, `"/[^a-zA-Z0-9-]/"` is used to remove all characters other than hyphens, letters and digits. |`string`|`null`| no |
323
339
| <aname="input_routing_rules"></a> [routing\_rules](#input\_routing\_rules)| A json array containing routing rules describing redirect behavior and when redirects are applied |`string`|`""`| no |
340
+
| <aname="input_s3_origins"></a> [s3\_origins](#input\_s3\_origins)| A list of S3 origins for this distribution. S3 buckets configured as websites<br>are custom\_origins, not s3\_origins. See the Terraform documentation for<br>configuration options<br>https://www.terraform.io/docs/providers/aws/r/cloudfront_distribution.html#origin-arguments| <pre>list(object({<br> domain_name = string<br> origin_id = string<br> origin_path = string<br> s3_origin_config = object({<br> origin_access_identity = string<br> })<br> }))</pre> |`[]`| no |
324
341
| <aname="input_stage"></a> [stage](#input\_stage)| Stage, e.g. 'prod', 'staging', 'dev', OR 'source', 'build', 'test', 'deploy', 'release' |`string`|`null`| no |
325
342
| <aname="input_tags"></a> [tags](#input\_tags)| Additional tags (e.g. `map('BusinessUnit','XYZ')`|`map(string)`|`{}`| no |
326
343
| <aname="input_trusted_signers"></a> [trusted\_signers](#input\_trusted\_signers)| The AWS accounts, if any, that you want to allow to create signed URLs for private content. 'self' is acceptable. |`list(string)`|`[]`| no |
327
344
| <aname="input_versioning_enabled"></a> [versioning\_enabled](#input\_versioning\_enabled)| When set to 'true' the s3 origin bucket will have versioning enabled |`bool`|`true`| no |
328
345
| <aname="input_viewer_protocol_policy"></a> [viewer\_protocol\_policy](#input\_viewer\_protocol\_policy)| allow-all, redirect-to-https |`string`|`"redirect-to-https"`| no |
329
346
| <aname="input_wait_for_deployment"></a> [wait\_for\_deployment](#input\_wait\_for\_deployment)| When set to 'true' the resource will wait for the distribution status to change from InProgress to Deployed |`bool`|`true`| no |
330
347
| <aname="input_web_acl_id"></a> [web\_acl\_id](#input\_web\_acl\_id)| ID of the AWS WAF web ACL that is associated with the distribution |`string`|`""`| no |
331
-
| <aname="input_website_enabled"></a> [website\_enabled](#input\_website\_enabled)| Set to true to use an S3 static website as origin |`bool`|`false`| no |
348
+
| <aname="input_website_enabled"></a> [website\_enabled](#input\_website\_enabled)| Set to true to use an S3 static website as origin. If you set this to true, see<br>README for more important instructions.|`bool`|`false`| no |
332
349
333
350
## Outputs
334
351
@@ -496,8 +513,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
Copy file name to clipboardExpand all lines: README.yaml
+21-4Lines changed: 21 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,10 @@
1
1
---
2
2
#
3
3
# This is the canonical configuration for the `README.md`
4
-
# Run `make readme` to rebuild the `README.md`
5
-
#
4
+
# To rebuild `README.md`:
5
+
# 1) Make all changes to `README.yaml`
6
+
# 2) Run `make init` (you only need to do this once)
7
+
# 3) Run`make readme` to rebuild this file.
6
8
7
9
# Name of this project
8
10
name: terraform-aws-cloudfront-s3-cdn
@@ -93,6 +95,21 @@ usage: |-
93
95
}
94
96
```
95
97
98
+
### Using an S3 Static Website Origin
99
+
100
+
When variable `website_enabled` is set to `true`, the S3 origin is configured
101
+
as a static website. The S3 static website has the advantage of redirecting
102
+
URL `subdir/` to `subdir/index.html` without requiring a
103
+
[Lambda@Edge function to perform the redirection](https://aws.amazon.com/blogs/compute/implementing-default-directory-indexes-in-amazon-s3-backed-amazon-cloudfront-origins-using-lambdaedge/).
104
+
The S3 static website responds only to CloudFront, preventing direct access to
105
+
S3.
106
+
107
+
In addition to setting `website_enabled=true`, you must also:
108
+
109
+
* Specify at least one `aliases`, like `["example.com"]` or
Although AWS Certificate Manager is supported in many AWS regions, to use an SSL certificate with CloudFront, it should be requested only in US East (N. Virginia) region.
0 commit comments