Simple lambda based on express, typescript and bundled with rollup.
- Have AWS account ;)
- Install nvm - https://github.com/nvm-sh/nvm
- Install aws cli - https://aws.amazon.com/cli/
- Install jq - https://stedolan.github.io/jq/
Simply by nvm use && npm install.
Run on local by npm start.
Before executing blindly, just think of to what function has to have access, current one has access to everything.
After you're done with selecting just run aws iam create-role --role-name lambda_rollup_role --assume-role-policy-document file://aws/function_role.json and make sure to copy the output ARN of role
For initial build run: rollup -c rollup.config.json.
To pack everything to one zip file run cd dist && zip -rq ./lambda.zip ../node_modules ./handler.js && cd ..
Now simply create function and upload the zip file by running:
aws lambda create-function --region eu-central-1 --function-name lambda-rollup --zip-file fileb://dist/lambda.zip --role <your_arn_from_above> --handler handler.handler --runtime nodejs8.10
To test successful deployment simply run:
aws lambda invoke --function-name lambda-rollup --payload file://events/alb.json --region eu-central-1 out.txt
Feel free to change the event. Currently loadbalancer lambda event is in use.
Just run ./deploy.sh!
What does it do?
- builds app to ./dist/handler.js
- creates zip with node_modules and handler
- uploads incremental update to aws
- invokes lambda to test if it really works