Episode Transcript
Available transcripts are automatically generated. Complete accuracy is not guaranteed.
Leo Dion (host) (00:00):
Hey
folks, happy Thanksgiving.
To those of you in the us I justwanted to let you know that we have
a big Black Friday sale right now onboth Bushel and Patreon membership.
You can click a link to thenewsletter below in the show notes.
Definitely take a look.
It's 50% off bushel membership for ayear and 25% off Patreon membership.
So if you want early access to episodeslike this, , this is definitely
(00:23):
something you wanna take advantage of.
There is a code, the code is 6 4 6 3 2. So, yeah, , join the Patreon membership
to get early access to episodes andtake advantage of the 50% off on bushel.
This will only be available for thenext few days, so definitely take
a look and I hope you enjoy thiswonderful episode with Sebastian.
(00:43):
Bye everybody.
I.
Welcome to anotherepisode of Empower Apps.
I'm your host, Leo Dion.
Today I'm joined bySebastian Storm Mock.
Sebastian, thank youso much for coming on.
Sébastien Stormacq (guest):
Thank you, Leo, for having me. (00:57):
undefined
Leo Dion (host) (00:58):
So good to see
you at the Server Site Swift
Conference, and excited to haveyou on today to talk about.
Amazon and AWS Lambda.
But before we get into that I'll letyou go ahead and introduce yourself.
Sébastien Stormacq (guest) (01:13):
I am
working at AWS since 12 years.
I start writing code like 40 years ago.
It was on a Commodore 64 first time.
So I have a couple of white hairs.
I love to write
Leo Dion (host) (01:24):
Load star
eights commas one right.
Sébastien Stormacq (guest) (01:28):
Different
systems, different programming language.
I'm very curious aboutprogramming language.
And I fall in love with Swiftyeah, at the very beginning,
almost 10 years ago when theyreleased the first beta version.
I host a podcast.
I'm talking with developersmost of the time, writing blog
posts, doing a bit of video.
That's my day-to-day activities.
Leo Dion (host) (01:48):
So you're kinda like
a developer evangelist, basically.
Is that a good way to put it?
And then, is your primaryfocus swift at AWS or just
Lambda, or what specifically?
Sébastien Stormacq (guest):
that's a good question. (02:03):
undefined
My primary focus is writingblog posts to announce new
services and new feature.
We are writing a lot right nowbecause we have our customer
conference that happened firstweek of December at Reinvent.
I'm also the producer of two AWSpodcast, but on my side and, I have
one or two days per week on my sidewhere I can focus on something else.
(02:23):
And I'm trying to, to bring the swiftdeveloper community to the cloud
and try to bridge the gap to makeit easier for a swift developer to
deploy their application in the cloud.
And as part of that, I'm workingwith the SWIFT server working group.
So we have daily meetings withdifferent person from the SWIFT
organization at Apple and othermembers of the SWIFT community and
the open source SWIFT community.
Leo Dion (host) (02:45):
Yeah.
And we had a episode with Yanas on a
Months ago talking about theserver side working group.
So where did you saythat conference was?
In December.
Sébastien Stormacq (guest):
Las Vegas Never Nevada. (02:56):
undefined
Leo Dion (host) (02:58):
Okay.
Sébastien Stormacq (guest):
In first week of December, (02:59):
undefined
Leo Dion (host) (03:01):
Yeah, hopefully
it'll be nice and warm.
Yeah, so let's get into it.
So a lot of folks who are swiftdevelopers surprise are iOS developers
and may not know a lot about the server.
We talked about this previously.
In the episode I had with BitBoag on, it's not really something
like if you probably looked atthe pie chart of SWIFT developers.
(03:25):
AWS Lambda very big,vast majority would be.
Yeah, exactly.
So explain, I think most peopleknow kind of what a server is,
but what exactly does that mean?
Serverless, and what is a,what does Lambda actually do?
Sébastien Stormacq (guest) (03:39):
I'll
come to that in, in a minute, but
just about Swift because you saidthe majority of the developers are
coming from iOS and that's true.
We also observe another group ofdevelopers on swift, the ones that
choose to use SWIFT for the qualityof the language, for the low memory
footprint, for the very strict.
The type system, the verydeveloped concurrency,
especially now with swift six.
(04:00):
So that programming language has alot of benefits to do development on
the server side and not only on theclient side to develop your API, for
example, or your batch processing,your image processing, document
processing on the server side.
And then as a Swift developer,you start to write code.
There is that huge ecosystemsof libraries, driver for
database and things like that.
(04:21):
And then you wonder, okay, whereI'm going to deploy that code.
And of course it runs on your laptop.
Maybe it runs on a container.
Then you start, okay, how canI host a container somewhere?
Maybe I should rent avirtual private server.
And this is where I enter and say,Hey, maybe you can deploy on AWS
as well, because we have virtualmachines, we have containers.
There is that options that we are hereto talk about today called AWS Lambda.
(04:45):
So Lambda is not new.
It's something that exists in 10 years.
We are celebrating the 10 years ofAWS Lambda this year, November, 2024.
What is Lambda?
Lambda?
It's a function as a service.
FAAS if you like, acronyms.
So the idea of Lambda as a developer,I write code and then I just publish
(05:08):
my code to Lambda and I don't have tocare about what is the infrastructure
that will be deployed to run that code.
I don't have to care about virtualmachines installing a a runtime,
installing, I don't know, libraries.
I don't.
Need to think in terms of deployments,scaling my infrastructures, we have
at least two machines with redundantin case one goes down or to scale to
(05:33):
1 million requests per hour and havea load balancer and things like that.
Lambda, the service a s Lambda will do?
that for me as a developer.
I write my code, I.
click publish.
The code is exposed on theinternet or not, depending
on how you configure things.
And that code will run insidemicro virtual machines.
(05:53):
It's not a container, it's amicro vm, and the service will
scale that automatically up.
So if you have 1000 call persecond, thank you, congrats.
You have a very successful application,but you don't need to be wake up
in the middle, middle of the nightbecause there is no more space on
your virtual machine or whatever.
The system will scale automatically,but it will also scale down to zero.
(06:13):
If your app is not used, thenthe last micro VM is shut down.
A new one will be restarted.
If a new request come from yourfor your code, but it means that
you stop paying for that as well.
And that's very interestingbecause you just pay what you use.
So for very small application for testand dev, it almost cost zero, zero
Leo Dion (host) (06:36):
So you
say it's like a micro vm.
How is that different from say a dockercontainer that just runs your code?
Sébastien Stormacq (guest) (06:44):
The
main difference, it's the level
of isolation between differentcontainers from multiple customer.
At AWS, our firstpriority is the security.
So when we launched Lambda two10 years ago we, of course we
didn't want that your code?
inside.
Lambda function is able to seeor to manipulate the memory from
another customer running anotherLambda function on the same machine.
(07:06):
So at the very beginning, we createdifferent virtual machines to
host all these Lambda function,one virtual machines or multiple
virtual machine for one customer.
And we were not sharing theunderlying virtual machines between
customer to have very strict.
Isolation of yourprogramming environment.
And we cannot do that with Dockerbecause as you know, two docker
(07:28):
containers are running on thesame machine, on the same kernel.
There is only one operating system,so a micro vm it's a vm, but with
just the minimal amount of librariesthat, that we need to run a piece of
code that is totally isolated fromother micro VM on the same bar metal.
Hardware, and that's thetechnology we are using for Lambda.
(07:49):
It's open source, it'scalled firecracker.
You can find it.
Just try a firecracker onGitHub and you will find it's a
rest base micro VM technology.
Leo Dion (host) (07:58):
Okay, so when
you say it's serverless, how do
I then hook up something like adatabase because it's nice to run a
function, but what if I wanna storesomething, for instance, some sort
of data, then what am I gonna do?
Because there is no server.
Sébastien Stormacq (guest) (08:16):
So when
I say serverless, of course there
are server at the end of the daythat code needs to run somewhere.
The key point with serverlessis that I, as a developer, don't
have to manage this server.
I don't have to install Linux to.
Patch it to install.
I dunno if it's Java Code, Javavirtual machines, or if it's
SWIFT code or Swift Runtime.
This is managed by Ws, soI don't have to do that.
(08:37):
That's the first thing.
Then typically your Lambdafunction alone is not very useful.
As you mentioned, you needsomething upstream to call to
involve the land function, andyou need something downstream.
The Lambda functioncan call to fetch data.
It might be files on the stream.
It might be a Postgres databaseor no SQL database somewhere.
So let's start with the flow.
(08:58):
What will invoke your Lambda function?
Most of the time it'llbe another AWS service.
So if you want to develop a rest,API, for example, you will put
in front of your Lambda function.
An API gateway.
So the API gateway,it's like a web server.
It's the HT TPS termination pointthat will receive your gate, put
post HGTP request and will invokeyour Lambda function where you
(09:21):
will handle these these requests.
So you will receive in the Lambdafunction, all the parameters, the
H TT P headers and stuff like that.
And then you really respondwith an HTT P response as well.
It might be you might useLambda function to react.
On something that happensin your infrastructure.
If you have a NoSQL database in thecloud called DynamoDB, you can have
(09:41):
lambda functions that are trigger.
So something change in my databaseand it triggers a Lambda function
just like the old Oracle trigger.
If you remember from the timeyou were using relational
database, it's the same id except.
It's different processes.
Here.
It might be a filearriving on Amazon three.
You know, you drop a file on a three, ittriggers the Lambda function that will
(10:03):
process that file, maybe summarize it,chunky, recode it, move it, whatever.
So that's what can invokeyour Lambda function.
And then inside your code inthe Lambda function, you do
pretty much what you want.
If you need to connect to a database,you take a database driver, JDBC,
or DBC In Swift, we have a databasedriver from MongoDB for Postgres,
(10:25):
for MySQL, and it's code as usual.
You connect to the IP addressor the DNS name of the database.
You.
Enter credentials, use onEM password and send your s
QL statement over database.
The only thing which is a bitdifferent with Lambda, remember, I, I
told you if the, if there is no morecall to your function, AWS Lambda
(10:46):
will terminate the last micro vm.
So whenever a new call will, willcome, we'll recreate a micro vm.
Reinstall the Lambda function and.
If you use relational database, youneed to reopen the connection to your,
the TCP connection to your database.
That's pretty much it.
The only things you have to thinkabout is that maybe your VM will
(11:08):
be terminated at some point.
So anything which is persistenceneed to be rein stances
when the code start again.
Leo Dion (host) (11:16):
Yeah.
So I've actually, we, I think we'vetalked about this previously, but
I've actually built an AWS Lambdain Swift used Dynamo key manager.
Gosh, I don't know how manyAmazon services, but it was
like an interesting experience.
Like one of the things that yeah,you have to kind of realize.
(11:37):
And this was completely like,no, no vapor, no hummingbird,
we'll talk about later.
This is completely allthrough AWS Lambda.
Was that yeah, you have to deal withthe fact that sometimes connections
could have been shut down andyou have to handle that yourself.
And I like that you mentioned,'cause obviously here we're gonna be
talking about like rest APIs, whichis like a majority, but there are
Sébastien Stormacq (guest) (11:58):
cases.
Yeah.
Leo Dion (host) (11:59):
Right.
But there are like a lot ofother instances and triggers
that you'll want to deal with.
And so I'm really gladyou mentioned that.
So if you were to like get startedwith AWS Lambda, would you suggest
just going with the, with 'causeSo it'd be like, what, five
years ago that I worked on this.
So I.
don't know how much has changed.
Probably a lot.
(12:20):
But would you just go withlike AWS Lambda or would you
build on top of something likecoming bird birder vapor that.
That builds through, and I'm not totallyclear if that's still available or
how that works, or if you're gonnastart a server how would you go about
doing that like today for a beginner?
Sébastien Stormacq (guest):
First I would go serverless. (12:38):
undefined
I would eliminate all deployment optionsthat require some kind of machine,
either Docker container or microvirtual machines running 24 by seven.
Because especially when you're astudent, when you're a beginner, when
you're, exploring a new id, you don'tknow if it's going to work or not.
So it's not necessary to engage abudget to have a machine running 24
(13:01):
by seven and to manage that machine.
So serverless is probably the way to go.
Question is should I use I.
Web framework such as Vaporand Hummingbird on Swift or
go directly native on Lambda.
It's possible as well to write codeswift code specifically for Lambda.
I would say, I'm sorry, that's mysolution architect type of answer.
I.
It depends.
(13:21):
It depends on your budget,depends on your needs.
But there is one overlap.
So if you start with Hummingbirdand Vapor these two frameworks
have an HTTP server built in.
So these things can accept and willaccept an HTTP request with get
post and then wrote that request tothe specific handler in your code.
And the thing I describedjust before API gateway.
The Lambda function is the same.
(13:43):
It's an HTT PS endpoint that will lookat the HTTP parameter and route the
call to a specific Lambda function.
The way I see it if you have alreadyexisting code using Hummingbird and
Vapor, you can deploy that application.
As is on Lambda, and both Vapor andHummingbird have a small adapter
lambda adapter that will marshal thearguments between whatever format
(14:06):
they receive from the API gateway andpass that in a way that the, framework
hummingbird or vapor understands.
So it's a very tiny,
Leo Dion (host) (14:13):
how does it
Sébastien Stormacq (guest):
one line change. (14:14):
undefined
Leo Dion (host) (14:16):
Well,
how does it pass the H?
Like how do, this is atotally technical question.
Sorry.
But like how does it pass the route?
Is it like a JS and then ithas to like decode the JS N of
whatever route was passed in.
Okay.
Sébastien Stormacq (guest) (14:29):
Yeah.
in that case, the HTT P requestarrive on the API gateway.
The API gateway will look at allthe HTT P there, the parameters and
things like that will create a bigJSON with all that information And
invoke your Lambda function with
Leo Dion (host) (14:41):
And so that's what
this vapor plugin or hummingbird
Sébastien Stormacq (guest) (14:44):
Exactly
what they do is read that json for you
and then recreate something that's thenative hummingbird of vapor framework.
I can understand theadvantage of doing that.
It's one or two lines ofcode to change in your code.
No more than that.
Add dependency to the vaporadapter or the hummingbird adapter.
And you can have what wecall a monolith lambda.
(15:05):
It's.
Speak Lambda function that handleall the case, the get, the post,
the delete the connection to thedatabase and things like that.
And it's perfectly valid becauseyou don't need to change your code.
So why would you do that?
It's to reduce your cost.
You don't have to run a container 24 byseven or a virtual machine 24 by seven
if you have an application, which is.
(15:26):
Invoked a couple of times perminute, a couple of times per hour
with downtime during the night,for example, or during the weekend.
Moving from a container or virtualmachine will reduce your cost.
If you.
go to Lambda,
Leo Dion (host) (15:39):
Okay.
Sébastien Stormacq (guest):
it's not always true If you have (15:39):
undefined
an application which is under.
Constant load that receive a stream ofrequest 24 by seven and consume a lot
of CPU Lambda might be more expensivethan a Docker container on micro vm.
So there is a sweet spot tofind in terms of pricing.
But for the huge majority of theuse cases, Lambda is less expensive
than a 24 by seven virtual machine.
Leo Dion (host) (16:01):
Why would you
put, so is there ever an advantage,
like I'm just thinking like, ifyou had one route, like at that
point, like what would be the pointin having Hummingbird or Vapor?
'cause then you could just handle
Sébastien Stormacq (guest) (16:15):
Now I.
start saying, if you have existingcode with Hummingbird and Vapor, Then
you can migrate them with minimalchange if you start from scratch.
But maybe you can say, I'm biasedbecause I'm working for AWS, so.
If I start from scratch, I willgo directly to the native Lambda.
So an API gateway that doesthe HT TPS termination and
a native Lambda functions.
(16:36):
So we have developed in opensource apple started that project.
It's maintained by the communitynow, the Swift AWS Lambda
runtime that allows to Right?
swift function for Lambda.
And to deploy.
Yes.
The public version on the Swiftserver GitHub report, it's five years
old, but we had different prototypeexperience that were driven by different
(16:58):
members of the community before.
Leo Dion (host) (17:00):
Right, right, right.
What was I gonna say?
Dang it.
I forgot.
Sébastien Stormacq (guest):
it happens to me too. (17:04):
undefined
Leo Dion (host) (17:05):
I know.
Really, I.
That's what editing is for.
Ado Lambda.
Sébastien Stormacq (guest) (17:10):
Deploying
Hummingbird versus Native Lambda.
function.
Leo Dion (host) (17:14):
Well, let's ask the
next question so you can answer this
in whatever way you want to, but howportable is a Lambda if, for instance,
I don't want to like, I'm sorry.
Like, you know, I might notwanna stick with Amazon forever.
I might find some other service.
Sébastien Stormacq (guest) (17:33):
Of course.
And Lambda is not the onlyfunction as a service.
available out there.
Google has Google function.
I think there is somethingon Microsoft as well.
Azure.
So yes the portabilityis an important question.
There is no vendor looking.
I don't like the word vendor looking.
I'm talking about a cost to exit it.
Going out will cost you somethingmore or less depending on
(17:54):
your architecture, your code.
So, le let's think about it.
It really depends on howyou architecture your code.
If the lambda specific part, sothe parameter that you function.
And the message that it'll produceas an output if this is well
isolated from the rest of your code.
The cost of exit is reallylow because your Lambda
(18:15):
function can be quite minimal.
And all the business logicis inside reusable libraries.
So if you segment your code,if you architecture your code
correctly, you have just the entryand the exit point to to rewrite.
Of course, on top of that, youhave, and to be honest, you have
also the deployment procedure, Youare most likely going to write.
Scripts or infrastructure codeto deploy this lambda function.
(18:36):
And the monitoring, you probablywant some alerting if you have
an error rate that goes up orif you have too many concurrent
invocation or any type of errors.
And these deployments andobservability monitoring will
always be very specific to theplatform where you're deploying it.
So that part, it's something thatyou would need to rewrite anyway.
Leo Dion (host) (18:57):
Yeah.
And obvious thing is if you'regonna use something specific
to Amazon, like Dynamo or S3.
That's where, I mean, that's kind ofmore where it is than it is the Lambda.
Sébastien Stormacq (guest) (19:08):
S3 is
pretty straightforward these day
because many other cloud providerhave an history, like something
which has roughly the same API as S3.
So S3 code can be a bit portable.
Right now, of course, if yougo to Dynamo and it's 100%
specific to Amazon, there.
Leo Dion (host) (19:27):
Dynamo is
the key value one, right?
Sébastien Stormacq (guest):
It's a key value NoSQL database, (19:30):
undefined
entirely managed serverless.
Nothing to install.
You.
Just make your H-G-T-P-A-P-Irequest to put or get your data.
Leo Dion (host) (19:39):
And Aurora
is the MySQL clone, right?
Sébastien Stormacq (guest) (19:42):
All Aurora
postgres or MySQL compatible database,
but really design for the cloud.
So the storage layer of Postgresor MySQL has been redesigned
to take advantage of multipledata center and a high level of
replication inside the data center.
So every time you write data on Aurora,it's replicated to six different place
in at least three different data center.
(20:03):
But the front end, the thingsthat accept the SQL is compatible
with Postgres on MySQL.
So from your application point of view.
It doesn't change a scene,you just send the same sequel.
But the storage engine behindthe scene is totally new
and developed for the cloud.
Leo Dion (host) (20:19):
Okay.
So, did you, were you able to attendMikayla's talk at Server Side Swift?
Sébastien Stormacq (guest) (20:26):
Yes,
and that was an eye opener for me.
Maybe you can explain the context there.
Oh, I.
can do it.
It's.
Leo Dion (host) (20:30):
Okay, so, I'll
post a link and maybe a card here
on YouTube, but basically McKaylaif you don't know McKayla, you
probably aren't a developer in Swift.
So, McKayla had a really great talkat the server site Swift conference
about, was it uploading a photo, right?
Sébastien Stormacq (guest):
Yeah, I think the (20:48):
undefined
Leo Dion (host) (20:49):
you
upload a photo through
Sébastien Stormacq (guest) (20:50):
do you
upload a photo to, to the cloud?
It cannot be that difficult.
Can.
Leo Dion (host) (20:55):
And what was great
about it wasn't a tutorial on how
to do it, it was a how do I put it?
Empathy, I guess wouldbe the right word.
Or maybe an example of like frustrationlearning how to do something in server
side swift that you would think isfairly simple but is a rabbit hole
Sébastien Stormacq (guest) (21:17):
Actually,
I don't think the challenge was because
it was swift on the server side.
The challenge was first understandthe security, the authorization system
from AWS, and she was using Herokuto deploy, which give you access to.
Part of the underlying AWSresource, but not totally.
So that was one, one of
Leo Dion (host) (21:38):
Well, but
even like, how do you upload a
file in the server side switch?
Like even that part like, yeah, the.
AWS Lambdahe Google result was basicallyuse S3 and then from there Yeah.
That would you I'm coming to aquestion obviously, but like,
one of, one of the things that.
People commonly will say withany Amazon service is the secure,
(21:59):
like the security, it's great,but it's also, it's so good that
it's difficult to get started.
And you know, you're gonna find thatwith aw, with Lambda because you have
to set up security roles and IAM stuff.
What pointers or what, likewhat guidance do you have
on that as far as like.
Oh man, my ado, my Lambda won'tcall my SQL server because this
(22:22):
role isn't like how should peoplefigure that stuff out or get started?
Sébastien Stormacq (guest) (22:26):
To get.
With Swift and Lambda I'm currentlywriting a lot of documentation.
So if you go to the Swift a s LambdaRuntime Project, the read me page as a
lot of example and I try to give verypractical and details about you have
to do that, you have to do that withthe exact comment before, assuming
that people know much about the cloud.
(22:48):
So it is really written with aneye of someone that knows Swift.
That would like to deploy on the cloud,but doesn't is not an expert on AWS
I'm not writing that for AWS customer.
I'm writing that for Swiftdevelopers to bring them to, to AWS.
The only big prerequisite, and I cannotavoid that, is to have an AWS account
and have an access key, secret key,which is equivalent of a use on password
(23:10):
at API level to interact with AWS.
And I'm not re rewritingthe doc for that.
I'm linking to existing doc on,on AWS, but once that is, that
prerequisite is met I'm trying toreally list all the steps so it's
not finished, it's work in progress.
If you go to the Read Me today inDecember, 2024, if you're listening
this shortly after publication.
(23:32):
You will see still a couple of to-dos orsections that are missing, but the goal
is in the next couple of months to havea fairly complete a set of documentation
including for deployment with differentoptions of deploying in the console,
deploying through the command line,deploying with infrastructure as code
tool like Sam, or maybe five time,tools not from AWS like Terraform,
(23:54):
pmi other infrastructure code tools.
So I.
try to be quite.
Complete there, includingin the code sample.
So you mentioned talking to a database.
It's a very common use case, sothere will be, it's not there yet.
An example of a Lambda functionthat talks to a postgre.
There is an example that talks toa three, that talks to dynamo db.
(24:15):
So you can find all these example,and these examples are super short,
like 10 lines of code maximumto show you how to get the basic
bricks in motion or in place.
Leo Dion (host) (24:25):
What do you like?
What do you think ismost of the confusion?
When setting up security roles andthings like that, like where do you
think, where do you think it comes from?
Like what is the mental model thatAmazon has that the average developer
doesn't have that is making thething, making it so challenging.
You know what I mean?
Sébastien Stormacq (guest) (24:46):
There are
different ways to do things as I said
in the console, in the command line.
And things evolve over time as well.
We try to simplify over time.
So if you Google for solutionlike Mickayla did she found tons
of old blog posts or results thatare not accurate anymore, and.
Leo Dion (host) (25:04):
I am just
thinking like, don't use AI than
to ask, because those modelsare probably trained on old blog
Sébastien Stormacq (guest) (25:10):
All data
Leo Dion (host) (25:11):
That's even worse.
Yeah.
Sébastien Stormacq (guest):
that's, that, that's true. (25:13):
undefined
So one challenge is theprofusion of documentation.
There is too many documentationincluding on our website.
I'm not just talking about third partyblocks in including on AWS and sometimes
it's outdated documentation as well.
The second thing, I think, I if youstart to use the cloud, any cloud,
Google, Microsoft, AWS, just to mentionthese three, spend half a day, one
(25:35):
day learning the basic of security.
It'll save you time forthe rest of your life.
If you, once you understand thesecurity model on AWS, what is
an access easy credit key can.
Or can I get one?
Either it's a permanent oneassigned to my user or a temporary
one that I receive through arole that I, and I assume a role.
Once you understand that basic,it's not that complicated, but
(25:57):
most of the developers that I know,you know, we don't read the doc,
we don't need to read the dogs.
So we go straight to the code and thenwe hit the, this type of programs.
So my advice would be spend.
Little time.
Honestly, it's not that complicated,at least the foundation, the basic to
understand what we are talking about.
It'll save you time a lotand read the error message.
The error message are incrediblydescriptive, and just by reading
(26:21):
the error message most of the timewe can point to the source of the
challenge as well of the problem.
Leo Dion (host) (26:26):
When you said about
documentation, well, luckily Apple
doesn't have that problem, right.
Of having old documentationon their wink.
Um, yeah.
Do you, besides your what, youryour readme that you're talking
about, any other links that youwould recommend that would be the
latest and have, like, this is whatyou should read to really deep dive
into how it's supposed to work.
Sébastien Stormacq (guest):
For Swift on Lambda? (26:48):
undefined
Specifically for Lambda in general,
Leo Dion (host) (26:51):
just how the
whole security system works.
Sébastien Stormacq (guest) (26:54):
I can
share a couple of links with you.
You can put that in thenotes of the podcast.
But yes, the getting started usuallyin all aw s doc per service, there is
a getting started page that explainthe main concept in a very clear way.
That's usually a verygood starting point.
PE as I said, we developer and Iinclude myself in that bunch of people.
(27:15):
We don't spend time reading thedoc and sometimes we should a.
Leo Dion (host) (27:19):
Right, right.
Like yeah, there's missing pieces whenyou just try to get it done right.
And if you read the doc, it will fillin a lot of blanks and then you don't
have to like keep Googling every or atcha PT every error message that you get.
So yeah, totally agreea hundred percent.
Let's talk about deployment.
So I assume this is aSwift package, right?
(27:42):
You can develop it on Xcode.
Is there a dev container now I.
Sébastien Stormacq (guest) (27:48):
There
is no dev container provided by us.
It's easy to create one, butyes, it's a swift package
you include in your package.
That swift classdependency on the runtime.
Leo Dion (host) (27:57):
I've started developing
a visual studio code for especially
when I need to see if something willwork in a a, so I was wondering if
we have that capability with Lambda.
Oh, awesome.
Okay.
Sébastien Stormacq (guest) (28:08):
I'm doing
most of my development in Visual Studio.
Leo Dion (host) (28:11):
See, it's like a real.
Sébastien Stormacq (guest) (28:13):
time to
time with Xcode just to see if it still
works and know the package that Swift,the SPM support in Xcode is decent.
So it works quite wellwith Xcode as well.
I tend to observe that the codecompletion is a bit better in
Xcode and in Visual Studio Code.
But we have copilot,which helps a lot as well.
Now both in Xcode andin Visual Studio Code.
So you import that package, youcreate your main, executable, a
(28:33):
swift function, Lambda function.
It's an executable.
You implement an interface calledRuntime that has one function
that receive two parameters.
The event.
So the J that you receivefrom whatever is calling you
the API gateway, for example.
And the other one is the Lambda context.
So it's a bit of information aboutwhere you are running, how much
memory is available, for example,what Is the request ID and some
(28:56):
other information about the context.
And then you do whateverbusiness you need to do.
And your return a response,typically a JSON response.
And that's pretty much it.
The neuro run time integrateswith the swift server lifecycle.
So if you have a database driverthat needs to start and to be shut
down correctly to manage the TCPconnection and the concurrency,
it fits nicely into that.
(29:16):
You can write lambda function thatstream their response over time.
That's also something newwith the new V two runtime.
So instead of responding a bigJSON in one shot, you just stream
your bites as you receive them or
Leo Dion (host) (29:29):
it Jason Lines?
There's like a, there's a few ofthem I've noticed in Hummingbird
that supports Jason Lines and Jason
Sébastien Stormacq (guest):
I guess it is. (29:36):
undefined
I didn't look at that part in a INGbird yet, but I think A ING Bird two
also support a streaming of response.
That's
Leo Dion (host) (29:43):
Okay.
Sébastien Stormacq (guest):
That's convenient. (29:44):
undefined
If you have a long computation orbig documents that you cannot return
in one shot, you can stream them asyou receive or as you generate them.
You can also run.
Background tasks.
So there is a short momentof time in between the lamb.
The moment the lambda function returnsresponse to the client, and the moment
the container the micro VM is shut down.
(30:05):
There is a you can run code there.
Of course, you're going to becharged for that CPU cycle.
But you can do cleanup.
Task like, pushing logs, forexample, closing DCP connection.
So the idea is to respond to theclient as fast as you can, so the
client get this answer and thenyou do your cleanup task after.
That's also a pattern, which issupported by the new run time, and
we've got samples and documentationfor all of that, but at the end,
Leo Dion (host) (30:29):
sorry, go ahead.
Go ahead.
Sébastien Stormacq (guest) (30:30):
Now at the
end, you need to compile your code.
Most of us, we are developing SwiftLambda on Mac on a RM, but Lambda
doesn't run on mac a m, so we needto cross compile for Amazon Linux.
Today we are doing that with Docker.
So there is a swift pluginintegrated with the runtime.
You can just type swift.
Package archive and it will triggerthe entire sequence to get a container
(30:52):
running compile inside the container tocompile, to create a binary compatible
for Amazon Linux, which is the operatingsystem running on a Lambda, and at
the end it will produce a zip file.
And then it's your responsibilityto deploy that zip file.
And there again, youhave multiple options.
You can go graphically in the AWSLambda console click upload my zip file.
(31:13):
It works.
It's ideal to learn and tounderstand how it works.
It's not good for production.
Anything that you do manually.
It's not good for production.
it's.
better to automate and write scripts.
Leo Dion (host) (31:24):
Yeah, I was
gonna ask, is there like, any good
like GitHub actions to do this?
Sébastien Stormacq (guest):
To deploy on Lambda? (31:29):
undefined
I never try.
Because there is a GitHub, Like,GitHub actions like system in
AWS, it's called Code Build.
It's a pipeline for ci.
Most of our customer aredescribing the infrastructure
they want, you know, text file.
Like in a Yammer or JSON file, yousay, Hey, I want an API gateway.
I want that lambdafunction with that zip.
I want the API gateway tocall the lambda function.
(31:50):
I need a policy because theLambda function will call
DynamoDB, blah, blah, blah.
So you describe that in a Yammerfile, and you give that to a tool
that will create infrastructurefor you automatically in the cloud.
And the typical way to do thatfor Lambda function and serverless
application on AWS, it's calledsam which means serverless.
Application model.
SAM
Leo Dion (host) (32:11):
Okay.
Model.
Yeah.
Sébastien Stormacq (guest) (32:12):
That's the
end to end workflow where you deploy
at the end, the function is deployed.
And then you can use Ker orany HTTP client rest API client
tool to invoke your function.
You can also test locally.
Leo Dion (host) (32:24):
I was gonna ask
Sébastien Stormacq (guest):
just swift run. (32:24):
undefined
And it'll detect, oh, I'm on the Mac.
I'm not inside the Lambda container.
So it will start a mini HTTP serverand you can just curl to a local
host or 127 0 0 1 on port 7,000and pass your JS on file there,
Leo Dion (host) (32:42):
Is there any testing?
Testing libraries?
Sébastien Stormacq (guest) (32:45):
For Lambda?
Leo Dion (host) (32:46):
Do you hear the
Sébastien Stormacq (guest):
Not that I know. (32:47):
undefined
No.
So you I typically do the unittest with swift testing or
existing test before, like we do.
Usually I do some integration testing,like starting the mini server, sending
Leo Dion (host) (33:00):
Let me ask
that question again, just
So can you do any stuff withlike swift testing or XE testing?
Sébastien Stormacq (guest):
Locally on your local machine? (33:05):
undefined
Yes.
And actually it's a best practice.
Your Lambda code is just theentry point and the exit point.
All in between the two is yourbusiness logic and you should write.
Test, don't you?
For all of that.
And yes, you can run locallyyour SWIFT test and XCCT test.
What I Do also, it's integration tests.
So I, I run the serverlocally with Swift Run.
(33:28):
I send a couple of jsonpayload and verify the JSON
response that are coming out.
So it's a bit more than unit test.
It's like testing the entirefunction in one shot and.
Some customer are alsodeploying and that's one of
the advantage of the clouds.
All the clouds, not only AWS, is thatonce you have a script to deploy into
production, you can run the same scriptto deploy into another environment.
(33:51):
And so you have the exact sameinfrastructure in dev test, the
staging production, so you can createtemporary environment for your test.
Leo Dion (host) (34:01):
Could you, like, let's
say you're using services Postgres.
Key manager, S3 dynamo.
Is there a way to test that locally ifyou're integrating with those services?
Or what would you recommendoutside of like mocking those
services, I guess and architectingit with like, you know, that
Sébastien Stormacq (guest) (34:22):
Yes, there
is an open source project called Local
Stack, which is quite impressive.
They try to mock the majority of theA-W-S-A-P-I, so it start a server.
It's a mock for DynamoDB for three,for the Q-S-Q-S-S-N-S, the mail system
typically it runs inside the container.
And you can write script, testing,script as complex as you want.
That will.
(34:42):
Create the local stack you pointyour environment to local stack,
and then you can develop locally.
You don't need to have evenan internet connection to, to
develop against the A-W-S-A-P-I.
Leo Dion (host) (34:53):
Yeah.
Yeah.
Yeah.
That's awesome.
Just a few more questionsbefore we close out.
Is the AWS Lambda stuff, isit all Swift six now and,
Sébastien Stormacq (guest) (35:03):
Yes.
So we are working sincetwo, three months on that.
So there is a newversion of the runtime.
If you go to GitHub, swift, AWS.
Lambda runtime.
Right now, the main branch, it'snot tagged yet, it's not V two, but
the main branch contains code thathas all these API that I mentioned,
background tasks, the streaming,and it's fully swift six compliance.
(35:24):
We compiles with all errors.
We, without warning, we fully embraceI think a weight and underneath
we're still using swift, Neo to makeHTT P request to the Lambda API.
Leo Dion (host) (35:34):
Awesome.
What.
What new tech are you asfar as for developers?
Are you excited about?
That's either come out in the lastfew months or coming out soon?
Sébastien Stormacq (guest) (35:47):
I
start to be excited and it's
not going to be super original.
I'm sorry about the coding assistant,the gen AI coding assistant.
I was trying copilot insideX code the other day.
It saved me hours of typing boring codeto validate command line arguments.
Kind of guess what I'm going to write.
I just typed the firsttwo letters and I.
have three, four lines that I canaccept with just one, one keystroke.
(36:09):
So that, that's super useful.
On Amazon, we have something equivalentcalled Amazon Queue for Developer
Running Inside Visual Studio Code.
And that one, it's not trainedon Swift officially, it does not
support Swift, but it can help a bit.
But I use it more like a.
Chat, like, Hey a Shell script,something that would take me 15 or
20 minutes to write, I know how to do
Leo Dion (host) (36:29):
scripts are amazing
as far as gen generating code.
I've sent this beforeon the show, but like,
Sébastien Stormacq (guest) (36:35):
regular
Leo Dion (host) (36:36):
They're the gold.
Like, oh, regular exp.
Yeah.
Anything that, like we've said, anythingthat's been out for like 30 or 40 years,
it's gonna have the model data for it.
If you're asking about some likeUI thing that has only been out
for like three months, you're gonnaget, you're gonna get screwed.
Yeah.
Sébastien Stormacq (guest) (36:53):
But
one year ago I would've a different
answer saying, okay, theseassistance, yeah, it's a gadget.
It's not super useful.
But honestly, all the work that hasbeen done in the last year, we are
at a stage now where a developercannot ignore these tools anymore.
It's like cutting with allStack overflow or we, without
Google, you don't do that anymore
Leo Dion (host) (37:10):
That's a
good way to think about it.
Yeah.
And it's not replacing chops, it's just
Sébastien Stormacq (guest) (37:14):
No,
Leo Dion (host) (37:15):
no, it's just assisting
and like, and answering questions.
You know, like whether you, what is it?
You should put concrete andpizza and stuff like that.
But yeah.
Yeah.
Very cool.
Anything else you wannaplug before we close out?
Sébastien Stormacq (guest):
Try the Swift Lambda Run Times. (37:27):
undefined
If you are a Swift developer, ifyou have a need to run code on a
server go to Swift swift server on,on GitHub and read the, read me.
Give us feedback, please.
If something is unclear, especiallyas a, as someone new to AWS don't,
there is no stupid question.
The only stupid question is theone you are not going to ask.
(37:48):
So open an issue.
I'm reading the issue.
Join us on the swiftserver Slack, ask question.
There is a, Lambda channel there.
I'm spending most of my day keepingan eye on that channel as well.
There is the swiftserver forums as well.
Leo Dion (host) (38:01):
I
Sébastien Stormacq (guest):
So ask question, give us (38:01):
undefined
Leo Dion (host) (38:03):
thought of a question
for you actually before we close out.
Why would you're doing such a goodjob selling AWS Lambda, why would you
ever go with another Amazon servicelike EC2 or Amplify or something else?
Sébastien Stormacq (guest) (38:16):
For
my need as a developer, I want.
Zero.
I will not do it.
I will go serverless,I will go with Lambda.
The only reason if ever I have thatuse case as I said in the beginning,
depending on the invocation patterns, ifyou have workloads that are running for
long period of time and the constant CPU
Leo Dion (host) (38:35):
gotta
find that sweet spot.
Sébastien Stormacq (guest) (38:36):
The
pricing might be, higher on Lambda
and than a traditional solution,but beside that I will not do it.
Why our customer are stillchoosing containers or vm.
One reason is history, and theyhave like 40 years of IT history.
They are used to managevirtual machines, but not
containers and about containers.
For some long, if you need to runa server, for example, you didn't
(38:58):
fully embrace the serverlesspatterns of the cloud, maybe it's
like a sweet spot in between virtualmachines and full serverless where
you feel you still understand abit or manage the infrastructure.
Leo Dion (host) (39:09):
where you need to
have more regulation and it's like, oh
yeah, you can't do this on a Lambda.
It needs to be this machine with this.
Yeah.
Sébastien Stormacq (guest):
that might be a reason. (39:16):
undefined
Some customers think that if they deployto customer they will have a bit more
portability in case they want to changecloud provider, which is partially true.
So that's another reason whysome customer are using virtual
machines or docker containers.
I.
Leo Dion (host) (39:32):
Thank you.
Sebastian, where canpeople find you online?
Sébastien Stormacq (guest) (39:36):
Everywhere
on Blue Sky, it's LinkedIn Threads,
mastodons I'll put my links in.
I'll send you my links and youcan put that in the comments.
Yeah.
Leo Dion (host) (39:46):
Yeah.
Well, thank you so muchfor coming on Sebastian.
We'll link to your presentation as well.
It was great to finallyhave you on and chat.
People can find me on X at LeoGD on Mastodon at Leo g dn.
C, IM LinkedIn, yada.
If you're watching this onYouTube, please like and subscribe.
And if you're listening to this on a podpodcast player, please post a review.
(40:10):
Thank you so much for joiningme for today's episode.
Consider joining our Patreon if you wantearly access, and we will see you again.
Bye everybody.
Sébastien Stormacq (guest) (40:21):
Bye.