Check out a free preview of the full Serverless with AWS Lambda course

The "AWS Event Types" Lesson is part of the full, Serverless with AWS Lambda course featured in this preview video. Here's what you'd learn in this lesson:

After saying that AWS has a growing list of event types that Lambdas can subscribe to, Scott demonstrates some of the common event types.

Preview
Close

Transcript from the "AWS Event Types" Lesson

[00:00:00]
>> Scott: All right, so let's get into the next topic which is gonna be event types. So I'm gonna go to my AWS here.
>> Scott: Or one of the ones I made for this.
>> Scott: Yeah, go there.
>> Scott: See if I can remember the login here.
>> Scott: Yea, all right, so this is the AWS console.

[00:00:37]
It looks better than it used to be. But [LAUGH] it's still the AWS console. I always make a joke that if you click on this Service tab and you pick two things, maybe three, and build a GUI around it, you got a startup. That's a startup.
>> [LAUGH]

[00:00:54]
>> Scott: Any two or three of these things. You'd probably get away with one. And you just build a better experience over it, and then you got to startup and they'll buy you, that's it. So if you're thinking about it, just remember you learned it here.
>> [LAUGH]
>> Scott: So we're gonna go to the lambdas, and this is where you're gonna be doing most of your work.

[00:01:16]
So what we just did before was we wrote a lambda on our machine, we didn't deploy it but we wrote a lambda there. Now I'm going to show you what you would have to do if you didn't have serverless framework, and how when lambda first came out what you basically did.

[00:01:30]
So you can see right here I only have one lambda here for this region in Northern California. Here's the one lambda. I already redeployed this lambda, it's the Service Developer API. If I click on it, you get this nice console. Again, this looks way better than it used to be.

[00:01:46]
It used to be so bad I would never look in here, but it's definitely a lot better now. So the important things I wanna talk about is kinda what's matching up with our serverless file and different things like that.
>> Scott: Don't worry about the API gateway stuff, we'll get there in a minute.

[00:02:04]
But the important thing to notice here is that when you go from local to AWS, the service framework does a lot of things for you, and we'll get into those things when we talk about deployment. But I just want to give you some context just in case as I'm scrolling you're going to see some stuff like, we didn't set any of that up.

[00:02:21]
We didn't set up CloudWatch logs or API gateway. That's fine, we'll get into that for deployment, but we don't really have to do a lot of that. Serverless is gonna do that for us. But the thing that I wanted to talk about is a few things. One, if you check out the runtime with the lambda it says 8.10.

[00:02:38]
If you go look at the Serverless YML you notice that it's the same runtime that we put here, so it's doing a lot of that stuff for us in the background. But the important thing that I really wanna talk about are these events. So at the top, if you click on Test, you will get this drop-down that says Event Template, and it says Hello World.

[00:03:01]
If you just scroll through all these events, these are all the events that your lambda can subscribe to from AWS. It's kinda ridiculous, I'm just gonna name a few of them. I mean there's literally a group full of just Alexa events. So if you wanna write lambdas that responded to Alexa smart home, here's all of them right here.

[00:03:19]
And your lambda could, I know everybody's thinking, man, I could do some crazy stuff. Yeah, I know, you really can. There's a lot of crazy stuff, and that's just Alexa. And then you get to the AWS specific things, the more practical things you're probably doing day to day.

[00:03:34]
This list is just growing, as I'm scrolling it's growing. So some of the common one that I find myself using, and a little description on those, CloudFront AB testing. This is actually really cool. You can do a lot of things with this, especially if you get into lambda on the Edge, which I can talk about later if anyone's interested in Edge computing.

[00:03:53]
That's really cool, and basically that allows you to do exacting what it says, AB testing. CloudFront is AWS's CDN, so it's an Edge network. And this allows you to do AB testing on the Edge using a lambda. So now you can write functions that exist on the Edge nearest to your customers, which is ridiculous.

[00:04:11]
And they keep expanding the parameters for those functions. Those functions used to be very minimum resources, now they're actually very intensive in resources. You can connect to databases on the Edge if you wanted to, which before you couldn't have done that. So you can imagine the possibilities there, it's kind of ridiculous, you don't even need an origin server anymore.

[00:04:31]
Another good one that I use a lot and that we'll be using here, is gonna be AWS gateway, AWS proxy, whcih we're gonna be talking about next. This is basically saying you wanna create an API and have the lambdas be the things that respond to your API basically.

[00:04:46]
They're like the controllers for your API, we we'll be talking more about that. That's probably the most heavily used one for sure cuz it's literally creating an API.
>> Scott: SES email receiving, this one's really cool because you can basically, if you use SES, simple email service, with AWS and you have all your emails coming in through there, you can have a lambda subscribed to that.

[00:05:07]
So whenever you get an email, you can do something. Now imagine the possibilities there. I mean, there's literally, you can do so much stuff with that. I just got an email from somebody, run this lambda function, and that lambda functions gets the email as a payload with all the context, and all the good stuff on it.

[00:05:21]
So there's some pretty crazy things you can do there. We're using it for things like if someone sends an email to our support, our technical support, we automatically open up an issue on GitHub with that person. And when it gets closed, that sends another lambda to email them that the issue got closed.

[00:05:38]
So it's automatic resolutional issues with us without us having to do anything, and that's all lambdas. It's costing us pennies a year.
>> Scott: CloudWatch logs is another good one. Basically it's subscribing to logs from CloudWatch. Really good for picking things off a stream. If you have a constant stream of events through CloudFront or anything that you're loged into, you can pick those off and send them through some pipeline or some ETL service or some data warehouse for processing later.

[00:06:08]
Really good source, we use it for keeping track of API calls and things like that.
>> Scott: And then another good one is,
>> Scott: S3, yeah, S3 put and delete. This one's really cool because you can basically can respond to events inside of S3. So if you've never used S3 before, it's basically just Amazon's file system in the cloud, right.

[00:06:31]
You can upload assets to it, and it's everywhere. So that's S3. Now you can subscribe to those events on those files. So if I have a folder of files and someone adds a file to it, like a user uploaded an image, I can now run a lambda function, right.

[00:06:46]
So I can grab that image and resize it, or pre-process it, or abstract it, or crop it, things like that. And vice versa, if they delete it, I can also do different things, like go clear the cache or something like that. So that's really powerful, to do things like that.

[00:07:02]
And again, those are some of the ones that I use. I think we use a lot more here, we're experimenting with a lot of stuff. And again, it just keeps going on and on and on. I don't even know what this lec stuff is, I've never even heard of this.

[00:07:15]
Book a car, book a hotel, I don't even know what that is but it sounds interesting. So, [LAUGH] if you wanna run a lambda whenever you book a hotel, this is where you would do it. So, if anybody ever looks that up, you let me know what that is, that's awesome.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now