๐Ÿ“š AWS 1x1: ๐—ช๐—ต๐—ฎ๐˜ ๐—ฎ๐—ฟ๐—ฒ ๐—Ÿ๐—ฎ๐—บ๐—ฏ๐—ฑ๐—ฎ ๐˜๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ๐˜€?

For a function to execute, an event must occur.
Most know about API Gateway for REST services as an event source.

But a lot more AWS resources can trigger your Lambda โ†“
Almost anything that happens within your AWS account is an event.

โ€ข writing a record to DynamoDB
โ€ข uploading a file to S3
โ€ข queuing a message in SQS
โ€ข a viewer request to your CloudFront distribution

All of those events can be used to trigger a Lambda function.

{ 1/12 }
There are two different kinds of invocation types: ๐˜€๐˜†๐—ป๐—ฐ๐—ต๐—ฟ๐—ผ๐—ป๐—ผ๐˜‚๐˜€ & ๐—ฎ๐˜€๐˜†๐—ป๐—ฐ๐—ต๐—ฟ๐—ผ๐—ป๐—ผ๐˜‚๐˜€

Synchronous event sources need to wait for your Lambda function to return a response.
Asynchronous don't.

If invoking functions via the SDK, this can be specified!

{ 2/12 }
Let's have a look at a sample invocation:

๐—ฎ๐˜„๐˜€ ๐—น๐—ฎ๐—บ๐—ฏ๐—ฑ๐—ฎ ๐—ถ๐—ป๐˜ƒ๐—ผ๐—ธ๐—ฒ \
โ€”๐—ณ๐˜‚๐—ป๐—ฐ๐˜๐—ถ๐—ผ๐—ป-๐—ป๐—ฎ๐—บ๐—ฒ ๐—บ๐˜†-๐—ณ๐˜‚๐—ป๐—ฐ๐˜๐—ถ๐—ผ๐—ป \
โ€”๐—ถ๐—ป๐˜ƒ๐—ผ๐—ฐ๐—ฎ๐˜๐—ถ๐—ผ๐—ป-๐˜๐˜†๐—ฝ๐—ฒ ๐—ฅ๐—ฒ๐—พ๐˜‚๐—ฒ๐˜€๐˜๐—ฅ๐—ฒ๐˜€๐—ฝ๐—ผ๐—ป๐˜€๐—ฒ

RequestResponse is the default, providing synchronous calls.

{ 3/12 }
If you're passing ๐—˜๐˜ƒ๐—ฒ๐—ป๐˜, the invocation will be triggered asynchronously.

If used in another function, the code execution will just continue after submitting the call.

๐Ÿ’ก If your function returns an error, AWS will automatically ๐—ฟ๐—ฒ๐˜๐—ฟ๐˜† the invoke ๐˜๐˜„๐—ถ๐—ฐ๐—ฒ

{ 4/12 }
Let's have a more detailed look at the most common Lambda triggers: ๐—”๐—ฃ๐—œ ๐—š๐—ฎ๐˜๐—ฒ๐˜„๐—ฎ๐˜†๐˜€, ๐—ฆ๐Ÿฏ, and ๐——๐˜†๐—ป๐—ฎ๐—บ๐—ผ๐——๐—• ๐˜๐—ฎ๐—ฏ๐—น๐—ฒ ๐˜€๐˜๐—ฟ๐—ฒ๐—ฎ๐—บ๐˜€.

They can be found in a lot of widely used architectural patterns.

{ 5/12 }
๐—”๐—ฃ๐—œ ๐—š๐—ฎ๐˜๐—ฒ๐˜„๐—ฎ๐˜† ๐—ง๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ

Invocations by API Gateway are synchronous ones, waiting for your Lambda to return a response it can send back to the requesting client.
You need to explicitly map which invocation paths you want to map to with function.

{ 6/12 }
๐—ฆ๐Ÿฏ ๐—ง๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ

Events occur when the content in an S3 bucket is modified, e.g. by creating, removing, or updating a file.
When defining an event, youโ€™re able to specify what sort of action will trigger the lambda function and which paths you want to include

