1
- ---
2
1
#
3
2
# This is the canonical configuration for the `README.md`
4
3
# To rebuild `README.md`:
@@ -34,16 +33,17 @@ github_repo: cloudposse/terraform-aws-cloudfront-s3-cdn
34
33
35
34
# Badges to display
36
35
badges :
37
- - name : " Codefresh Build Status"
38
- image : " https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-cloudfront-s3-cdn?type=cf-1"
39
- url : " https://g.codefresh.io/public/accounts/cloudposse/pipelines/5d169121757962ff25679794"
40
- - name : " Latest Release"
41
- image : " https://img.shields.io/github/release/cloudposse/terraform-aws-cloudfront-s3-cdn.svg"
42
- url : " https://travis-ci.org/cloudposse/terraform-aws-cloudfront-s3-cdn/releases"
43
- - name : " Slack Community"
44
- image : " https://slack.cloudposse.com/badge.svg"
45
- url : " https://slack.cloudposse.com"
46
-
36
+ - name : Latest Release
37
+ image : https://img.shields.io/github/release/cloudposse/terraform-aws-cloudfront-s3-cdn.svg?style=for-the-badge
38
+ url : https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn/releases/latest
39
+ - name : Last Updated
40
+ image : https://img.shields.io/github/last-commit/cloudposse/terraform-aws-cloudfront-s3-cdn.svg?style=for-the-badge
41
+ url : https://github.com/cloudposse/terraform-aws-cloudfront-s3-cdn/commits
42
+ - name : Slack Community
43
+ image : https://slack.cloudposse.com/for-the-badge.svg
44
+ url : https://slack.cloudposse.com
45
+
46
+ # List any related terraform modules that this module may be used with or that this module depends on.
47
47
related :
48
48
- name : " terraform-aws-cloudfront-cdn"
49
49
description : " Terraform Module that implements a CloudFront Distribution (CDN) for a custom origin."
@@ -57,7 +57,7 @@ description: |-
57
57
Terraform module to provision an AWS CloudFront CDN with an S3 origin.
58
58
59
59
# How to use this project
60
- usage : |-
60
+ usage : |2 -
61
61
62
62
For a complete example, see [examples/complete](examples/complete).
63
63
@@ -143,57 +143,57 @@ usage: |-
143
143
```
144
144
145
145
### Background on CDNs, "Origins", S3 Buckets, and Web Servers
146
-
146
+
147
147
#### CDNs and Origin Servers
148
-
148
+
149
149
There are some settings you need to be aware of when using this module. In order to understand the settings,
150
150
you need to understand some of the basics of CDNs and web servers, so we are providing this _highly simplified_
151
151
explanation of how they work in order for you to understand the implications of the settings you are providing.
152
-
152
+
153
153
A "**CDN**" ([Content Distribution Network](https://www.cloudflare.com/learning/cdn/what-is-a-cdn/)) is a collection of
154
154
servers scattered around the internet with the aim of making it faster for people to retrieve content from a website.
155
155
The details of why that is wanted/needed are beyond the scope of this document, as are most of the details of how
156
156
a CDN is implemented. For this discussion, we will simply treat a CDN as a set of web servers all serving
157
157
the same content to different users.
158
-
158
+
159
159
In a normal web server (again, greatly simplified), you place files on the server and the web server software receives
160
160
requests from browsers and responds with the contents of the files.
161
-
161
+
162
162
For a variety of reasons, the web servers in a CDN do not work the way normal web servers work. Instead of getting
163
163
their content from files on the local server, the CDN web servers get their content by acting like web browsers
164
164
(proxies). When they get a request from a browser, they make the same request to what is called an "**Origin Server**".
165
165
It is called an origin server because it _serves_ the original content of the website, and thus is the _origin_
166
166
of the content.
167
-
167
+
168
168
As a website publisher, you put content on an Origin Server (which users usually should be prevented from accessing)
169
169
and configure your CDN to use your Origin Server. Then you direct users to a URL hosted by your CDN provider, the
170
170
users' browsers connect to the CDN, the CDN gets the content from your Origin Server, your Origin Server gets the
171
171
content from a file on the server, and the data gets sent back hop by hop to the user. (The reason this ends up
172
172
being a good idea is that the CDN can cache the content for a while, serving multiple users the same content while
173
173
only contacting the origin server once.)
174
-
174
+
175
175
#### S3 Buckets: file storage and web server
176
-
176
+
177
177
S3 buckets were originally designed just to store files, and they are still most often used for that. The have a lot
178
178
of access controls to make it possible to strictly limit who can read what files in the bucket, so that companies
179
179
can store sensitive information there. You may have heard of a number of "data breaches" being caused by misconfigured
180
180
permissions on S3 buckets, making them publicly accessible. As a result of that, Amazon has some extra settings on
181
181
top of everything else to keep S3 buckets from being publicly accessible, which is usually a good thing.
182
-
182
+
183
183
However, at some point someone realized that since these files were in the cloud, and Amazon already had these web servers
184
184
running to provide access to the files in the cloud, it was only a tiny leap to turn an S3 bucket into a web server.
185
185
So now S3 buckets [can be published as websites](https://docs.aws.amazon.com/AmazonS3/latest/userguide/EnableWebsiteHosting.html)
186
186
with a few configuration settings, including making the contents publicly accessible.
187
-
187
+
188
188
#### Web servers, files, and the different modes of S3 buckets
189
-
189
+
190
190
In the simplest websites, the URL "path" (the part after the site name) corresponds directly to the path (under
191
191
a special directory we will call `/webroot`) and name
192
192
of a file on the web server. So if the web server gets a request for "http://example.com/foo/bar/baz.html" it will
193
193
look for a file `/webroot/foo/bar/baz.html`. If it exists, the server will return its contents, and if it does not exist,
194
194
the server will return a `Not Found` error. An S3 bucket, whether configured as a file store or a website, will
195
195
always do both of these things.
196
-
196
+
197
197
Web servers, however, do some helpful extra things. To name a few:
198
198
- If the URL ends with a `/`, as in `http://example.com/foo/bar/`, the web server (depending on how it is configured)
199
199
will either return a list of files in the directory or it will return the contents of a file in the directory with
@@ -204,41 +204,41 @@ usage: |-
204
204
turns out to be quite helpful.
205
205
- If the URL does not point to a directory or a file, instead of just sending back a cryptic `Not Found` error code,
206
206
it can return the contents of a special file called an "error document".
207
-
207
+
208
208
#### Your Critical Decision: S3 bucket or website?
209
-
209
+
210
210
All of this background is to help you decide how to set `website_enabled` and `s3_website_password_enabled`.
211
211
The default for `website_enabled` is `false` which is the easiest to configure and the most secure, and with
212
212
this setting, `s3_website_password_enabled` is ignored.
213
-
213
+
214
214
S3 buckets, in file storage mode (`website_enabled = false`), do none of these extra things that web servers do.
215
215
If the URL points to a file, it will return the file, and if it does not _exactly_ match a file, it will return
216
216
`Not Found`. One big advantage, though, is that the S3 bucket can remain private (not publicly accessible). A second,
217
217
related advantage is that you can limit the website to a portion of the S3 bucket (everything under a certain prefix)
218
218
and keep the contents under the the other prefixes private.
219
-
219
+
220
220
S3 buckets configured as static websites (`website_enabled = true`), however, have these extra web server features like redirects, `index.html`,
221
221
and error documents. The disadvantage is that you have to make the entire bucket public (although you can still
222
222
restrict access to some portions of the bucket).
223
-
223
+
224
224
Another feature or drawback (depending on your point of view) of S3 buckets configured as static websites is that
225
225
they are directly accessible via their [website endpoint](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteEndpoints.html)
226
226
as well as through Cloudfront. This module has a feature, `s3_website_password_enabled`, that requires a password
227
227
be passed in the HTTP request header and configures the CDN to do that, which will make it much harder to access
228
228
the S3 website directly. So set `s3_website_password_enabled = true` to limit direct access to the S3 website
229
229
or set it to false if you want to be able to bypass Cloudfront when you want to.
230
-
230
+
231
231
In addition to setting `website_enabled=true`, you must also:
232
232
233
233
* Specify at least one `aliases`, like `["example.com"]` or
234
234
`["example.com", "www.example.com"]`
235
235
* Specify an ACM certificate
236
236
237
237
### Custom Domain Names and Generating a TLS Certificate with ACM
238
-
238
+
239
239
When you set up Cloudfront, Amazon will generate a domain name for your website. You amost certainly will not
240
240
want to publish that. Instead, you will want to use a custom domain name. This module refers to them as "aliases".
241
-
241
+
242
242
To use the custom domain names, you need to
243
243
- Pass them in as `aliases` so that Cloudfront will respond to them with your content
244
244
- Create CNAMEs for the aliases to point to the Cloudfront domain name. If your alias domains are hosted by
@@ -383,22 +383,4 @@ include:
383
383
- " docs/terraform.md"
384
384
385
385
# Contributors to this project
386
- contributors :
387
- - name : " Erik Osterman"
388
- github : " osterman"
389
- - name : " Andriy Knysh"
390
- github : " aknysh"
391
- - name : " Jamie Nelson"
392
- github : " Jamie-BitFlight"
393
- - name : " Clive Zagno"
394
- github : " cliveza"
395
- - name : " David Mattia"
396
- github : " dmattia"
397
- - name : " RB"
398
- github : " nitrocode"
399
- - name : " John McGehee"
400
- github : " jmcgeheeiv"
401
- - name : " Yonatan Koren"
402
- github : " korenyoni"
403
- - name : " Lucas Caparelli"
404
- github : " lcaparelli"
386
+ contributors : []
0 commit comments