You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-7Lines changed: 19 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,8 +35,9 @@ We use the following tools:
35
35
during the build and write the results to a cache file to be included in the
36
36
bundle; then when the Lambda service starts up it can read from the cache
37
37
rather than introspecting the database again.
38
+
- serverless.js (optional) - for automated AWS deployments.
38
39
39
-
## Building lambda.zip
40
+
## Setup
40
41
41
42
First clone this repository locally, and install dependencies:
42
43
@@ -50,18 +51,29 @@ Next, set up a `.env` file matching your environment:
50
51
cp .env.template .env
51
52
```
52
53
53
-
And modify the `src/postgraphileOptions.js`file to your taste.
54
+
And modify the `src/postgraphileOptions.js`and `serverless.yml` files to your taste.
54
55
55
-
Finally run:
56
+
## Automatic Deployment with Serverless.js
57
+
58
+
#### Deployment Prerequisites
59
+
60
+
-[serverless](https://serverless.com/framework/docs/providers/aws/guide/installation/) - `yarn global add serverless`
61
+
62
+
After configuring your `.env` file, ~/.aws/credentials, and postgraphileOptions.js, you can deploy to AWS using serverless.js by running:
56
63
57
64
```
58
-
yarn build
65
+
yarn deploy
59
66
```
60
67
61
-
This will result in a `lambda.zip` file that you can upload to Amazon Lambda.
68
+
## Setting up a Lambda endpoint manually
69
+
70
+
If you prefer not to use the serverless.js framework, you can also deploy your lambda function manually.
71
+
72
+
Note 1: Change your process.env.AWS_STAGE_NAME to "/default" to match the default stage name for manually deployed API Gateways.
62
73
63
-
## Setting up a Lambda endpoint
74
+
Note 2: CORS is enabled by default. Remove cors() middleware in `/src/index.js` if you would prefer disabled cors.
64
75
76
+
0. Run `yarn build` to create `lambda.zip` file that you can upload to Amazon Lambda.
65
77
1. Visit https://console.aws.amazon.com/lambda/home and click 'Create function'
66
78
2. Select "Author from scratch" and give your function a name, select the most recent Node.js release (at least 8.10+), create (or select) a role (I granted "Simple microservice permissions")
67
79
3. Click "Create function" and wait about 15 seconds; you should be greeted with a "Congratulations" message.
@@ -171,7 +183,7 @@ Do the same as for the test, but instead of running `yarn test` at the end, inst
171
183
yarn sam
172
184
```
173
185
174
-
This will set up a local GraphQL endpoint at http://127.0.0.1:3000/
186
+
This will set up a local GraphQL endpoint at http://127.0.0.1:3000/graphql
175
187
176
188
You can then use a GraphQL client such as Altair or GraphQL Playground to issue requests.
0 commit comments