{ 7/12 }
๐——๐˜†๐—ป๐—ฎ๐—บ๐—ผ๐——๐—• ๐—ฆ๐˜๐—ฟ๐—ฒ๐—ฎ๐—บ ๐—ง๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ๐˜€

If streams are enabled for a table, all changes are pushed into such a stream if there were changes made to an item or a new item was inserted.
Think of it like a line or a queue through which the data flows.

{ 8/12 }
If there's data inside that stream, a Lambda function will be triggered with related data.
The stream data can be ๐—ฎ๐—ด๐—ด๐—ฟ๐—ฒ๐—ด๐—ฎ๐˜๐—ฒ๐—ฑ, meaning that a single Lambda invocation can contain ๐—บ๐˜‚๐—น๐˜๐—ถ๐—ฝ๐—น๐—ฒ change records.

Invocations are asynchronous like at S3.

{ 9/12 }
There are a lot of other ๐˜€๐˜†๐—ป๐—ฐ๐—ต๐—ฟ๐—ผ๐—ป๐—ผ๐˜‚๐˜€ ๐—ฒ๐˜ƒ๐—ฒ๐—ป๐˜ ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€...

โ€ข Elastic Load Balancing (ALB)
โ€ข Cognito
โ€ข Alexa
โ€ข API Gateway
โ€ข CloudFront
โ€ข Kinesis Data Firehose
โ€ข Simple Storage Service Batch
โ€ข Amazon Connect
โ€ข Amazon Lex

{ 10/12 }
... and also ๐—ฎ๐˜€๐˜†๐—ป๐—ฐ๐—ต๐—ฟ๐—ผ๐—ป๐—ผ๐˜‚๐˜€ ones!

โ€ข CodePipeline
โ€ข S3
โ€ข SNS
โ€ข SES
โ€ข CloudFormation
โ€ข CloudWatch Logs
โ€ข CloudWatch/EventBridge Events
โ€ข CodeCommit
โ€ข AWS Config
โ€ข AWS IoT
โ€ข AWS IoT Events

{ 11/12 }
If you're more interested in Lambda triggers and what architectural patterns you can build with them, have a look at the ๐—–๐—ผ๐—บ๐—ฝ๐—น๐—ฒ๐˜๐—ฒ ๐—š๐˜‚๐—ถ๐—ฑ๐—ฒ ๐˜๐—ผ ๐—Ÿ๐—ฎ๐—บ๐—ฏ๐—ฑ๐—ฎ ๐—ง๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ๐˜€ ๐—ฎ๐—ป๐—ฑ ๐——๐—ฒ๐˜€๐—ถ๐—ด๐—ป ๐—ฃ๐—ฎ๐˜๐˜๐—ฒ๐—ฟ๐—ป๐˜€ by @thedashbird ๐Ÿ—

dashbird.io/blog/complete-โ€ฆ

{ 12/12 }
Thank you for reading!
I hope you learned something new ๐Ÿ™Œ

As usual: I'm happy about a โ™ป๏ธ or โ™ฅ๏ธ of the initial post.

... and drop me a follow if you're interested in regular cloud content! ๐ŸŒค

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Tobias Schmidt

Tobias Schmidt Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @tpschmidt_

26 Oct
๐Ÿ“š Cloud 1x1 - ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐—ฟ๐—น๐—ฒ๐˜€๐˜€ ๐—”๐—ฟ๐—ฐ๐—ต๐—ถ๐˜๐—ฒ๐—ฐ๐˜๐˜‚๐—ฟ๐—ฎ๐—น ๐—ฃ๐—ฎ๐˜๐˜๐—ฒ๐—ฟ๐—ป๐˜€

You don't need to re-invent the wheel.
You can rely on field-tested patterns.

Let's explore some common ones โ†“
๐—ฃ๐—ฎ๐˜๐˜๐—ฒ๐—ฟ๐—ป ๐—ข๐˜ƒ๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„

