s3_website_monadic 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/LICENSE +42 -0
- data/README.md +451 -0
- data/Rakefile +24 -0
- data/additional-docs/example-configurations.md +62 -0
- data/additional-docs/setting-up-aws-credentials.md +51 -0
- data/assembly.sbt +3 -0
- data/bin/s3_website +80 -0
- data/build.sbt +33 -0
- data/changelog.md +215 -0
- data/features/as-library.feature +29 -0
- data/features/cassettes/cucumber_tags/create-redirect.yml +384 -0
- data/features/cassettes/cucumber_tags/empty-bucket.yml +89 -0
- data/features/cassettes/cucumber_tags/new-and-changed-files.yml +303 -0
- data/features/cassettes/cucumber_tags/new-files-for-sydney.yml +211 -0
- data/features/cassettes/cucumber_tags/new-files.yml +355 -0
- data/features/cassettes/cucumber_tags/no-new-or-changed-files.yml +359 -0
- data/features/cassettes/cucumber_tags/one-file-to-delete.yml +390 -0
- data/features/cassettes/cucumber_tags/only-changed-files.yml +411 -0
- data/features/cassettes/cucumber_tags/s3-and-cloudfront-after-deleting-a-file.yml +434 -0
- data/features/cassettes/cucumber_tags/s3-and-cloudfront-when-updating-a-file.yml +435 -0
- data/features/cassettes/cucumber_tags/s3-and-cloudfront.yml +290 -0
- data/features/cloudfront.feature +54 -0
- data/features/command-line-help.feature +54 -0
- data/features/delete.feature +19 -0
- data/features/error_reporting.feature +24 -0
- data/features/instructions-for-new-user.feature +154 -0
- data/features/jekyll-support.feature +20 -0
- data/features/nanoc-support.feature +20 -0
- data/features/push.feature +115 -0
- data/features/redirects.feature +14 -0
- data/features/security.feature +15 -0
- data/features/step_definitions/steps.rb +86 -0
- data/features/support/env.rb +26 -0
- data/features/support/test_site_dirs/cdn-powered.blog.fi/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/cdn-powered.blog.fi/_site/index.html +5 -0
- data/features/support/test_site_dirs/cdn-powered.blog.fi/s3_website.yml +4 -0
- data/features/support/test_site_dirs/cdn-powered.when-deleted-a-file.blog.fi/_site/index.html +10 -0
- data/features/support/test_site_dirs/cdn-powered.when-deleted-a-file.blog.fi/s3_website.yml +5 -0
- data/features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi/_site/index.html +10 -0
- data/features/support/test_site_dirs/cdn-powered.with-one-change.blog.fi/s3_website.yml +4 -0
- data/features/support/test_site_dirs/create-redirects/_site/.gitkeep +0 -0
- data/features/support/test_site_dirs/create-redirects/s3_website.yml +6 -0
- data/features/support/test_site_dirs/ignored-files.com/_site/css/styles.css +4 -0
- data/features/support/test_site_dirs/ignored-files.com/_site/index.html +8 -0
- data/features/support/test_site_dirs/ignored-files.com/s3_website.yml +5 -0
- data/features/support/test_site_dirs/index-and-assets.blog.fi/_site/assets/picture.gif +0 -0
- data/features/support/test_site_dirs/index-and-assets.blog.fi/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/index-and-assets.blog.fi/_site/index.html +5 -0
- data/features/support/test_site_dirs/index-and-assets.blog.fi/s3_website.yml +3 -0
- data/features/support/test_site_dirs/jekyllrb.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/jekyllrb.com/_site/index.html +5 -0
- data/features/support/test_site_dirs/jekyllrb.com/s3_website.yml +3 -0
- data/features/support/test_site_dirs/my.blog-with-clean-urls.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/my.blog-with-clean-urls.com/_site/index +5 -0
- data/features/support/test_site_dirs/my.blog-with-clean-urls.com/s3_website.yml +3 -0
- data/features/support/test_site_dirs/my.blog.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/my.blog.com/_site/index.html +5 -0
- data/features/support/test_site_dirs/my.blog.com/s3_website.yml +3 -0
- data/features/support/test_site_dirs/my.sydney.blog.au/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/my.sydney.blog.au/_site/index.html +5 -0
- data/features/support/test_site_dirs/my.sydney.blog.au/s3_website.yml +4 -0
- data/features/support/test_site_dirs/nanoc.ws/public/output/css/styles.css +3 -0
- data/features/support/test_site_dirs/nanoc.ws/public/output/index.html +5 -0
- data/features/support/test_site_dirs/nanoc.ws/s3_website.yml +3 -0
- data/features/support/test_site_dirs/new-and-changed-files.com/_site/css/styles.css +4 -0
- data/features/support/test_site_dirs/new-and-changed-files.com/_site/index.html +8 -0
- data/features/support/test_site_dirs/new-and-changed-files.com/s3_website.yml +3 -0
- data/features/support/test_site_dirs/no-new-or-changed-files.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/no-new-or-changed-files.com/_site/index.html +5 -0
- data/features/support/test_site_dirs/no-new-or-changed-files.com/s3_website.yml +3 -0
- data/features/support/test_site_dirs/only-changed-files.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/only-changed-files.com/_site/index.html +9 -0
- data/features/support/test_site_dirs/only-changed-files.com/s3_website.yml +3 -0
- data/features/support/test_site_dirs/site-that-contains-s3-website-file.com/_site/s3_website.yml +3 -0
- data/features/support/test_site_dirs/site-that-contains-s3-website-file.com/s3_website.yml +3 -0
- data/features/support/test_site_dirs/site-with-text-doc.com/_site/file.txt +1 -0
- data/features/support/test_site_dirs/site.with.css-maxage.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/site.with.css-maxage.com/_site/index.html +5 -0
- data/features/support/test_site_dirs/site.with.css-maxage.com/s3_website.yml +5 -0
- data/features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/_site/index.html +5 -0
- data/features/support/test_site_dirs/site.with.gzipped-and-max-aged-content.com/s3_website.yml +5 -0
- data/features/support/test_site_dirs/site.with.gzipped-html.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/site.with.gzipped-html.com/_site/index.html +5 -0
- data/features/support/test_site_dirs/site.with.gzipped-html.com/s3_website.yml +5 -0
- data/features/support/test_site_dirs/site.with.maxage.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/site.with.maxage.com/_site/index.html +5 -0
- data/features/support/test_site_dirs/site.with.maxage.com/s3_website.yml +4 -0
- data/features/support/test_site_dirs/unpublish-a-post.com/_site/css/styles.css +3 -0
- data/features/support/test_site_dirs/unpublish-a-post.com/s3_website.yml +3 -0
- data/features/support/vcr.rb +20 -0
- data/features/website-performance.feature +57 -0
- data/lib/cloudfront/invalidator.rb +37 -0
- data/lib/s3_website/config_loader.rb +55 -0
- data/lib/s3_website/diff_helper.rb +113 -0
- data/lib/s3_website/endpoint.rb +37 -0
- data/lib/s3_website/errors.rb +42 -0
- data/lib/s3_website/jekyll.rb +5 -0
- data/lib/s3_website/keyboard.rb +27 -0
- data/lib/s3_website/nanoc.rb +5 -0
- data/lib/s3_website/parallelism.rb +25 -0
- data/lib/s3_website/paths.rb +39 -0
- data/lib/s3_website/retry.rb +19 -0
- data/lib/s3_website/tasks.rb +36 -0
- data/lib/s3_website/upload.rb +137 -0
- data/lib/s3_website/uploader.rb +177 -0
- data/lib/s3_website.rb +34 -0
- data/project/assembly.sbt +1 -0
- data/project/build.properties +0 -0
- data/project/plugins.sbt +1 -0
- data/project/sbt-launch-0.13.2.jar +0 -0
- data/resources/configuration_file_template.yml +56 -0
- data/s3_website.gemspec +41 -0
- data/sbt +4 -0
- data/spec/lib/cloudfront/invalidator_spec.rb +60 -0
- data/spec/lib/config_loader_spec.rb +20 -0
- data/spec/lib/endpoint_spec.rb +31 -0
- data/spec/lib/error_spec.rb +21 -0
- data/spec/lib/keyboard_spec.rb +62 -0
- data/spec/lib/parallelism_spec.rb +81 -0
- data/spec/lib/paths_spec.rb +7 -0
- data/spec/lib/retry_spec.rb +34 -0
- data/spec/lib/upload_spec.rb +303 -0
- data/spec/lib/uploader_spec.rb +37 -0
- data/spec/sample_files/hyde_site/_site/.vimrc +5 -0
- data/spec/sample_files/hyde_site/_site/css/styles.css +3 -0
- data/spec/sample_files/hyde_site/_site/index.html +1 -0
- data/spec/sample_files/hyde_site/s3_website.yml +3 -0
- data/spec/sample_files/tokyo_site/_site/.vimrc +5 -0
- data/spec/sample_files/tokyo_site/_site/css/styles.css +3 -0
- data/spec/sample_files/tokyo_site/_site/index.html +1 -0
- data/spec/sample_files/tokyo_site/s3_website.yml +4 -0
- data/spec/spec_helper.rb +1 -0
- data/src/main/scala/s3/website/CloudFront.scala +96 -0
- data/src/main/scala/s3/website/Diff.scala +42 -0
- data/src/main/scala/s3/website/Implicits.scala +7 -0
- data/src/main/scala/s3/website/Push.scala +191 -0
- data/src/main/scala/s3/website/Ruby.scala +12 -0
- data/src/main/scala/s3/website/S3.scala +139 -0
- data/src/main/scala/s3/website/model/Config.scala +152 -0
- data/src/main/scala/s3/website/model/S3Endpoint.scala +22 -0
- data/src/main/scala/s3/website/model/Site.scala +68 -0
- data/src/main/scala/s3/website/model/errors.scala +11 -0
- data/src/main/scala/s3/website/model/push.scala +192 -0
- data/src/test/scala/s3/website/S3WebsiteSpec.scala +445 -0
- metadata +508 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 634e20c8a7499f1c7147b0460ff7c1a7fbc4c3c8
|
4
|
+
data.tar.gz: b5cc7f546c4958744dce20476379da21e1bfcbb9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 01ddba22131ffb857634230b553a659bb8d5ded515850849f0a41485bafff580caee2962508d9cc778735ebe6cfaf3bf14ae434c4383607ffb4f40bf8487cd38
|
7
|
+
data.tar.gz: 6a62c9c2905d0d6c2f32be332bcc7a74f115e0e5c6c878374ad800daf708eaa5a0d7c9e761464570765260135314c8a83dced0dbeaed0b1b892d51e1c9a06efc
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Copyright (c) 2013 Lauri Lehmijoki
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
20
|
+
|
21
|
+
(This software is derived from the Ruby gem jekyll-s3, which was created by
|
22
|
+
Philippe Creux. Below is the MIT license of jekyll-s3.)
|
23
|
+
|
24
|
+
Copyright (c) 2011 VersaPay, Philippe Creux.
|
25
|
+
|
26
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
27
|
+
of this software and associated documentation files (the "Software"), to deal
|
28
|
+
in the Software without restriction, including without limitation the rights
|
29
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
30
|
+
copies of the Software, and to permit persons to whom the Software is
|
31
|
+
furnished to do so, subject to the following conditions:
|
32
|
+
|
33
|
+
The above copyright notice and this permission notice shall be included in
|
34
|
+
all copies or substantial portions of the Software.
|
35
|
+
|
36
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
37
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
38
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
39
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
40
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
41
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
42
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,451 @@
|
|
1
|
+
# Deploy your website to S3
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/laurilehmijoki/s3_website.png?branch=master)](https://travis-ci.org/laurilehmijoki/s3_website)
|
4
|
+
[![Gem Version](https://fury-badge.herokuapp.com/rb/s3_website.png)](http://badge.fury.io/rb/s3_website)
|
5
|
+
|
6
|
+
## What `s3_website` can do for you
|
7
|
+
|
8
|
+
* Create and configure an S3 website for you
|
9
|
+
* Upload your static website to AWS S3
|
10
|
+
* Jekyll and Nanoc are automatically supported
|
11
|
+
* Help you use AWS Cloudfront to distribute your website
|
12
|
+
* Improve page speed with HTTP cache control and gzipping
|
13
|
+
* Set HTTP redirects for your website
|
14
|
+
* (for other features, see the documentation below)
|
15
|
+
|
16
|
+
## Install
|
17
|
+
|
18
|
+
gem install s3_website
|
19
|
+
|
20
|
+
`s3_website` requires Ruby. Here is documentation on installing Ruby:
|
21
|
+
<http://www.ruby-lang.org/en/downloads/>.
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Here's how you can get started:
|
26
|
+
|
27
|
+
* Create API credentials that have sufficient permissions to S3. More info
|
28
|
+
[here](https://github.com/laurilehmijoki/s3_website/blob/master/additional-docs/setting-up-aws-credentials.md).
|
29
|
+
* Go to your website directory
|
30
|
+
* Run `s3_website cfg create`. This generates a configuration file called `s3_website.yml`.
|
31
|
+
* Put your AWS credentials and the S3 bucket name into the file
|
32
|
+
* Run `s3_website cfg apply`. This will configure your bucket to function as an
|
33
|
+
S3 website. If the bucket does not exist, the command will create it for you.
|
34
|
+
* Run `s3_website push` to push your website to S3. Congratulations! You are live.
|
35
|
+
|
36
|
+
**Important security note:** if the source code of your website is publicly
|
37
|
+
available, ensure that the `s3_website.yml` file is in the list of ignored files.
|
38
|
+
For git users this means that the file `.gitignore` should mention the
|
39
|
+
`s3_website.yml` file.
|
40
|
+
|
41
|
+
### For Jekyll users
|
42
|
+
|
43
|
+
S3_website will automatically discover your website in the *_site* directory.
|
44
|
+
|
45
|
+
### For Nanoc users
|
46
|
+
|
47
|
+
S3_website will automatically discover your website in the *public/output* directory.
|
48
|
+
|
49
|
+
### For others
|
50
|
+
|
51
|
+
It's a good idea to store the `s3_website.yml` file in your project's root.
|
52
|
+
Let's say the contents you wish to upload to your S3 website bucket are in
|
53
|
+
*my_website_output*. You can upload the contents of that directory with
|
54
|
+
`s3_website push --site my_website_output`.
|
55
|
+
|
56
|
+
If you want to store the `s3_website.yml` file in a directory other than
|
57
|
+
the project's root you can specify the directory.
|
58
|
+
`s3_website push --config_dir config`.
|
59
|
+
|
60
|
+
### Using environment variables
|
61
|
+
|
62
|
+
You can use ERB in your `s3_website.yml` file which incorporates environment variables:
|
63
|
+
|
64
|
+
```yaml
|
65
|
+
s3_id: <%= ENV['S3_ID'] %>
|
66
|
+
s3_secret: <%= ENV['S3_SECRET'] %>
|
67
|
+
s3_bucket: blog.example.com
|
68
|
+
```
|
69
|
+
|
70
|
+
(If you are using `s3_website` on an [EC2 instance with IAM
|
71
|
+
roles](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/UsingIAM.html#UsingIAMrolesWithAmazonEC2Instances),
|
72
|
+
you can omit the `s3_id` and `s3_secret` keys in the config file.)
|
73
|
+
|
74
|
+
## Project goals
|
75
|
+
|
76
|
+
* Provide a command-line interface tool for deploying and managing S3 websites
|
77
|
+
* Let the user have all the S3 website configurations in a file
|
78
|
+
* Minimise or remove the need to use the AWS Console
|
79
|
+
* Allow the user to deliver the website via CloudFront
|
80
|
+
* Automatically detect the most common static website tools, such as Jekyll or
|
81
|
+
Nanoc
|
82
|
+
* Be simple to use: require only the S3 credentials and the name of the S3
|
83
|
+
bucket
|
84
|
+
* Let the power users benefit from advanced S3 website features such as
|
85
|
+
redirects, Cache-Control headers and gzip support
|
86
|
+
* Be as fast as possible. Do in parallel all that can be done in parallel.
|
87
|
+
* Maintain 90% backward compatibility with the jekyll-s3 gem
|
88
|
+
|
89
|
+
`s3_website` attempts to be a command-line interface tool that is easy to
|
90
|
+
understand and use. For example, `s3_website --help` should print you all the
|
91
|
+
things it can perform. Please create an issue if you think the tool is
|
92
|
+
incomprehensible or inconsistent.
|
93
|
+
|
94
|
+
## Additional features
|
95
|
+
|
96
|
+
### Cache Control
|
97
|
+
|
98
|
+
You can use the `max_age` configuration option to enable more effective browser
|
99
|
+
caching of your static assets. There are two possible ways to use the option:
|
100
|
+
you can specify a single age (in seconds) like so:
|
101
|
+
|
102
|
+
```yaml
|
103
|
+
max_age: 300
|
104
|
+
```
|
105
|
+
|
106
|
+
Or you can specify a hash of globs, and all files matching those globs will have
|
107
|
+
the specified age:
|
108
|
+
|
109
|
+
```yaml
|
110
|
+
max_age:
|
111
|
+
"assets/*": 6000
|
112
|
+
"*": 300
|
113
|
+
```
|
114
|
+
|
115
|
+
Place the configuration into the file `s3_website.yml`.
|
116
|
+
|
117
|
+
### Gzip Compression
|
118
|
+
|
119
|
+
If you choose, you can use compress certain file types before uploading them to
|
120
|
+
S3. This is a recommended practice for maximizing page speed and minimizing
|
121
|
+
bandwidth usage.
|
122
|
+
|
123
|
+
To enable Gzip compression, simply add a `gzip` option to your `s3_website.yml`
|
124
|
+
configuration file:
|
125
|
+
|
126
|
+
```yaml
|
127
|
+
gzip: true
|
128
|
+
```
|
129
|
+
|
130
|
+
Note that you can additionally specify the file extensions you want to Gzip
|
131
|
+
(`.html`, `.css`, `.js`, and `.txt` will be compressed when `gzip: true`):
|
132
|
+
|
133
|
+
```yaml
|
134
|
+
gzip:
|
135
|
+
- .html
|
136
|
+
- .css
|
137
|
+
- .md
|
138
|
+
```
|
139
|
+
|
140
|
+
Remember that the extensions here are referring to the *compiled* extensions,
|
141
|
+
not the pre-processed extensions.
|
142
|
+
|
143
|
+
#### Gzip zopfli
|
144
|
+
|
145
|
+
By adding the line `gzip_zopfli: true` into the config file, you can benefit
|
146
|
+
from the zopfli algorithm, which is 100% compatible with the traditional gzip
|
147
|
+
algorithm. A zopfli compression takes longer but results in about 5% smaller
|
148
|
+
files.
|
149
|
+
|
150
|
+
### Specifying a MIME type for files without extensions
|
151
|
+
|
152
|
+
`s3_website` will look up the MIME type of each file it uploads, and infer the Content-Type from it automatically. By default, files without an extension will have a blank Content-Type.
|
153
|
+
|
154
|
+
You can specify a default MIME type for files without an extension using a line like this in `s3_website.yml`:
|
155
|
+
|
156
|
+
```yaml
|
157
|
+
extensionless_mime_type: text/html
|
158
|
+
```
|
159
|
+
|
160
|
+
This is useful when you are uploading HTML files for which you want 'clean' URLs, e.g. `www.domain.com/info`.
|
161
|
+
|
162
|
+
### Using non-standard AWS regions
|
163
|
+
|
164
|
+
By default, `s3_website` uses the US Standard Region. You can upload your
|
165
|
+
website to other regions by adding the setting `s3_endpoint` into the
|
166
|
+
`s3_website.yml` file.
|
167
|
+
|
168
|
+
For example, the following line in `s3_website.yml` will instruct `s3_website` to
|
169
|
+
push your site into the Tokyo region:
|
170
|
+
|
171
|
+
```yaml
|
172
|
+
s3_endpoint: ap-northeast-1
|
173
|
+
```
|
174
|
+
|
175
|
+
The valid `s3_endpoint` values consist of the [S3 location constraint
|
176
|
+
values](http://docs.amazonwebservices.com/general/latest/gr/rande.html#s3_region).
|
177
|
+
|
178
|
+
### Ignoring files you want to keep on AWS
|
179
|
+
|
180
|
+
Sometimes there are files or directories you want to keep on S3, but not on
|
181
|
+
your local machine. You may define a regular expression to ignore files like so:
|
182
|
+
|
183
|
+
```yaml
|
184
|
+
ignore_on_server: that_folder_of_stuff_i_dont_keep_locally
|
185
|
+
```
|
186
|
+
|
187
|
+
You may also specify the values as a list:
|
188
|
+
|
189
|
+
```yaml
|
190
|
+
ignore_on_server:
|
191
|
+
- that_folder_of_stuff_i_dont_keep_locally
|
192
|
+
- file_managed_by_somebody_else
|
193
|
+
```
|
194
|
+
|
195
|
+
### Excluding files from upload
|
196
|
+
|
197
|
+
You can instruct `s3_website` not to push certain files:
|
198
|
+
|
199
|
+
```yaml
|
200
|
+
exclude_from_upload: test
|
201
|
+
```
|
202
|
+
|
203
|
+
The value can be a regex, and you can specify many of them:
|
204
|
+
|
205
|
+
```yaml
|
206
|
+
exclude_from_upload:
|
207
|
+
- test
|
208
|
+
- (draft|secret)
|
209
|
+
```
|
210
|
+
|
211
|
+
### Reduced Redundancy
|
212
|
+
|
213
|
+
You can reduce the cost of hosting your blog on S3 by using Reduced Redundancy Storage:
|
214
|
+
|
215
|
+
* In `s3_website.yml`, set `s3_reduced_redundancy: true`
|
216
|
+
* All objects uploaded after this change will use the Reduced Redundancy Storage.
|
217
|
+
* If you want to change all of the files in the bucket, you can change them through the AWS console, or update the timestamp on the files before running `s3_website` again
|
218
|
+
|
219
|
+
### How to use Cloudfront to deliver your blog
|
220
|
+
|
221
|
+
It is easy to deliver your S3-based web site via Cloudfront, the CDN of Amazon.
|
222
|
+
|
223
|
+
#### Creating a new CloudFront distribution
|
224
|
+
|
225
|
+
When you run the command `s3_website cfg apply`, it will ask you whether you
|
226
|
+
want to deliver your website via CloudFront. If you answer yes, the command will
|
227
|
+
create a CloudFront distribution for you.
|
228
|
+
|
229
|
+
#### Using your existing CloudFront distribution
|
230
|
+
|
231
|
+
If you already have a CloudFront distribution that serves data from your website
|
232
|
+
S3 bucket, just add the following line into the file `s3_website.yml`:
|
233
|
+
|
234
|
+
cloudfront_distribution_id: your-dist-id
|
235
|
+
|
236
|
+
Next time you run `s3_website push`, it will invalidate the items on CloudFront and
|
237
|
+
thus force the CDN system to reload the changes from your website S3 bucket.
|
238
|
+
|
239
|
+
#### Specifying custom settings for your CloudFront distribution
|
240
|
+
|
241
|
+
`s3_website` lets you define custom settings for your CloudFront distribution.
|
242
|
+
|
243
|
+
For example, like this you can define a your own TTL and CNAME:
|
244
|
+
|
245
|
+
```yaml
|
246
|
+
cloudfront_distribution_config:
|
247
|
+
default_cache_behavior:
|
248
|
+
min_TTL: <%= 60 * 60 * 24 %>
|
249
|
+
aliases:
|
250
|
+
quantity: 1
|
251
|
+
items:
|
252
|
+
CNAME: your.website.com
|
253
|
+
```
|
254
|
+
|
255
|
+
Once you've saved the configuration into `s3_website.yml`, you can apply them by
|
256
|
+
running `s3_website cfg apply`.
|
257
|
+
|
258
|
+
#### Invalidating root resources instead of index.htmls
|
259
|
+
|
260
|
+
By default, `s3_website push` calls the CloudFront invalidation API with the
|
261
|
+
file-name-as-it-is. This means that if your file is *article/index.html*, the
|
262
|
+
push command will call the invalidation API on the resource
|
263
|
+
*article/index.html*.
|
264
|
+
|
265
|
+
You can instruct the push command to invalidate the root resource instead of the
|
266
|
+
*index.html* resource by adding the following setting into the configuration
|
267
|
+
file:
|
268
|
+
|
269
|
+
cloudfront_invalidate_root: true
|
270
|
+
|
271
|
+
To recap, this setting instructs s3_website to invalidate the root resource
|
272
|
+
(e.g., *article/*) instead of the filename'd resource (e.g.,
|
273
|
+
*article/index.html*).
|
274
|
+
|
275
|
+
No more index.htmls in your URLs!
|
276
|
+
|
277
|
+
*Note*: If the root resource on your folder displays an error instead of the
|
278
|
+
index file, your source bucket in Cloudfront likely is pointing to the S3 Origin,
|
279
|
+
*example.com.s3.amazonaws.com*. Update the source to the S3 Website Endpoint,
|
280
|
+
*e.g. example.com.s3-website-us-east-1.amazonaws.com*, to fix this.
|
281
|
+
|
282
|
+
### Configuring redirects on your S3 website
|
283
|
+
|
284
|
+
You can set HTTP redirects on your S3 website in two ways. If you only need
|
285
|
+
simple "301 Moved Premanently" redirects for certain keys, use the Simple
|
286
|
+
Redirects method. Otherwise, use the Routing Rules method.
|
287
|
+
|
288
|
+
#### Simple Redirects
|
289
|
+
|
290
|
+
For simple redirects `s3_website` uses Amazon S3's
|
291
|
+
[`x-amz-website-redirect-location`](http://docs.aws.amazon.com/AmazonS3/latest/dev/how-to-page-redirect.html)
|
292
|
+
metadata. It will create zero-byte objects for each path you want
|
293
|
+
redirected with the appropriate `x-amz-website-redirect-location` value.
|
294
|
+
|
295
|
+
For setting up simple redirect rules, simply list each path and target
|
296
|
+
as key-value pairs under the `redirects` configuration option:
|
297
|
+
|
298
|
+
```yaml
|
299
|
+
redirects:
|
300
|
+
index.php: /
|
301
|
+
about.php: about.html
|
302
|
+
music-files/promo.mp4: http://www.youtube.com/watch?v=dQw4w9WgXcQ
|
303
|
+
```
|
304
|
+
|
305
|
+
#### Routing Rules
|
306
|
+
|
307
|
+
You can configure more complex redirect rules by adding the following
|
308
|
+
configuration into the `s3_website.yml` file:
|
309
|
+
|
310
|
+
```yaml
|
311
|
+
routing_rules:
|
312
|
+
- condition:
|
313
|
+
key_prefix_equals: blog/some_path
|
314
|
+
redirect:
|
315
|
+
host_name: blog.example.com
|
316
|
+
replace_key_prefix_with: some_new_path/
|
317
|
+
http_redirect_code: 301
|
318
|
+
```
|
319
|
+
|
320
|
+
After adding the configuration, run the command `s3_website cfg apply` on your
|
321
|
+
command-line interface. This will apply the routing rules on your S3 bucket.
|
322
|
+
|
323
|
+
For more information on configuring redirects, see the documentation of the
|
324
|
+
[configure-s3-website](https://github.com/laurilehmijoki/configure-s3-website#configuring-redirects)
|
325
|
+
gem, which comes as a transitive dependency of the `s3_website` gem. (The
|
326
|
+
command `s3_website cfg apply` internally calls the `configure-s3-website` gem.)
|
327
|
+
|
328
|
+
### Using `s3_website` as a library
|
329
|
+
|
330
|
+
By nature, `s3_website` is a command-line interface tool. You can, however, use
|
331
|
+
it programmatically by calling the same API as the executable `s3_website` does:
|
332
|
+
|
333
|
+
````ruby
|
334
|
+
require 's3_website'
|
335
|
+
is_headless = true
|
336
|
+
S3Website::Tasks.push('/website/root', '/path/to/your/website/_site/', is_headless)
|
337
|
+
````
|
338
|
+
|
339
|
+
You can also use a basic `Hash` instead of a `s3_website.yml` file:
|
340
|
+
|
341
|
+
```ruby
|
342
|
+
config = {
|
343
|
+
"s3_id" => YOUR_AWS_S3_ACCESS_KEY_ID,
|
344
|
+
"s3_secret" => YOUR_AWS_S3_SECRET_ACCESS_KEY,
|
345
|
+
"s3_bucket" => "your.blog.bucket.com"
|
346
|
+
}
|
347
|
+
in_headless = true
|
348
|
+
S3Website::Uploader.run('/path/to/your/website/_site/', config, in_headless)
|
349
|
+
```
|
350
|
+
|
351
|
+
The code above will assume that you have the `s3_website.yml` in the directory
|
352
|
+
`/path/to/your/website`.
|
353
|
+
|
354
|
+
### Specifying custom concurrency level
|
355
|
+
|
356
|
+
By default, `s3_website` does 3 operations in parallel. An operation can be an
|
357
|
+
HTTP PUT operation against the S3 API, for example.
|
358
|
+
|
359
|
+
You can increase the concurrency level by adding the following setting into the
|
360
|
+
`s3_website.yml` file:
|
361
|
+
|
362
|
+
```
|
363
|
+
concurrency_level: <integer>
|
364
|
+
```
|
365
|
+
|
366
|
+
However, because S3 throttles connections, there's an upper limit to the
|
367
|
+
level of parallelism. If you start to see end-of-file errors, decrease the
|
368
|
+
concurrency level. Conversely, if you don't experience any errors, you can
|
369
|
+
increase the concurrency level and thus benefit from faster uploads.
|
370
|
+
|
371
|
+
If you experience the "too many open files" error, either increase the amount of
|
372
|
+
maximum open files (on Unix-like systems, see `man ulimit`) or decrease the
|
373
|
+
`concurrency_level` setting.
|
374
|
+
|
375
|
+
## Example configurations
|
376
|
+
|
377
|
+
See
|
378
|
+
<https://github.com/laurilehmijoki/s3_website/blob/master/additional-docs/example-configurations.md>.
|
379
|
+
|
380
|
+
## Known issues
|
381
|
+
|
382
|
+
Please create an issue and send a pull request if you spot any.
|
383
|
+
|
384
|
+
## Development
|
385
|
+
|
386
|
+
### Versioning
|
387
|
+
|
388
|
+
s3_website uses [Semantic Versioning](http://semver.org).
|
389
|
+
|
390
|
+
In the spirit of semantic versioning, here is the definition of public API for
|
391
|
+
s3_website: Within a major version, s3_website will not break
|
392
|
+
backwards-compatibility of anything that is mentioned in this README file.
|
393
|
+
|
394
|
+
### Tests
|
395
|
+
|
396
|
+
* Install bundler and run `bundle install`
|
397
|
+
* Run all tests by invoking `rake test`
|
398
|
+
|
399
|
+
### Contributing
|
400
|
+
|
401
|
+
We (users and developers of s3_website) welcome patches, pull requests and
|
402
|
+
ideas for improvement.
|
403
|
+
|
404
|
+
When sending pull requests, please accompany them with tests. Favor BDD style
|
405
|
+
in test descriptions. Use VCR-backed integration tests where possible. For
|
406
|
+
reference, you can look at the existing s3_website tests.
|
407
|
+
|
408
|
+
If you are not sure how to test your pull request, you can ask the [gem owners
|
409
|
+
](http://rubygems.org/gems/s3_website) to supplement the request with tests.
|
410
|
+
However, by including proper tests, you increase the chances of your pull
|
411
|
+
request being incorporated into future releases.
|
412
|
+
|
413
|
+
#### Checklist for new features
|
414
|
+
|
415
|
+
* Is it tested?
|
416
|
+
* Is it documented in README?
|
417
|
+
* Is it mentioned in `resources/configuration_file_template.yml`?
|
418
|
+
|
419
|
+
## License
|
420
|
+
|
421
|
+
MIT. See the LICENSE file for more information.
|
422
|
+
|
423
|
+
## Contributors
|
424
|
+
|
425
|
+
This gem is created by Lauri Lehmijoki. Without the valuable work of [Philippe
|
426
|
+
Creux](https://github.com/pcreux) on
|
427
|
+
[jekyll-s3](https://github.com/laurilehmijoki/jekyll-s3), this project would not
|
428
|
+
exist.
|
429
|
+
|
430
|
+
Contributors (in alphabetical order)
|
431
|
+
* Alan deLevie
|
432
|
+
* Cory Kaufman-Schofield
|
433
|
+
* Chris Kelly
|
434
|
+
* Chris Moos
|
435
|
+
* Christopher Petersen
|
436
|
+
* David Michael Barr
|
437
|
+
* David Raffensperger
|
438
|
+
* Greg Karékinian
|
439
|
+
* John Allison
|
440
|
+
* Jordan White
|
441
|
+
* László Bácsi
|
442
|
+
* Mason Turner
|
443
|
+
* Michael Bleigh
|
444
|
+
* Philip I. Thomas
|
445
|
+
* Philippe Creux
|
446
|
+
* Shigeaki Matsumura
|
447
|
+
* stanislas
|
448
|
+
* Tate Johnson
|
449
|
+
* Toby Marsden
|
450
|
+
* Trevor Fitzgerald
|
451
|
+
* Zee Spencer
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
desc "Build the project"
|
5
|
+
task :default => 'test'
|
6
|
+
|
7
|
+
desc "Run tests"
|
8
|
+
task :test do
|
9
|
+
ENV['disable_parallel_processing'] = 'true'
|
10
|
+
sh "bundle exec rspec"
|
11
|
+
sh "bundle exec cucumber --tags ~@skip-on-travis"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Run work-in-progress features'
|
15
|
+
task "cucumber:wip" do
|
16
|
+
ENV['disable_parallel_processing'] = 'true'
|
17
|
+
sh "bundle exec cucumber --tags @wip"
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Run fast tests'
|
21
|
+
task "cucumber:fast" do
|
22
|
+
ENV['disable_parallel_processing'] = 'true'
|
23
|
+
sh "bundle exec cucumber --tags ~@network-io --tags ~@starts-new-os-process"
|
24
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Example `s3_website` configurations
|
2
|
+
|
3
|
+
This document shows examples of complete `s3_website.yml` configurations.
|
4
|
+
|
5
|
+
## Minimal
|
6
|
+
|
7
|
+
````yaml
|
8
|
+
s3_id: abcd
|
9
|
+
s3_secret: 2s+x92
|
10
|
+
s3_bucket: your.domain.net
|
11
|
+
````
|
12
|
+
|
13
|
+
## Minimal with EC2 AIM roles
|
14
|
+
|
15
|
+
````yaml
|
16
|
+
s3_bucket: your.domain.net
|
17
|
+
````
|
18
|
+
|
19
|
+
If you run `s3_website` on an EC2 instance with IAM roles, it is possible to omit
|
20
|
+
the `s3_id` and `s3_secret`.
|
21
|
+
|
22
|
+
## Optimised for speed
|
23
|
+
|
24
|
+
Use CloudFront, gzip, cache headers and greater concurrency:
|
25
|
+
|
26
|
+
````yaml
|
27
|
+
s3_id: <%= ENV['your_domain_net_aws_key'] %>
|
28
|
+
s3_secret: <%= ENV['your_domain_net_aws_secret'] %>
|
29
|
+
s3_bucket: your.domain.net
|
30
|
+
cloudfront_distribution_id: <%= ENV['your_domain_net_cloudfront_distribution_id'] %>
|
31
|
+
cloudfront_distribution_config:
|
32
|
+
default_cache_behavior:
|
33
|
+
min_TTL: <%= 60 * 60 * 24 %>
|
34
|
+
aliases:
|
35
|
+
quantity: 1
|
36
|
+
items:
|
37
|
+
CNAME: your.domain.net
|
38
|
+
max_age: 120
|
39
|
+
gzip: true
|
40
|
+
````
|
41
|
+
|
42
|
+
Above, we store the AWS credentials and the id of the CloudFront distribution as
|
43
|
+
environment variables. It's convenient, since you can keep the `s3_website.yml`
|
44
|
+
in a public Git repo, and thus have your deployment configurations
|
45
|
+
version-controlled.
|
46
|
+
|
47
|
+
## Using redirects
|
48
|
+
|
49
|
+
````yaml
|
50
|
+
s3_id: hello
|
51
|
+
s3_secret: galaxy
|
52
|
+
redirects:
|
53
|
+
index.php: /
|
54
|
+
about.php: about.html
|
55
|
+
routing_rules:
|
56
|
+
- condition:
|
57
|
+
key_prefix_equals: code/repositories/git/
|
58
|
+
redirect:
|
59
|
+
host_name: git.johnny.com
|
60
|
+
replace_key_prefix_with: ""
|
61
|
+
http_redirect_code: 301
|
62
|
+
````
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Setting up AWS credentials
|
2
|
+
|
3
|
+
Before starting to use s3\_website, you need to create AWS credentials.
|
4
|
+
|
5
|
+
## Easy setup
|
6
|
+
|
7
|
+
* Go to [AWS IAM console](https://console.aws.amazon.com/iam)
|
8
|
+
* Create a new user that has full permissions to the S3 and CloudFront services
|
9
|
+
* Call `s3_website cfg create` and place the credentials of your new AWS user
|
10
|
+
into the *s3_website.yml* file
|
11
|
+
* Read the main documentation for further info
|
12
|
+
|
13
|
+
## Limiting the permissions of the credentials
|
14
|
+
|
15
|
+
AWS IAM offers multiple ways of limiting the permissions of a user. Below is one
|
16
|
+
way of configuring the limitations and yet retaining the capability to use all
|
17
|
+
s3\_website features.
|
18
|
+
|
19
|
+
If you know the hostname of your public website (say `my.website.com`), perform the
|
20
|
+
following steps:
|
21
|
+
|
22
|
+
* Create a user that has full permissions to the S3 bucket
|
23
|
+
* In addition, let the user have full permissions to CloudFront
|
24
|
+
|
25
|
+
Here is the IAM Policy Document of the above setup:
|
26
|
+
|
27
|
+
```json
|
28
|
+
{
|
29
|
+
"Statement": [
|
30
|
+
{
|
31
|
+
"Action": [
|
32
|
+
"cloudfront:*"
|
33
|
+
],
|
34
|
+
"Effect": "Allow",
|
35
|
+
"Resource": [
|
36
|
+
"*"
|
37
|
+
]
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"Action": [
|
41
|
+
"s3:*"
|
42
|
+
],
|
43
|
+
"Effect": "Allow",
|
44
|
+
"Resource": [
|
45
|
+
"arn:aws:s3:::my.website.com",
|
46
|
+
"arn:aws:s3:::my.website.com/*"
|
47
|
+
]
|
48
|
+
}
|
49
|
+
]
|
50
|
+
}
|
51
|
+
```
|
data/assembly.sbt
ADDED