Skip to content

Commit e365d38

Browse files
rpigu-igrgur
authored andcommitted
Readme (#68)
* tst ci * Add in warning message to command line * Update message in template * Add stubs for new docs * [issue-64] Start splitting up the readme file * Update to advanced_use.md file * Update readme doc * Add links to readme * Update readme file layout * Add link to webhooks * Update advanced use docs * Added CoC and contribute docs * Fox duplicate title
1 parent 444ff8a commit e365d38

File tree

7 files changed

+331
-210
lines changed

7 files changed

+331
-210
lines changed

README.md

Lines changed: 62 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ npm install -g capsule
3434

3535
You can now use `capsule` from your command line.
3636

37-
## Getting Started
37+
## Quick Start - Configuring Your Environment
3838

3939
In order to use Capsule you will need the following:
4040

@@ -66,7 +66,7 @@ A safe bet is to use `us-east-1` as this is the region that Capsule has been tes
6666

6767
First we are going to create a single file `config.json`
6868

69-
We a need directory to store this file, so create a new directory `.aws` under the root of your user
69+
We a need directory to store this file, so create a new directory `.aws` under the root of your user
7070

7171
*Mac/Linux*
7272

@@ -95,9 +95,9 @@ After creating these files, log into your AWS account. We now need to create an
9595
5. Next click on your username in the table
9696
6. When this loads, click on the `Security Credentials` tab
9797
7. We can now create an Access Key by clking `Create Access Key`
98-
8. Finally click `Show User Security Credentials` and copy the ID and value.
98+
8. Finally click `Show User Security Credentials` and copy the ID and value.
9999

100-
These details can only be displayed once, so if forget or lose them, you will need to generate a new key.
100+
These details can only be displayed once, so if forget or lose them, you will need to generate a new key.
101101
If you wish you can download the CSV file from this screen as a backup.
102102

103103
Re-open the config file e.g. vim `~/.aws/config.json`
@@ -106,18 +106,18 @@ Now replace the `accessKeyId` value (<YOUR_ACCESS_KEY_ID>) with the value you co
106106

107107
Next replace the `secretAccessKey` value (YOUR_SECRET_ACCESS_KEY) wuth the key you copied from the console.
108108

109-
Make sure you wrap the value you paste in with `"` and `"`.
109+
Make sure you wrap the value you paste in with `"` and `"`.
110110

111111
You can change the region if you wish as well, but please check the region supports all the features required by Capsule.
112112

113-
Save the file. You are now ready to use Capsule to build out your static site.
113+
Save the file. You are now ready to use Capsule to build out your static site.
114114

115115

116116
#### AWS Config - YAML setup
117117

118118
First we are going to create two files. These are the `config` and `credentials` file.
119119

120-
Create a new directory `.aws` under the root of your user
120+
Create a new directory `.aws` under the root of your user
121121

122122
*Mac/Linux*
123123

@@ -152,9 +152,9 @@ After creating these files, log into your AWS account. We now need to create an
152152
5. Next click on your username in the table
153153
6. When this loads, click on the `Security Credentials` tab
154154
7. We can now create an Access Key by clking `Create Access Key`
155-
8. Finally click `Show User Security Credentials` and copy the ID and value.
155+
8. Finally click `Show User Security Credentials` and copy the ID and value.
156156

157-
These details can only be displayed once, so if forget or lose them, you will need to generate a new key.
157+
These details can only be displayed once, so if forget or lose them, you will need to generate a new key.
158158
If you wish you can download the CSV file from this screen as a backup.
159159

160160
Re-open the credentials file e.g. vim `~/.aws/credentials`
@@ -181,35 +181,20 @@ region=us-east-1
181181
output=json
182182
```
183183

184-
Save the file.
184+
Save the file.
185185

186186
Your credentials and configuration are now setup to use Capsule.
187187

188-
### Your website configuration
189188

190-
Capsule supports a number of command line parameters to allow you to configure your web site.
189+
## Quick Start - Configure Your Project
191190

192-
In addition to this, you can use a JSON configuration file, containing these values.
191+
In order to create the `config.json` file containing your project configuration
192+
run the command `capsule.js init`
193193

194-
An example can be found in the `config/capsule.json` file in the capsule repository.
194+
Answer the questions presented to you on the screen.
195195

196-
When loading configuration options, the JSON config is loaded first, if specified. Following this any command line
197-
parameters are then loaded. Command line parameters will override any parameters specified in the JSON file.
198-
199-
An example can be seen here:
200-
201-
```
202-
./bin/capsule.js create --project-name "exampledotcom" --dom example.com --subdom app --url https://github.com/ExampleCom/exampledotcom --config ~/.aws/config.json --site_config='{"WebsiteCode":"./build"}' --site_config_file=./config/capsule.json ci
203-
```
204-
205-
In this example the value of the `--site_config` flag will overwrite the the key value pair specified in the `--site_config_file` JSON file.
206-
Thus if `WebsiteCode` is defined in `capsule.json` it's value will be overridden with `./build`.
207-
208-
209-
You can always check what command line parameters are available by running the `capsule -h` command.
210-
211-
212-
If you wish to run multiple bash commands inside of the build or post_build CodeBuild actions, then you will need to pass these as a single paramter.
196+
If you wish to run multiple bash commands inside of the `build` or `post_build`
197+
CodeBuild actions, then you will need to pass these as a single parameter.
213198

214199
Use the following chart as a guide for bash commands:
215200

@@ -228,19 +213,51 @@ npm build dev ; npm test
228213

229214
### Project Names
230215

231-
During the setup of your site you will need to define a project name. This will be used to name the
216+
During the setup of your site you will need to define a project name. This will be used to name the
232217
S3 bucket in AWS. Therefore your project name must confirm to the S3 bucket naming standards.
233218

234219
You can find these here:
235220

236221
https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
237222

238223

224+
225+
## Quick Start - Deploy Your Project
226+
227+
Once the `capsule.json` file is generated, you are now ready to deploy your project to
228+
your AWS account.
229+
230+
To do this, simply type:
231+
232+
`capsule.js deploy`
233+
234+
If you wish to learn more about the templates that are implemented by the
235+
deploy command, please refer to the [templates read me](docs/templates.md) file.
236+
239237
### Authorizing your certificate
240238

241239
In order to authorize your certificate you will need to log into the AWS console.
242240

243-
Depending on whether you are using DNS or Email authroitzation you will need to follow the relevant steps below.
241+
Depending on whether you are using DNS or Email authorization you will need to follow the relevant steps below.
242+
243+
244+
#### Domain configuration
245+
246+
As part of the process of creating your static site, you will need to point an existing domain or subdomain to your S3 bucket.
247+
When executing the `web` command from the cli the process will halt once it reaches the certificate manager portion.
248+
249+
At this point you should log into your AWS console and select the ` Certificate Manager` service. On this screen the domain
250+
you passed to the cli should be visible e.g. `example.com`.
251+
252+
Open up the drop-down arrow for the domain and follow the insturctions provived bu Amazon to validate control of the domain. Note that Amazon will send an email to your account at:
253+
254+
* webmaster@example.com
255+
* admin@example.com
256+
* postmaster@example.com
257+
* administrator@example.com
258+
* hostmaster@example.com
259+
260+
Where `example.com` is the domain you passed to the cli tool.
244261

245262

246263
### CloudFront waiting time
@@ -287,192 +304,28 @@ Triggers:
287304
Webhook: yes
288305
```
289306

290-
In this case, the user will need Admin permissions.
291-
292-
You will need to create a webhook in GitHub.
293-
294-
### How to use it?
295-
296-
The `ci` tool can be executed from the command line in order to setup the
297-
CodeBuild process. Located in this repository are two CodeBUild files:
298-
299-
1. `codebuild_capsule.cf` - this contains the CodeBuild CF templates for this project
300-
2. `codebuild_project.cf` - which provides a template for the Capsule user to use for their own project
301-
302-
In addition to the `ci` tool the CodeBuild cf templates can also be executed from the aws cli.
303-
304-
From the CLI it can be used like this:
305-
306-
```sh
307-
aws cloudformation create-stack \
308-
--stack-name <your-stack-name> \
309-
--template-body file://<path-to-repo>/ci/<codebuild_template>.cf \
310-
--parameters ParameterKey=CodeBuildProjectCodeName,ParameterValue=<project-name> \
311-
ParameterKey=RepositoryURL,ParameterValue=<https-clone-url> \
312-
ParameterKey=BuildSpecLocation,ParameterValue=<path-to-buildspec>
313-
```
314-
315-
Example:
316-
317-
```sh
318-
aws cloudformation create-stack \
319-
--stack-name moduscreate-labs \
320-
--template-body file://<path-to-repo>/ci/codebuild_project.cf \
321-
--parameters ParameterKey=CodeBuildProjectCodeName,ParameterValue=labs \
322-
ParameterKey=RepositoryURL,ParameterValue=https://github.com/ModusCreateOrg/labs.git
323-
```
324-
325-
#### Supported parameters:
326-
327-
- *CodeBuildProjectCodeName*: CodeBuild Project codename.
328-
- *RepositoryURL*: HTTPS URL for the Git repository. This should be a valid repository HTTPS URL.
329-
- *RepositoryType*: `CODECOMMIT`|`CODEPIPELINE`|`GITHUB`|`GITHUB_ENTERPRISE`|`BITBUCKET`|`S3`. Default: `GITHUB`.
330-
- *EnvironmentImage*: Image to use for running a container where the build will execute. Needs to respect the format `<repository>/<image>:<tag>`. Default: `aws/codebuild/ubuntu-base:14.04`
331-
- *ComputeType*: `BUILD_GENERAL1_SMALL` (Small 3 GB memory, 2 vCPU) | `BUILD_GENERAL1_MEDIUM` (Medium 7 GB memory, 4 vCPU) | `BUILD_GENERAL1_LARGE` (large 15 GB memory, 8 vCPU). Default: `BUILD_GENERAL1_SMALL`.
332-
- *BuildSpecLocation*: Path of the file `buildspec.yml` to use (Defaults to `<repo-root>/buildspec.yml`
333-
334-
335-
### Using the capsule cli:
336-
337-
The capsule cli is a NodeJS cli app with the intention to simplify the generation of the hosting infrastructure and ci infrastructure. For nested stacks, it requires to generate a base s3 bucket. This can be generated in the following way:
338-
339-
```sh
340-
$ ./capsule create --project-name <project-name> s3
341-
```
342-
343-
For getting the complete list of options, just enter `--help`:
344-
345-
```sh
346-
$ ./bin/capsule.js --help
347-
348-
Usage: capsule [options]
349-
350-
Options:
351-
352-
-V, --version Output the version number
353-
init Builds out the web hosting infrastructure in one go
354-
create Initializes the s3 bucket required to store nested stack templates
355-
update Updates the templates into the s3 bucket and runs the nested stack
356-
delete Delete the s3 bucket contents
357-
-n, --project-name <project-name> Push cf templates to the s3 bucket, and creates it if it does not exist
358-
-c, --config <config-path> Load the configuration from the specified path
359-
-p, --aws-profile <profile> The AWS profile to use
360-
-u, --url <repo> The source control URL to use
361-
-sc, --site_config <site-config> A JSON object contianing site configuration, overrides values defined in site config file
362-
-scf, --site_config_file <site-config-path> Custom configuration file used in CodeBuild for building the static site
363-
-d, --remove-cf-bucket Remove the bucket used for storing the nested templates
364-
-v, --verbose Verbose output
365-
-h, --help output usage information
366-
367-
```
368-
369-
To kick off building out a project with a single command, you can use the `init` option. The example below demonstrates this:
370-
371-
```
372-
./bin/capsule.js init --project-name "exampledotcom" --dom example.com --subdom app --url https://github.com/ExampleCom/exampledotcom --config ~/.aws/config.json --site_config='{"WebsiteCode":"."}' --site_config_file=./config/capsule.json
373-
```
374-
375-
376-
377-
#### Domain configuration
378-
379-
As part of the process of creating your static site, you will need to point an existing domain or subdomain to your S3 bucket.
380-
When executing the `web` command from the cli the process will halt once it reaches the certificate manager portion.
381-
382-
At this point you should log into your AWS console and select the ` Certificate Manager` service. On this screen the domain
383-
you passed to the cli should be visible e.g. `example.com`.
384-
385-
Open up the drop-down arrow for the domain and follow the insturctions provived bu Amazon to validate control of the domain. Note that Amazon will send an email to your account at:
386-
387-
* webmaster@example.com
388-
* admin@example.com
389-
* postmaster@example.com
390-
* administrator@example.com
391-
* hostmaster@example.com
392-
393-
Wjere `example.com` is the domain you passed to the cli tool.
394-
395-
### Future steps:
396-
397-
- The CI for the hosted project will still be using codebuild
398-
- The CI infrastructure for Capsule will be evolving soon to use codepipeline to execute several integration tests the cloudformation templates and the cli with different node versions.
399-
- Add in CloudTrail support for debugging
400-
401-
402-
## Templates
403-
404-
Capsule is made up of multiple YAML based Cloud Formation templates.
405-
406-
You can read more about AWS CloudFormation on the AWS official page:
407-
408-
https://aws.amazon.com/cloudformation/
409-
410-
A brief description of each is provided as follows.
411-
412-
### Certificates - template.certificate.yaml
413-
414-
This file handles the certificate manager portion
415-
of the CloudFormation configuration.
416-
417-
You can read more about AWS Certificate Manager here:
418-
419-
https://aws.amazon.com/certificate-manager/
420-
421-
422-
### CloudFront - template.cloudfront.yaml
423-
424-
This file contains the list of parameters required by our
425-
CloudFormation Stack including Error codes, HTTP versions and SSL supported method.
426-
CloudFront acts as a CDN. More documentation can be found at the AWS page here:
427-
428-
https://aws.amazon.com/cloudfront/
429-
430-
### CloudFront Origin Access Identity - template.cfoai.yaml
431-
432-
The CFOAI template contains the configuration required
433-
for CloudFront Origin Access Identity.
434-
435-
You can read more about CFOAI here:
436-
437-
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html
438-
439-
440-
### Route 53 - template.route53.yaml
441-
442-
Here you can find the Route 53 configuration for the static website
443-
project.
444-
445-
To learn more about Route 53 you can read the official documents here:
446-
447-
https://aws.amazon.com/route53/
307+
In this case, the user will need Admin permissions.
448308

309+
You will need to create a [webhook in GitHub](https://developer.github.com/webhooks/).
449310

450-
### S3 - template.s3.yaml
451311

452-
Amazon S3 bucket configuration can be found here.
453-
The S3 bucket is where the static resources will be uploaded to and hosted
454-
from.
312+
## Advanced Options
455313

456-
To learn more visit the official webpage here:
314+
Capsule comes with a number of advanced options. These allow:
457315

458-
https://aws.amazon.com/s3/
316+
1. A more granular deployment process
317+
2. Overridding default settings in the capsule.json with command line values
459318

460-
### CodeBuild - codebuild_project.cf
319+
To read me please check out the documentation [here](docs/advanced_use.md).
461320

462-
Included in this project are two CodeBuild Cloud Formation templates:
321+
### Templates
463322

464-
1. The template for Capsule itself
465-
2. A parameterized template for use with your own project.
323+
To learn more about the CloudFormation templates that make up a portion of the capsule project
324+
please refer to the template documentation [here](docs/templates.md).
466325

467-
CodeBuild configuration to handle:
326+
## Contibute to this project
468327

469-
1. Creating environment to check project into
470-
2. Pull code from GitHub/Source control
471-
3. Install code
472-
4. Run tests
473-
5. Create build
474-
6. Upload build to S3 bucket
475-
7. Setup trigger so that new pushes to master are built/test/deployed
328+
To learn about our contributor guidelines, please check out the documentation [here](docs/contribute.md)
476329

477330
## Modus Create
478331

bin/capsule.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ commander
165165
.command('deploy')
166166
.description('Builds out the web hosting infrastructure in one go')
167167
.action(function (options) {
168+
console.log(chalk.bgRed.bold("DO NOT CANCEL THIS PROCESS UNTIL COMPLETED"))
168169
console.log("Executing project deployment")
169170
commander.type = options._name || undefined
170171
});

config/capsule_init_questions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
"type": "input",
44
"name": "ProjectName",
5-
"message": "Enter your project name"
5+
"message": "Enter your project name (Alphanumeric and underscore characters only)"
66
},
77
{
88
"type": "input",

0 commit comments

Comments
 (0)