โ€ข Fan-in & Fan-out
โ€ข Simple Web Service
โ€ข Publish/Subscribe
โ€ข Strangler
โ€ข Aggregator

{ 1/7 }
๐—™๐—ฎ๐—ป-๐—ถ๐—ป & ๐—™๐—ฎ๐—ป-๐—ผ๐˜‚๐˜

Common problem: large tasks that are exceeding Lambda's execution time limit
With Fan-out, you're splitting those large tasks into small ones and delegating those to Lambda workers.
Afterward, results are aggregated (= Fan-in).

{ 2/7 }
Read 11 tweets
25 Oct
๐—Ÿ๐—ฒ๐˜'๐˜€ ๐—ฏ๐—ฒ ๐—ต๐—ผ๐—ป๐—ฒ๐˜€๐˜: generally, debugging is not a fun task ๐Ÿคข

Especially for serverless, event-driven & distributed systems.

From Lambda's logging basics to ๐˜€๐—ฎ๐˜ƒ๐—ถ๐—ป๐—ด ๐˜๐—ถ๐—บ๐—ฒ & ๐—ป๐—ฒ๐—ฟ๐˜ƒ๐—ฒ๐˜€ โ†“
Lambda's a serverless technology provided by AWS.
But that ๐—ฑ๐—ผ๐—ฒ๐˜€๐—ป'๐˜ ๐—บ๐—ฒ๐—ฎ๐—ป that there are no servers.

In the background, there are countless micro-containers running on top of the traditional servers.

Where do all the logs of those containers go to?
By default, they will end up in CloudWatch.
Every Lambda will receive its own ๐—น๐—ผ๐—ด ๐—ด๐—ฟ๐—ผ๐˜‚๐—ฝ.
Like a repository for logs.

Not only that, every micro-container will create a new so-called ๐—น๐—ผ๐—ด ๐˜€๐˜๐—ฟ๐—ฒ๐—ฎ๐—บ.
Think of it as a text file where logs are written to.
Read 9 tweets
15 Oct
๐Ÿ“š AWS 1x1 - ๐—Ÿ๐—ฎ๐—บ๐—ฏ๐—ฑ๐—ฎ ฦ›

The Heart of your Serverless Love Story ๐Ÿงก

All my learnings & (almost) everything you need to know โ†“
๐—ง๐—ต๐—ฟ๐—ฒ๐—ฎ๐—ฑ ๐—ข๐˜ƒ๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„

โ€ข Introduction
โ€ข Cold Starts
โ€ข Handler Method
โ€ข Runtimes
โ€ข Layers
โ€ข Security
โ€ข Versioning & Aliases
โ€ข Provisioned & Reserved Concurrency
โ€ข Lambda@Edge
โ€ข Pros & Cons
โ€ข Observability
โ€ข Considerations to make

{ 1/31 }
๐—œ๐—ป๐˜๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜๐—ถ๐—ผ๐—ป

AWS released Lambda in late 2014, spreading the buzzword serverless.

With EC2 you didn't have to think about physical servers anymore, but only virtual machines.

With Lambda, there's not even that anymore to maintain.
Just bring your code.

{ 2/31 }
Read 33 tweets
13 Oct
๐Ÿ“š AWS 1x1 - ๐——๐˜†๐—ป๐—ฎ๐—บ๐—ผ๐——๐—• ๐Ÿ’พ

My personal holy grail of database solutions & one of AWS' flagship services

An all-embracing mega-thread ๐Ÿงตโ†“
๐—ง๐—ต๐—ฟ๐—ฒ๐—ฎ๐—ฑ ๐—ข๐˜ƒ๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„

โ€ข Introduction
โ€ข Provisioned vs On-Demand Capacity
โ€ข Basic Concepts
โ€ข Keys & Attributes
โ€ข Retrieving Items
โ€ข Race Conditions
โ€ข Expressions
โ€ข Indexes
โ€ข Streams
โ€ข Security
โ€ข Backups
โ€ข Global Tables
โ€ข Observability

