UNPKG

3.08 kBMarkdownView Raw
1# Haiku9
2
3Haiku9 (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
9H9 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
16npm install -g haiku9
17```
18
19## Configuration
20
21### AWS Profile
22H9 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
24From that reference:
25> defaulting to `~/.aws/credentials` or defined by the `AWS_SHARED_CREDENTIALS_FILE` environment variable
26
27Within that file, you can assign credentials to multiple "profiles" for easy access. H9 can accept that profile name as a command-line argument
28```
29h9 publish production -p "panda"
30```
31
32### H9 File
33
34At 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.
41source: build
42
43# The root domain for your site.
44domain: pandastrike.com
45
46# The AWS region you would like to use for your S3 bucket that serves your site
47region: 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.
51site:
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 "*"
56cors: 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.
62environments:
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
85To 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
91Next, publish to AWS:
92
93```shell
94h9 publish <environment>
95```
96
97And in a few minutes you will have a new website.
98
99If you would like to tear it down.
100
101```shell
102h9 delete <environment>
103```
104
105And it will be gone just as easily.