|
| 1 | +# Serverless Stack |
| 2 | + |
| 3 | +This repository contains all my serverless functions currently hosted on AWS. |
| 4 | + |
| 5 | +## Configuration |
| 6 | + |
| 7 | +Create AWS access as described [here][aws-setup-link]. |
| 8 | +Using the received credentials, add a profile to `~/.aws/credentials`: |
| 9 | + |
| 10 | +``` |
| 11 | +[profileName] |
| 12 | +aws_access_key_id=*************** |
| 13 | +aws_secret_access_key=*************** |
| 14 | +``` |
| 15 | + |
| 16 | +## Setup |
| 17 | + |
| 18 | +[Serverless][sls] is included as a dependency in the root of the repository to make sure the version is pinned cross functions. |
| 19 | +It's advised to use `yarn` over `npm` as we're 2018 (and it's faster too 😄). |
| 20 | + |
| 21 | + $ yarn install |
| 22 | + |
| 23 | +When you want to initialize a function, navigate to the folder and install it's dependencies. |
| 24 | + |
| 25 | + $ cd github-webhooks |
| 26 | + $ yarn install |
| 27 | + |
| 28 | +Each function is configured to use serverless included in the root of the repository. |
| 29 | + |
| 30 | +## Debugging |
| 31 | + |
| 32 | +I advice to use [Visual Studio Code][vscode] given that the debug task is included in the project, feel free to create a PR if you wan't to add other integrations. Pressing `F5` will use [serverless-offline][sol] to start a debug session and run the function. |
| 33 | + |
| 34 | +_Beware: setting breakpoints might tell you they can't be bound, this is not true._ |
| 35 | + |
| 36 | +Use any tool of choice to invoke http functions and have fun. |
| 37 | + |
| 38 | +## Secure Variables |
| 39 | + |
| 40 | +The runtime variables are included in the project. The [serverless-secrets-plugin][sspl] is used to encrypt and decrypt them. |
| 41 | + |
| 42 | + $ yarn sls encrypt --password correcthorsebatterystaple --stage production |
| 43 | + |
| 44 | +## Deployment |
| 45 | + |
| 46 | +You can deploy individual functions using serverless. Navigate to the function you wish to deploy and use the deploy command. |
| 47 | + |
| 48 | + $ yarn sls deploy --verbose --aws-profile profileName |
| 49 | + |
| 50 | +[aws-setup-link]: https://serverless.com/framework/docs/providers/aws/guide/credentials#creating-aws-access-keys |
| 51 | +[sls]: https://serverless.com/ |
| 52 | +[vscode]: https://code.visualstudio.com/ |
| 53 | +[sspl]: https://github.com/serverless/serverless-secrets-plugin |
| 54 | +[sol]: https://github.com/dherault/serverless-offline |
0 commit comments