{ 1/38 }
๐—œ๐—ป๐˜๐—ฟ๐—ผ๐—ฑ๐˜‚๐—ฐ๐˜๐—ถ๐—ผ๐—ป

Why should you care about DynamoDB?

It's managed, highly available & scales on-demand with low latencies.

For getting you hooked, at Prime Days 2021 DynamoDB served ๐Ÿด๐Ÿต.๐Ÿฎ ๐—บ๐—ถ๐—น๐—น๐—ถ๐—ผ๐—ป ๐—ฟ๐—ฒ๐—พ๐˜‚๐—ฒ๐˜€๐˜๐˜€/๐˜€๐—ฒ๐—ฐ๐—ผ๐—ป๐—ฑ at its peak.

{ 2/38 }
Read 40 tweets
12 Oct
Unpopular opinion: building a successful SaaS product is ๐—ต๐—ฎ๐—ฟ๐—ฑ

Yes, Twitter feels like everybody launches something & immediately goes to $10k MRR

๐—ฅ๐—ฒ๐—ฎ๐—น๐—ถ๐˜๐˜† ๐—ถ๐˜€ ๐—ฑ๐—ถ๐—ณ๐—ณ๐—ฒ๐—ฟ๐—ฒ๐—ป๐˜

I'm still in the early stages & already got a lot of lessons learned โ†“
๐—Ÿ๐—ฎ๐˜‚๐—ป๐—ฐ๐—ต ๐—ฒ๐—ฎ๐—ฟ๐—น๐˜†

Maybe you've got another dozen ideas for features you think are needed for your MVP.
But until you've launched and you've got actual (paying) users, you've got no guarantee that your business case is even valid.

Keep your scope as small as possible.
๐—ฃ๐—ฒ๐—ฟ๐—ณ๐—ฒ๐—ฐ๐˜๐—ถ๐—ผ๐—ป๐—ถ๐˜€๐—บ ๐—ถ๐˜€ ๐—ฏ๐—ฎ๐—ฑ

Intersects with the previous point: don't make the shinest code, with 100% code coverage and the perfect architecture, as it requires way too much effort.

Don't over or underdo it.
Make it work & manageable.
Read 9 tweets
11 Oct
๐—œ๐˜'๐˜€ ๐—ฒ๐—ฎ๐˜€๐˜† & ๐—ฐ๐—ผ๐—บ๐—ณ๐—ผ๐—ฟ๐˜๐—ฎ๐—ฏ๐—น๐—ฒ ๐˜๐—ผ ๐˜€๐˜๐—ฎ๐˜† ๐˜„๐—ต๐—ฒ๐—ฟ๐—ฒ ๐˜†๐—ผ๐˜‚ ๐—ฎ๐—ฟ๐—ฒ

Working at the same company for years.
In the same project.
In the same team.
At the same product.

No need to prove yourself anymore.

Maybe that's exactly why you should think about leaving โ†“
๐—˜๐˜ƒ๐—ฎ๐—น๐˜‚๐—ฎ๐˜๐—ถ๐—ป๐—ด ๐˜†๐—ผ๐˜‚๐—ฟ ๐˜€๐—ถ๐˜๐˜‚๐—ฎ๐˜๐—ถ๐—ผ๐—ป

You've gained respect & trust in your current position.
Maybe you've got promoted.
You know your craft.

Life's good.

Why should you leave into some uncertainty?
Why taking risks?

Because there's a lot to ๐—ด๐—ฎ๐—ถ๐—ป!

{ 1/8 }
๐€๐๐š๐ฉ๐ญ๐ข๐ง๐  & ๐ฌ๐ญ๐ซ๐ž๐ง๐ ๐ญ๐ก๐ž๐ง๐ข๐ง๐  ๐ฒ๐จ๐ฎ๐ซ ๐š๐ญ๐ญ๐ข๐ญ๐ฎ๐๐ž

Everything is under constant change โšก๏ธ

The new technology you've read about will probably be the standard next year.
What you're working on is probably obsolete tomorrow.

{ 2/8 }
Read 10 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(