Skip to content

Commit 0b468e0

Browse files
Merge pull request #71 from fredliporace/docs
Deployment instructions
2 parents d8e375a + 605a929 commit 0b468e0

File tree

3 files changed

+61
-91
lines changed

3 files changed

+61
-91
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Development Seed runs an instance of sat-api for the Landsat-8 and Sentinel-2 im
99

1010
## Documentation
1111

12-
The docuementation includes information on the STAC spec, how to use the API, manage Elasticsearch, as well as how to deploy your own API on AWS. Access the documentation [here](docs) or on [gitbook](https://sat-utils.gitbook.io/sat-api/).
12+
The documentation includes information on the STAC spec, how to use the API, manage Elasticsearch, as well as how to deploy your own API on AWS. Access the documentation [here](docs) or on [gitbook](https://sat-utils.gitbook.io/sat-api/).
1313

1414

1515
## Development

docs/deploy.md

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,74 @@
1-
# Deploy your own sat-api
1+
# Example sat-api Deployment
22

3-
Work is ongoing to simplify the deployment process, but the following steps should get you started:
3+
This deployment powers https://sat-api.developmentseed.org/search. We use [kes](https://www.npmjs.com/package/kes) to deploy sat-api as an application to AWS.
44

5-
1. Make sure you have AWS credentials with necessary access to AWS Lambda and AWS APIGateway (an admin level access will do enough).
5+
For the deployment to work we use a kes template included in the [@sat-utils/api](https://www.npmjs.com/package/@sat-utils/api) package. This package has all the necessary resources needed for a successful deployment of sat-api.
66

7-
2. To simplify deployment to AWS, we make use of [`kes`](http://devseed.com/kes/), a tool for CloudFormation deployment. It can be installed with:
7+
You can override all the configurations and options in this template by adding override files to the `.kes/config.yml` folder.
88

9-
$ npm install -g kes
9+
## Install
1010

11-
3. You MUST create a bucket on S3 that is used for storing deployment artifacts and metadata csv files.
11+
$ yarn install
1212

13-
4. Update `.kes/config.yml` and enter the name of the bucket.
13+
## Deploy with unpublished code
1414

15-
5. If direct access to the elasticsearch instance is needed from fixed IP address, copy `.env.example` to `.env` and add your IP address there.
15+
If you need to use the latest code on the master branch that is not released to npm yet, or if you need to do live development on an instance deployed to AWS (not recommended), you should follow these steps:
1616

17-
6. Deploy the system with `kes`. It can take some time for AWS to create the various resources, so be patient.
17+
- Clone this repo and install requirements ([follow](../README.md#local-installation))
18+
- At the repo root run: `yarn linkall` (this will link packages to your local npm).
19+
- In the deployment repository (e.g. `example` folder) run the link command with the package name you are using:
20+
- `yarn link @sat-utils/api`
21+
- In the `example` folder we have included a shortcut: `yarn linkall`
22+
- Verify packages are linked: `ls -la node_modules/@sat-utils`
23+
- This show an output similar to: `lrwxr-xr-x 1 user staff 29 Jul 11 14:19 api -> ../../../sat-api/packages/api`
1824

19-
$ kes cf deploy -r us-east-1
20-
21-
Replace `us-east-1` with any desired region. This will deploy the CloudFormation stack, which includes:
25+
To restore packages from npm just run `yarn`.
2226

23-
* API Gateway
24-
* Lambda functions
25-
* Step Functions
26-
* CloudWatch Rules
27-
* Elasticsearch
28-
* Associated IAM Roles
27+
## Deploy an instance
2928

30-
Additional calls of `kes cf deploy` will update the existing CloudFormation stack (see below on building the deployment distribution).
29+
Make sure the you add a deployment to `.kes/config.yml` by adding the following to the file:
3130

32-
7. Once the system is initialized, go to the API Gateway console and select the "sat-api-..." entry, click on the _Settings_ menu, and then click _Add Binary Media Type_ option and add `'*'` as the Binary media type.
31+
```yaml
32+
name-of-my-deployment:
33+
stackName: <name-of-my-stack>
34+
system_bucket: <a s3 bucket I have access to>
35+
```
36+
37+
Then run this command:
38+
39+
$ ./node_modules/.bin/kes cf deploy --region us-east-1 --profile <profile-name> --template node_modules/@sat-utils/api/template --deployment <name-of-deployment> --showOutputs
40+
41+
The command will return the api endpoint that is created by the operation.
3342
3443
The Landsat and Sentinel ingestors are run as Step Functions every 12 hours (Landsat at 6:00 and 18:00, Sentinel at 0:00 and 12:00), as can be seen under the CloudWatch Rules console. They can be disabled from the console.
3544
45+
### Deploy Devseed's Dev stack
46+
47+
This command only works if you have access to Devseed's AWS account
48+
49+
$ ./node_modules/.bin/kes cf deploy --region us-east-1 --template node_modules/@sat-utils/api/template --deployment dev --profile <replace-me> --showOutputs
50+
51+
### Deployer Role
52+
53+
For the CI environment, we use a special IAM role that is assumed by an AWS user. This will allow us to give limited access to the user that is used inside the CI build environment.
54+
55+
To create the deployer role run:
56+
57+
$ ./node_modules/.bin/kes cf deploy --kes-folder deployer --profile ds --region us-east-1 --showOutputs
58+
59+
Then create a user on AWS and give it this policy permission. Replase the value of the resource with the output of the previous command:
60+
61+
```json
62+
{
63+
"Version": "2012-10-17",
64+
"Statement": [
65+
{
66+
"Effect": "Allow",
67+
"Action": "sts:AssumeRole",
68+
"Resource": "<arn:DeployerRole>"
69+
}
70+
]
71+
}
72+
```
73+
74+
When running the deployment command make sure to [include the `--role` flag](.circleci/config.yml#L17).

example/README.md

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,3 @@
11
# Example sat-api Deployment
22

3-
This deployment powers https://sat-api.developmentseed.org/search. We use [kes](https://www.npmjs.com/package/kes) to deploy sat-api as an application to AWS.
4-
5-
For the deployment to work we use a kes template included in the [@sat-utils/api](https://www.npmjs.com/package/@sat-utils/api) package. This package has all the necessary resources needed for a successful deployment of sat-api.
6-
7-
You can override all the configurations and options in this template by adding override files to the `.kes/config.yml` folder.
8-
9-
## Install
10-
11-
$ yarn install
12-
13-
## Deploy with unpublished code
14-
15-
If you need to use the latest code on the master branch that is not released to npm yet, or if you need to do live development on an instance deployed to AWS (not recommended), you should follow these steps:
16-
17-
- Clone this repo and install requirements ([follow](../README.md#local-installation))
18-
- At the repo root run: `yarn linkall` (this will link packages to your local npm).
19-
- In the deployment repository (e.g. `example` folder) run the link command with the package name you are using:
20-
- `yarn link @sat-utils/api`
21-
- In the `example` folder we have included a shortcut: `yarn linkall`
22-
- Verify packages are linked: `ls -la node_modules/@sat-utils`
23-
- This show an output similar to: `lrwxr-xr-x 1 user staff 29 Jul 11 14:19 api -> ../../../sat-api/packages/api`
24-
25-
To restore packages from npm just run `yarn`.
26-
27-
## Deploy an instance
28-
29-
Make sure the you add a deployment to `.kes/config.yml` by adding the following to the file:
30-
31-
```yaml
32-
name-of-my-deployment:
33-
stackName: <name-of-my-stack>
34-
system_bucket: <a s3 bucket I have access to>
35-
```
36-
37-
Then run this command:
38-
39-
$ ./node_modules/.bin/kes cf deploy --region us-east-1 --profile <profile-name> --template node_modules/@sat-utils/api/template --deployment <name-of-mystack> --showOutputs
40-
41-
The command will return the api endpoint that is created by the operation.
42-
43-
### Deploy Devseed's Dev stack
44-
45-
This command only works if you have access to Devseed's AWS account
46-
47-
$ ./node_modules/.bin/kes cf deploy --region us-east-1 --template node_modules/@sat-utils/api/template --deployment dev --profile <replace-me> --showOutputs
48-
49-
### Deployer Role
50-
51-
For the CI environment, we use a special IAM role that is assumed by an AWS user. This will allow us to give limited access to the user that is used inside the CI build environment.
52-
53-
To create the deployer role run:
54-
55-
$ ./node_modules/.bin/kes cf deploy --kes-folder deployer --profile ds --region us-east-1 --showOutputs
56-
57-
Then create a user on AWS and give it this policy permission. Replase the value of the resource with the output of the previous command:
58-
59-
```json
60-
{
61-
"Version": "2012-10-17",
62-
"Statement": [
63-
{
64-
"Effect": "Allow",
65-
"Action": "sts:AssumeRole",
66-
"Resource": "<arn:DeployerRole>"
67-
}
68-
]
69-
}
70-
```
71-
72-
When running the deployment command make sure to [include the `--role` flag](.circleci/config.yml#L17).
3+
See [documentation](../docs/deploy.md)

0 commit comments

Comments
 (0)