It's time to start building our serverless backend!
In this quick lesson we're going to use the lambda.Function
construct imported from @aws-cdk/aws-lambda
in order to build and deploy a 'Hello World!' AWS Lambda function.
You can find out more about what kind of constructs are available in AWS CDK construct library here
Hey Tomasz, I think you forgot to mention, that before running cdk deploy
you also have to run npm run build
to compile the code in lambda
folder. Otherwise, CDK will just upload just the TypeScript file and it's not going to work in AWS Lambda.
I had to bootstrap before running cdk deploy
. Once that completed I ran cdk deploy
and no errors. The exact error message I was getting was: TodoappStack failed: Error: This stack uses assets, so the toolkit stack must be deployed to the environment (Run "cdk bootstrap aws://unknown-account/unknown-region")
Thanks for this. It was really helpful to get started. One issue I had was using 3rd party node packages (I'm using FaunaDB) in my code. Somehow I missed the description of how to do this in a later lesson. After using my overcomplicated workaround, I found a much better way in lesson 22.
The link to the code seems to be broken - I get a 404
Link to code https://github.com/tlakomy/egghead-build-an-app-with-aws-cloud-development-kit/tree/create-a-lamba-function-with-cdk
Link to code https://github.com/tlakomy/egghead-build-an-app-with-aws-cloud-development-kit/tree/create-a-lamba-function-with-cdk
Thanks for this @Milan! I got the code link updated! 🙌