-
Upload to a public repository
-
DE-829 Finish Serverless configuration
- Configure API Gateway? Could it be replaced by Cloudflare?
- Take a look to Juane's examples
- Take a look to Serverless TypeScript Starter
-
DE-830 CD in our Jenkins deploying to AWS
- Docker image with Serverless https://hub.docker.com/r/20minutes/node-16-yarn-serverless-3
- Docker image with Serverless https://hub.docker.com/r/amaysim/serverless
-
DE-831 Expose API in a friendly domain
-
DE-832 Token JWT validation
- ✔️ JWT Validation runs in the API Gateway or inside the lambdas?
- ✔️ JWT payload should be available inside the lambdas
-
Add all CI validation steps that we run in other projects
-
Nice to have
This template demonstrates how to make a simple HTTP API with Node.js running on AWS Lambda and API Gateway using the Serverless Framework.
This template does not include any kind of persistence (database). For more advanced examples, check out the serverless/examples repository which includes Typescript, Mongo, DynamoDB and other examples.
For the moment, we decided to share a bucket for all lambda functions in the same environment, so we have three:
doppler-fun-int-us-east-2
doppler-fun-qa-us-east-2
doppler-fun-production-us-east-2
Each of them has been created manually using the S3 Buckets page.
We are using a custom domain for each environment:
{custom-domain}.fromdoppler.com/lambdas-poc/
➡lambdas-poc-production
API{custom-domain}qa.fromdoppler.net/lambdas-poc/
➡lambdas-poc-qa
API{custom-domain}int.fromdoppler.net/lambdas-poc/
➡lambdas-poc-int
API
Our custom domain is managed by Cloudflare.
- Create a certificate
- Validate certificate
- Create custom domain in AWS
- Add DNS to the custom domain
- Configure mappings
Now it is done by code 😀
$ serverless deploy
After deploying, you should see output similar to:
Deploying aws-node-http-api-project to stage dev (us-east-1)
✔ Service deployed to stack aws-node-http-api-project-dev (152s)
endpoint: GET - https://xxxxxxxxxx.execute-api.us-east-1.amazonaws.com/
functions:
hello: aws-node-http-api-project-dev-hello (1.9 kB)
Note: In current form, after deployment, your API is public and can be invoked by anyone. For production deployments, you might want to configure an authorizer. For details on how to do that, refer to http event docs.
After successful deployment, you can call the created application via HTTP:
curl https://xxxxxxx.execute-api.us-east-1.amazonaws.com/
Which should result in response similar to the following (removed input
content for brevity):
{
"message": "Go Serverless v2.0! Your function executed successfully!",
"input": {
...
}
}
You can invoke your function locally by using the following command:
serverless invoke local --function hello
Which should result in response similar to the following:
{
"statusCode": 200,
"body": "{\n \"message\": \"Go Serverless v3.0! Your function executed successfully!\",\n \"input\": \"\"\n}"
}
Alternatively, it is also possible to emulate API Gateway and Lambda locally by using serverless-offline
plugin. In order to do that, execute the following command:
serverless plugin install -n serverless-offline
It will add the serverless-offline
plugin to devDependencies
in package.json
file as well as will add it to plugins
in serverless.yml
.
After installation, you can start local emulation with:
serverless offline
To learn more about the capabilities of serverless-offline
, please refer to its GitHub repository.