1 | # Haiku9
|
2 |
|
3 | Haiku9 (H9 for short) is a static site publisher. H9 supports:
|
4 |
|
5 | - Syncing Web assets with an S3 bucket
|
6 | - Configuring that bucket as a website
|
7 | - Optionally fronting that bucket with a CloudFront distribution to support edge caching and/or TLS termination.
|
8 |
|
9 | H9 provides CLI and programmatic interfaces, though most of the configuration is handled with your `h9.yaml` file.
|
10 |
|
11 | ## Installation
|
12 |
|
13 | ### Local
|
14 |
|
15 | ```shell
|
16 | npm install -g haiku9
|
17 | ```
|
18 |
|
19 | ## Configuration
|
20 |
|
21 | ### AWS Profile
|
22 | H9 uses your AWS access to perform actions on your behalf. Your environment needs access to AWS credentials that can be reached by the [`SharedIniFileCredentials` method](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SharedIniFileCredentials.html)
|
23 |
|
24 | From that reference:
|
25 | > defaulting to `~/.aws/credentials` or defined by the `AWS_SHARED_CREDENTIALS_FILE` environment variable
|
26 |
|
27 | Within that file, you can assign credentials to multiple "profiles" for easy access. H9 can accept that profile name as a command-line argument
|
28 | ```
|
29 | h9 publish production -p "panda"
|
30 | ```
|
31 |
|
32 | ### H9 File
|
33 |
|
34 | At the root of your site, create a `h9.yaml` file. Here is an example for publishing to a hypothetical https://haiku9.pandastrike.com
|
35 |
|
36 | ```yaml
|
37 | # The directory Haiku9 will copy into an S3 bucket. The local directory is
|
38 | # authoritative, so files will be added or deleted from your bucket to make
|
39 | # it match. Haiku9 also uses MD5 hashes to make sure existing bucket files
|
40 | # are current.
|
41 | source: build
|
42 |
|
43 | # The root domain for your site.
|
44 | domain: pandastrike.com
|
45 |
|
46 | # The AWS region you would like to use for your S3 bucket that serves your site
|
47 | region: us-west-1
|
48 |
|
49 | # The default path when navigating to "/", as well as the page to serve if
|
50 | # a requested path does not exist.
|
51 | site:
|
52 | index: index
|
53 | error: 404
|
54 |
|
55 | # If you a publishing content to CDN that will be accessed through CORS, you can set your CORS settings here. `wildstyle` is the permissive "*"
|
56 | cors: wildstyle
|
57 |
|
58 |
|
59 | # Haiku9 uses environments to organize your a project's configuration into
|
60 | # sections while maintaining access to common configuration. Each environment
|
61 | # is named as the keys in the dictionary below.
|
62 | environments:
|
63 |
|
64 | # The staging environment has a hostname, but no cache configuration, so it
|
65 | # will serve directly from the S3 bucket without TLS termination.
|
66 | staging:
|
67 | hostnames:
|
68 | - staging-haiku
|
69 |
|
70 | # The production environment has a different hostname setting, as well as
|
71 | # configuration for the CloudFront distribution.
|
72 | production:
|
73 | hostnames:
|
74 | - haiku
|
75 | cache:
|
76 | expires: 1800 # 30 minutes
|
77 | ssl: true
|
78 | priceClass: 100
|
79 | ```
|
80 |
|
81 |
|
82 | ## Publishing
|
83 |
|
84 |
|
85 | To publish your compiled site to AWS, first confirm that your AWS credentials are defined in `~/.aws/credentials`:
|
86 |
|
87 | [default]
|
88 | aws_access_key_id=AKIAIOSFODNN7EXAMPLE
|
89 | aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
90 |
|
91 | Next, publish to AWS:
|
92 |
|
93 | ```shell
|
94 | h9 publish <environment>
|
95 | ```
|
96 |
|
97 | And in a few minutes you will have a new website.
|
98 |
|
99 | If you would like to tear it down.
|
100 |
|
101 | ```shell
|
102 | h9 delete <environment>
|
103 | ```
|
104 |
|
105 | And it will be gone just as easily.
|