what's cooking? lambdas!
see at lambdas
folder
lambdas/
├── go-microservice-handlers-terraform
├── go-monolithic-http-terraform
├── typescript-handler-awscli
├── typescript-layer-serverless
├── typescript-microservice-handlers-sam
├── typescript-monolithic-express-sam
└── typescript-monolithic-proxy-serverless
- make
- aws
- sam
- terraform
- go
- node
- yarn
yarn install
yarn nx -- <command>
###
# shows workspace graph
yarn nx -- graph
# show project individual commands
cd lambdas/<project> && make help
by default serverless/sam creates one bucket for each lambda, and thats a problem because the account bucket limit is 100 by default
plugin: serverless-domain-manager
to stage path e.g www.domain/`dev`/images
Configure serverless-domain-manager config basePath
to '${sls:stage}/'
The best way is to use aws SSM, see also
And follow this pattern in serverless.yml:
MY_VAR: ${ssm:/${sls:stage}/MY_VAR}
note the sls:stage, witch guarantees staging note that ssm var work like paths so they always start with a forward slash (/)
- Add the vars after deploy with a script
or
- Use the cdk for iam/secrets manager
Do this to cut costs
Theres no cli option or config to that, but the best workaround is to manipulate permissions.
You either just disallow the cloudwatch or only allow lambda creation.
You could create a aws role
or declare the policie directly on the yaml
example:
#only allow functions
iam:
role:
statements:
- Effect: 'Allow'
Action:
- 'lambda:InvokeFunction'
Resource: '*'
Policie to disallow cloudwatch Serverless iam docs
-
organize lambdas: https://aws.amazon.com/blogs/compute/best-practices-for-organizing-larger-serverless-applications/
-
typescript power-tools: https://aws.amazon.com/blogs/compute/simplifying-serverless-best-practices-with-aws-lambda-powertools-for-typescript/
-
memory optimization: https://theburningmonk.com/2020/03/how-to-optimize-lambda-memory-size-during-ci-cd-pipeline/ https://medium.com/geekculture/pick-the-right-memory-size-for-your-aws-lambda-functions-682394aa4b21
- monolithic go https://github.com/build-on-aws/golang-apis-on-aws-lambda
- microservice go https://github.com/aws-samples/serverless-go-demo
- monolithic typescript https://github.com/rodrigokamada/nodejs-aws-lambda