This repository contains CloudFormation configuration to run a stack of the Rural Accessibility Map on AWS. It spins up:
- a machine to run the API
- a machine with Nginx to run the interface
- Fargate instances for the background processes
- RDS for the database
- a S3 bucket for file storage
More information about RAM can be found in the docs.
- nodejs 8 or higher
- yarn
$ yarn
$ cp .kes/.env.sample .kes/.env
Follow these steps before deploying the first stack:
- On AWS, manually create the following:
- A S3 bucket where the CloudFormation configuration will be stored. This bucket can be shared by different stacks.
- A key pair, which can also be shared by multiple stacks in the same account.
- Add both to the
.kes/config.yml
:- the S3 bucket under
default.bucket
- the key pair under
default.ecs.keyPairName
- the S3 bucket under
- Set the environment variables in
.kes/.env
This configuration is shared between different stacks. If you run multiple stacks, you only have to do this once.
To deploy a new stack:
- Add a new stack to
.kes/config.yml
The new stack will inherit all configuration from the default stack. It's possible to override some or all of the configuration.ram-my-deployment: stackName: ram-another-instance
- run kes deploy
$ ./node_modules/.bin/kes cf deploy --deployment ram-my-deployment --region us-east-1
Once the deploy finishes (which may take a while), Kes prints information about the stack. This includes IP addresses and the database connection string. Use this connection string to set up the database structure:
$ yarn setup --db postgres://your:own@connection:1234/string
Deleting a stack will take all resources down, but keep the S3 bucket that was created by the stack for file storage. It can be manually deleted.
To validate the CloudFormation configuration without deploying the stack:
./node_modules/.bin/kes cf validate
This will generate the .kes/cloudformation.yml
.