Setup AWS Serverless Project with Typescript Lambda Functions

  Рет қаралды 31,337

CodeDunks

CodeDunks

Күн бұрын

I will guide you guys on setting up a serverless project with typescript lambda functions for AWS. I will help in setting up some example HTTP triggered lambdas, as well as an SNS topic trigger lambda. I will also show how to configure serverless to deploy to AWS as well as run in offline mode and how to debug your lambdas locally.
Starter Project link: github.com/leoroese/aws-ts-se...
Finished: github.com/leoroese/aws-ts-se...
Useful Documentation
Serverless: www.serverless.com/framework/...
DefinatelyTyped: github.com/DefinitelyTyped/De...
Timestamps
0:00 intro
0:30 what is serverless
4:40 project start setup
7:30 serverless config
10:30 http triggered lambdas
14:28 serverless deploy
16:55 sns resource
18:40 sns triggered lambda
19:56 serverless offline
25:20 setup debugging

Пікірлер: 51
@CodeDunks
@CodeDunks 3 жыл бұрын
Assumption was that AWS may have been configured on your machine already. But if not you can quickly follow along here: documentationnerds.com/blog/tech/configure-aws-cli
@tdelam
@tdelam 2 жыл бұрын
Site is offline for me atm.
@mosespeter9711
@mosespeter9711 Жыл бұрын
This is undoubtably the best serverless video on internet
@tarunhasija4751
@tarunhasija4751 9 ай бұрын
After investing over 48 hours into learning about serverless from various sources and blogs, I was surprised to find that this video managed to encapsulate the entire topic in just under 30 minutes. Outstanding job, Leo!
@supa1009
@supa1009 2 жыл бұрын
bro you are my hero, this tutorial really helped me to deploy my existing project!
@CodeDunks
@CodeDunks 2 жыл бұрын
Glad I could help!
@seeds_of_growth-yi5gx
@seeds_of_growth-yi5gx Жыл бұрын
Thanks a lot, for being on-point and touching upon important parts of the topic. On the debug section, in the run configs, the "protocol" is not longer supported, and for me it was just exiting with 1 so I added the --verbose flag to know what's going on, and just adding --verbose as follows, solved the problem and the debugger works great! "args": ["offline", "start", "--httpPort", "4000", "--noTimeout", "--verbose"], Cheers!
@LodkaGG
@LodkaGG 4 ай бұрын
Thank you very much man, you teaching so clearly, that's cool for sure
@guillermovillalta6322
@guillermovillalta6322 2 жыл бұрын
Just got a new subscriber, great content. This is awesome!
@toan_tan
@toan_tan 2 жыл бұрын
Hi, Very useful video. Thank you a lot! 😄
@andrewdelmonte1172
@andrewdelmonte1172 2 жыл бұрын
This is dope man thank you
@user-sv2hb9ik2u
@user-sv2hb9ik2u 14 күн бұрын
Very helpful. Thank you
@HughHopkins
@HughHopkins Жыл бұрын
Great video, thank you so much
@joshvanriel5176
@joshvanriel5176 Жыл бұрын
Awesome vid. Subbed!
@khandoor7228
@khandoor7228 2 жыл бұрын
Great tutorial Leo, I use a lot of AWS + Serverless would love to see more, especially queryStringParameters with Lambdas and Dynamo tables. If you could do a video on pathParameters for pagination and searching by queryStringParameters I think would be awesome. just an idea.
@CodeDunks
@CodeDunks 2 жыл бұрын
Thanks, KhanDoor! Yeah, I personally love using Serverless, I hope to eventually get to learn about those things you mentioned and if I do I will be sure to make a video on it!
@iamdhison
@iamdhison 2 жыл бұрын
Amazing video bro. I am struggling to debug typescript aws cdk lambda. It will be very great if you post video for that as well.
@sahej97
@sahej97 3 жыл бұрын
Nice intro and tutorial
@CodeDunks
@CodeDunks 3 жыл бұрын
Thank you!
@ChrisTian-ox5nr
@ChrisTian-ox5nr 2 жыл бұрын
Legend!
@dontdoit6986
@dontdoit6986 2 жыл бұрын
Dude Amazing! Great video. Super helpful! Question: feelings on terraform?
@CodeDunks
@CodeDunks 2 жыл бұрын
Thanks Christopher, my feelings is that I wish I had more time to be able to get my hands dirty with it haha. I've heard good things about it though!
@alanrodriguezw.9149
@alanrodriguezw.9149 2 жыл бұрын
Thanks You!!
@ajithxyz
@ajithxyz 2 жыл бұрын
Hi- Is there a way you can add a lambda layer demo as well?
@mugdhawadhokar1071
@mugdhawadhokar1071 2 ай бұрын
hey great video. Here I am confuse about invcocation API, why does it generates and can we avoid it from generating ?
@76Freeman
@76Freeman 2 жыл бұрын
Hi Leo, Great video, I've just stepped in the land of Serverless :) and your video was of great help. I'm wondering if you've ever used it in conjunction with Hasura? Thank you again
@CodeDunks
@CodeDunks 2 жыл бұрын
I have not had the chance to use Hasura but I have heard good things about it.
@76Freeman
@76Freeman 2 жыл бұрын
​@@CodeDunks I'm actually working with it right now and I need to create a user when a user confirms his signup. Do you know I could test a lambda that is triggered when the user confirms the signup. Right now I'm getting an error "Unrecognizable lambda output" This is my lambda: import { GraphQLClient } from 'graphql-request'; import { Callback, Context } from 'aws-lambda'; const adminSecret = process.env.ADMIN_SECRET; const hgeEndpoint = process.env.HGE_ENDPOINT; export const handler = async (event: any, context: Context, callback: Callback): Promise => { try { const headers = { headers: { 'x-hasura-admin-secret': adminSecret as string, }, }; const graphqlClient = new GraphQLClient(hgeEndpoint as string, headers); const qv = { email: event.request.userAttributes.email, }; await graphqlClient.request( `mutation InsertUser($user: users_insert_input!) { insert_users_one(object: $user) { id } }`, qv ); callback(null, event); } catch (e) { console.warn('error', e); callback(null, false); } };
@glenjensen3683
@glenjensen3683 3 жыл бұрын
as Luke as all ready requested, could you please do a quick addition or just foot note to this video where you talk about how to have each Lambda be self contain and deployable on it's own as well as having a parent template that imports all others, giving the option to either deploy all Lambdas at once or just a single Lambda. It is something that I see a lot of projects that grow in size require, but often hit a road block on as they are all written with the intent to deploy all Lambdas at once.
@CodeDunks
@CodeDunks 3 жыл бұрын
Oh I haven't quite come across that recently. I will try and get around to it if I can!
@xukhanh
@xukhanh 3 жыл бұрын
How can I setup the command 'template-cli' like you do? Would you mind share some tutorial about it?
@CodeDunks
@CodeDunks 3 жыл бұрын
Hey there you can look at either my video or article I made about it. Video: kzbin.info/www/bejne/rorOoGWYfbOajKM Article: documentationnerds.com/blog/tech/template-cli-with-node-and-inquirer
@ashrutinayak4079
@ashrutinayak4079 2 жыл бұрын
@leo Roese can you Please guide me? I am confused in two type serverless project build one HTTP API nodejs and express API node. what's different in that and when we create http api nodejs project and when we create express api nodejs project?
@lowkeygaming4716
@lowkeygaming4716 2 жыл бұрын
Is it okay to use the lambda without using the APi Gateway too? And does lambda support Class based node js app?
@lukewyman1
@lukewyman1 3 жыл бұрын
Show us how to do a multi-module (like, a serverless.yml and package.json for each module, where what goes in common vs each module, that kinda thing). Pleez, pretty pleez? Also, any thoughts for chosing between mocha and jest? I was going to go with mocha, as it seems to have larger market share (maybe?), but I'm seeing that coverage, expect, etc for mocha has additional dependencies, like chai and istanbul to install, and configuration doesn't look as easy and breezy as with jest.
@CodeDunks
@CodeDunks 3 жыл бұрын
I've worked with both mocha and jest and found that the overall experience with Jest is a lot better in my own personal opinion. Every industry position I've worked on has also used Jest
@seeds_of_growth-yi5gx
@seeds_of_growth-yi5gx Жыл бұрын
Why in the hello arg is _event, and goodbye is just event without underscore ?
@betheleyo2701
@betheleyo2701 Ай бұрын
Good work, but you missed explaining all the permissions in an aws iam policy file that is needed to be able to run a successful "serverless deploy" command, it took me a while to have that set up
@glenjensen3683
@glenjensen3683 3 жыл бұрын
I'm experiencing a peculiar error, and I'm hoping that you might have seen the same one. When I run local testing, everything works fine with imported modules. But when I deploy it to lambdas, any handler that use a library from a separate file will crash with "cannot find module as if dependencies aren't being installed. However any dependencies directly in a handler file works just fine.
@CodeDunks
@CodeDunks 3 жыл бұрын
Hey Glen, when you say a library from a separate file what do you mean? For example, if you have this lambda project as a sub repository and are accessing another sub repositories interface then this is expected. The reason for that is that serverless will only package up the lambda projects files. So locally it works because it can access the "other library" on your local machine, but that "other library" does not exist within the package on AWS. This link might be of some use also aws.amazon.com/premiumsupport/knowledge-center/lambda-deployment-package-nodejs/
@glenjensen3683
@glenjensen3683 3 жыл бұрын
​@@CodeDunks Hello Leo, from further investigation I can see that it is just any node module that cannot be found. Which perplexes me greatly, as I've followed the same structure as you have. From the link you send, do I understand correctly that this article wants me to change my code structure to have functions in root with package.json?
@CodeDunks
@CodeDunks 3 жыл бұрын
@@glenjensen3683 Hmm that is odd. Couple of things you can try. 1) run yarn install again to make sure dependencies are installed correctly 2) run "yarn sls package -s dev" then check in your .serverless folder in the root of your current directory for your projects generated zip, then within that zip see that node_modules is in there with whatever dependency it says that it's missing. 3) If all else fails, try possibly copying the project from my repo in the description and see if that works.
@xmaxfuture
@xmaxfuture 2 жыл бұрын
i get a "message": "Bad request", code: 400. i cant find the solution
@lcrazyvinil
@lcrazyvinil 2 жыл бұрын
Using AWS lambda I'll have a lot of external IPs? I need an cheap solution to run my API with a lot of external IPs.
@CodeDunks
@CodeDunks 2 жыл бұрын
I am not entirely sure what is being asked here. Could you elaborate?
@Rekefa
@Rekefa 2 жыл бұрын
What a great terminal, do you have the config files for it?
@CodeDunks
@CodeDunks 2 жыл бұрын
Hey Rekefa, I actually just got a new computer and therefore don't have the configs yet. But here is the article I used to kinda set it up. Its a combination of windows terminal and cmder. medium.com/talpor/windows-terminal-cmder-%EF%B8%8F-573e6890d143
@Rekefa
@Rekefa 2 жыл бұрын
@@CodeDunks Thank you very much!
@limpep
@limpep 3 ай бұрын
s3 triggers, schedulers
@igoralves1
@igoralves1 2 жыл бұрын
Have been working with serverless some yrs now. Do not mix serverless concept and microservices. There are some microservices written in nodejs in a ec2 container that are not serverless and there are some serverless system that are not microservices at all. And there are some real serverless microservices and on top of this concepts there are lambdas vs non lambdas microservices and also lambdas that are restful apis or a simple lambda with no endpoint....also that brings the idea of Functional paradigm vs oop in lambdas/serverless/microservices approach....
Setup Lerna Monorepo with Husky
18:45
CodeDunks
Рет қаралды 8 М.
Getting started with AWS Lambda and Serverless Framework
35:18
Tomasz Tarnowski
Рет қаралды 9 М.
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 33 МЛН
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Паша Осадчий
Рет қаралды 9 МЛН
How Many Balloons Does It Take To Fly?
00:18
MrBeast
Рет қаралды 168 МЛН
Create Your First AWS Lambda Function | AWS Tutorial for Beginners
12:44
Tiny Technical Tutorials
Рет қаралды 132 М.
That's It, I'm Done With Serverless*
23:58
Theo - t3․gg
Рет қаралды 198 М.
Serverless Framework with AWS Lambda Crash Course
1:29:11
Laith Academy
Рет қаралды 110 М.
Deploy a Nest.js App With Serverless (Cheap & Easy)
12:22
Michael Guay
Рет қаралды 36 М.
Debugging AWS typescript lambdas
8:11
Concise Developer
Рет қаралды 2,1 М.
Serverless Offline for testing on your local machine. Tutorial with DynamoDB
18:16
Complete Coding - Master AWS Serverless
Рет қаралды 35 М.
🆕  Write your Lambda functions using Typescript with AWS SAM
15:53
FooBar Serverless
Рет қаралды 12 М.
Develop Lambdas Locally in VS Code Using AWS SAM | AWS Lambda Tutorial
15:50
Getting Started with Serverless Framework
20:53
Serverless
Рет қаралды 30 М.
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 33 МЛН