OK hello how yours and welcome to this lecture this lecture we're going to build a Servilius web page
using API gateway and LAMDA.
Now I appreciate we haven't covered off what API gateway is just yet.
We will do that further along in the course but for the purposes of this lecture it's just to show you
how we can build out the surplus web page that uses various different components and then you don't
have to worry about you know easy to and going in and managing that environment.
It all just reacts when your users actually go and visit the site.
And this is exactly what happens when you visit the cloud doc gooroo Web site.
We do not run any service whatsoever.
We use a combination of Ingela yes across all the client devices.
We then use API Gateway we use lambda to trigger individual lambda functions and then all of our video
files are stored in this tree which we then back off to cloud front.
So we have built a service learning management system and that's one of the reasons why our courses
are so cheap compared to our competitors is because we have a much lower cost base than them and we
passed that cost based on to you.
We don't have to worry about you know running data centers for example or you know Rax and we don't
need to worry about network administrators system administrators etc. all of our code just runs natively
in the cloud.
So let's have a look at what a web site which is going to look like so here we have our user and they're
making a get request all they're making they're trying to resolve a domain name which will be hello
cloud gurus dot com.
So I have registered this domain name and we will cover this off in the route 53 section of the course.
Don't worry if you don't have a domain name we can just use the DNS name for the three buckets.
So when we resolve this through route 53 it's going to resolve to straight and inside as three we're
going to have our indexed not hatred you know web page there.
We're also going to have an area of hatred email web page in there and then in the sexual little web
page we've got a button that you're going to push when you push that button is going to trigger a get
request to API gateway and then that is going to trigger a lambda function and that lambda function
simply print out your name so you just change your name in there and then that will be passed back through
API gateway to your S-3 bucket.
And then it will be returned to the user and instead of saying hello how gors when you hit the button.
It's going to say hello and then your full name.
OK so this is a letter and you need to log into the AWOS con..
OK so here I am in the AWOS console.
I'm going to go down to Lamda which is under compute and I'm going to go ahead and click on that.
And if you haven't created a function before you're going to get this following splash page let's go
ahead and hit create a function.
Now the UI has changed off to reinvent 2088.
So you either have or from scratch or blueprints when we go on to do the Alexa component we can to use
a blueprint.
But right now we're going to operate from scratch going to call this my server lists them web page and
then the runtime environment is going to be Python 3.6.
And then in terms of the role you probably don't having an existing row right now so let's go ahead
and create a new role from a template we'll just call it my lambda execution role.
And this essentially allows you gives Lamda permission to actually execute.
Don't forget with AWOS you have at least privilege.
So you need to create a role in order for lambda to work.
So in here what we want to do is we want to select the simple Micro's services permission or Micro's
service permission and that will give us a basic execution role so go ahead and hit to create your function
and that can take a little bit of time.
That is hanging a little bit and there we go.
We have now created Alem to function.
So you'll be able to see configuration and in Him monitoring them we have our design a whya and if we
scroll down we have our function code.
So you can see now there's an ID which is a an integrated development environment ID and this one was
actually bought by Amazon.
It used to be cloud nine.
They bought it and now integrated it into AWOS.
So this is where we're going to pace our code.
You scroll down here we've got our environmental variables.
This is where we pass a variable back to our code.
We're going to use that in the very next lab and down here we've got our execution wrong.
This is where we define our roles.
These are all basic settings.
This is where we head into the description for our lambda functions so we'd say my basic columned Web
site or something like that in here we can do our timeout.
So after three seconds automatically terminate this for the Poly lab we're going to increase this to
five minutes because the police service can take some time.
Abbo going to leave everything as default for now.
So let's scroll all the way up.
We're not going to set our target just yet what we're going to do is we're going to put our code in
two years ago over where you download a Joe code some down where I download my code I zipped it to service
and in here we've got three different bits of code we've got error index and we've got Hilary cloggers
dot Python.
We want to open up this one.
Open that up in your favorite text editor.
I always use text wrangler for Mac and it here what we want to do is if you want to change your name
so is saying my name it could be your name.
Go ahead and change that and then save it and then we just want to copy this entire clipboard over here.
We just want to paste it in and that is literally all that we're going to do.
We're going to leave everything else has to go ahead and hit save and that will save our function.
And then what we want to do now is now that we've saved our function as we want to be able to trigger
this how are we going to trigger this and understanding the different Lamda triggers is pretty essential
going into both the solutions architect associate and developer so should exam.
So you will need to try and commit to memory or what I would do is try and remember what contract Alamdar.
So right now dynamite D-B can trigger lambda but RDX cannot for example.
So just bear in mind what we're going to do is we're going to add a trigger and we're going to add API
gateway.
And I can see down here that it says configuration is required.
So we go down to configuring our triggers.
Note that the environment has now dropped away.
So you will need to save this before you get your ID back.
And I'm just going to leave everything as default.
I'm going to call it.
Yeah.
Lamda Micro's service deployment deployment stage will be my proud production environment security I'm
just going to use I am leave everything is default hit add and then go ahead and hit save up here and
that will actually go ahead and create an API gateway for you.
You see the actual R L in him.
So what we want to do is you could click on that but it's not going to work.
So just go back to where you were and then what we want to do is we want to click on method any and
this will drop us into the API gateway section or API Gateway does come in but the solutions architect
associate and developer associate exams and we will have an entire lecture on it later on in the course.
But it's not in this section of the course.
So what I really like about API gateway is the UI.
So the client is you.
So you at your laptop at your desktop et cetera.
When you go to a Web site so you say you go to a cloud are you sending a p method and you know it's
a get to request essentially this get request goes to your sorrow.
And if it's hitting API gateway essentially what API gateway is going to do is going to proxy it through
to lambda lambda then responds to your request depending on what information you're sending it.
So even here with it it's triggering our function.
My service web site that response is then proxied back through to API gateway which then gives you a
method response and is sent back to your client.
So right now we've got any method available to us.
We don't actually want that because that allows all DTP methods and we only want to allow it get request.
So what I'm going to do is just going to go in here and delete this method and just say yes delete any
because it's not a secure number.
What we want to do is go ahead and create a new method.
We're going to create a get rich best hit the little tick and then we're going to have our integration
type so we could be passing this get requests through to allow them to function all through to TDP through
to mock.
That's basically a mock response returns a response Buli using API gateway mappings and transformations
which will cover off mappings to actually cover off in the next couple of lectures.
Or you could send it on to another AWOS service.
I'm going to send that to Lamda.
I'm going to allow lambda proxy integration.
You then select all regions so we want EU west to which is where I am so you select whichever reach
you're in if you just type something in here you'll be able to see functions that are available so we
won't miss this Web site.
Go ahead and hit save and go ahead and hit.
OK.
That now allows.
Get requests to our lambda function.
What we need to now do is deploy our API to just go to actions and hit deploy API and now deployment
stage we want to play this into Prod. and we might just write my first deployment something like that.
So go ahead and hit deploy.
So if that has worked you'll be able to click down here.
Notice that you're in stages now so if you ever want to get back to you know your different stages click
on stages and what we want to do is click on stage and then click on get and you get this invoke you
are old and you should be able to click on that and hopefully you'll be able to see your name or my
name depending on whether or not you've changed it.
So that means it is all working now the very next thing we need to do is go ahead and set up a story
like I saw it back in the console.
The first thing we need to do is just go over to S-3 and create our buckets that we're going to host
our Web site from.
So just go ahead and hit create bucket enter in a name I'm going to call it a club.
My service web site version 2.9 because people have taken to 2.0 2.1 etc. so I'm going to use 2.9 and
then I'm just going to leave everything as default and go ahead and hit create.
And that's going to create my bucket.
So now you just need to go to the directory way you downloaded the files from the resources section
of the course.
And here we had three files we had our indexed CMO.
Hello cloggers dot Python which is Zeland lambda function.
We had our adult females.
We just want to open up our index dot hatred Himoto and in here we can see our h you know it's pretty
pretty simple but in here we have our heads so we're doing a get request and here is your API gateway
link here.
So what we need to essentially do is we need to go and paste in our API gateway link.
So back in the AWOS console you can get to API Gateway by just going down to application services and
going to API gateway.
Click on that click on your lambda Microcircuits click on stages and then click on prod and then just
make sure it goes all the way down and click on get and you want to get this link.
Is a copy and paste this link into your clipboard and we want to paste it in here.
And there we go.
We can now save this and we will upload it to S-3.
OK so I'm back in the AWOS clone so I need to go to S-3 which of course is under storage and I'm just
going to click on here.
Now what we want to do is a new a way that S3 is operating and we need to basically enable this bucket
to be public in order to host a web site so you can see here.
I've got one bucket that's already public.
If I just close this it might be easy to see say in here it says buckets and objects not public.
And that's the default setting now and then objects can be public.
That's what we need to enable.
And then when we make a static web site using S3 we'll get this public thing if we do that using the
bucket policy.
So what we do is or just click in click on the bucket that you are going to host the Web site from and
then just go to and click Edit public access settings make sure everything is unchecked.
Go ahead and hit save and then go ahead and type confirm and hit confirm and you'll say that this now
changes the access to objects can be public as opposed to bucket and objects not public.
So we've done that.
Let's go in here and upload our two files.
Just go ahead and add your files.
And so I've saved mine in several web site and it's index page Timo and erudite Hey so I'm going to
go ahead and at those in now and I'm just going to go ahead and hit upload.
And then once that's uploaded We'll get to successes.
All you need to do is click in on each object and just go make public so make public that in here we
want to go actions make public so made those too public you can see the success Kurd's down that just
close these off.
And then finally what we want to do is just make sure that this is a three bucket can act as a web site
so all we need to do is just go to properties go to a static web site hosting and say use this bucket
to host a web site going to change the index.
Are we going to put the index document as index page to him.
An era.
Don't hate at for our era document and go ahead and hit save.
And then if we come back we should be able to see these these files.
So if you just click in here you'll be able to click on this link.
Or alternatively you can go over to your static web site hosting and click on this link and that should
then load those files.
Let's go ahead and click on this.
And here we go.
Says hello cloggers.
There's a little button that says Click me.
This is a cloud Guri team at surplus camp in Austin Texas.
That is me.
Hello cloggers.
And yeah it is great fun if you guys ever want to come to severals.
We've got them all around the world so do check out our Web site several It's called Don't I.
And hopefully when we click this button we should get a return response from Lamda as to our name so
click and they go hello Ryan Kronenberg.
So what we've done is we've created our own S-3 what we've created our and service web site using both
S-3 API gateway and LAMDA.
As one last thing I want to show you if we just go back to the AWOS console some back in the AWOS console
if we just go over the identity access management you remember right at the start we created a role
and we called that role.
Hello cloggers LAMDA.
You actually click in there you'll be able to see the policies that are attached to this row.
So we've got the basic execution road that allows lambda to do basic execution.
We also have the AWOS lambda microstates Micro's service execution.
If we click in there we'll be able to see the actual policy statement.
So it's in Jason we could go have it a policy summary.
And essentially what this is allowing us to do is to read and write to Dynamo D.
B.
So that is a policy that is attached to our fellow clogger is Lamda row and we can add additional policies
so if we want read and write access to S-3 for example we'd go in and attach a policy here and type
time in S3 and maybe you want only read only access.
Or maybe you want your lambda functions to write to S-3 etc..
And as we go throughout this course and create more and more complex lambda functions we will need to
continuously update our permissions to allow lambda access to other AWOS services.
So the last thing that we need to do is to configure route 53 to redirect DNS requests for our DNS name.
We're going to use Hello cloggers dot com.
And that is going to redirect straight to our S-3 bucket.
And then from history we'll be able to go into API gateway then on to Lamda and back again.
So to do that we would go back to the console we would go down to route 53 which we haven't covered
yet but it is an entire section that's coming up in the course in here you can register your own domain
so you can go to registered domains and register a domain or you can go ahead and do that.
They aren't free.
Some of them will cost $12.
It depends on the domain name.
After Obelix $39.
Cetera.
But if you do want to go do that it can be useful especially if you plan on doing any of the other associate
courses that can be useful to play around with the domain name you know and route 53.
Once you register the domain name you'll see it in your host zones.
So I've Hello how gurus dot com if I click in here.
We always have an industry.
And they start over 30 record what we would want to do is create a record set in here you'd have it
as an alias you'd leave this blank because you want.
Hello cloggers dot com to resolve to your three bucket.
Now if you click in here basically it can take a little while to load.
You have to be patient.
It can take like a couple of minutes sometimes to show you your Web site points but just wanted to point
this out.
There we go as Lloyd says no targets available and you might be thinking Well hang on we've got in this
three bucket that's set up as a web site.
Why can't I use the three Web site in point.
Why isn't it showing it there why can't I click on that.
And that's because I didn't call my bucket.
Hello cloud gurus.
It needs to have the same name as your DNS name.
Now believe it or not somebody actually owns Hello club gurus as a bucket and it's not me so I can't
go ahead and demonstrate this for you.
But if you do want to create your own service you know Web site that's using a domain name.
Make sure that when you go to register the domain name that is three bucket name is also available because
if it's not you won't be able to use route 53 to connect to your bucket.
So that's something just to know the future.
So I really hope you enjoy it if you think about what you've just accomplished.
You started out just learning what to is we've gone through and we've learnt how to make web servers
we've learned about security groups we've learnt about elastic balances etc. and now we're really venturing
into the future where we're getting rid of easy to getting rid of servers and essentially what we're
doing is we're moving to lammed API gateway S3 et cetera and that is really the future of cloud computing
in my opinion because when you have no service to manage it makes your infrastructure a hell of a lot
cheaper.
You don't need System Administrators anymore database administrators network admin administrators etc.
and you only pay for execution.
And of course Lamda gives you one million free executions per month.
So it is very very cheap.
So the level of debate as to whether or not services actually services.
Obviously it all runs on servers but civil list is basically where vendors take care of provisioning
and management of servers.
The vendor is responsible for capacity provisioning and automated scaling.
We no longer have to worry about our orders scaling group configurations.
That's a great thing about API gateway and Lamda.
It just scales automatically.
You don't have to worry about you know Paik performance.
Our biggest peak performance is Black Friday Cyber Monday and New Year's Day and I don't have to worry
about it anymore because literally Lamda an API Gateway will scale with me and I think I'm moving away
from servers and infrastructure's should be everyone's and go.
And the reason for that is because of awareness said so when I said very famously at the Sydney summit
in 2017 he said that no server is easier to manage than no server.
So leave you on that note in the very next lectures what we're going to do is we're going to create
a service web site using polie.
And essentially what it will allow you to do is to as you take notes throughout this course you'll be
able to generate them into MP 3 files using the police service.
Those will then be stored in S3 and the very end of that.
What we're going to do is we're going to hook that up to an Alexa unit and we'll be able to get Alexa
to randomly read out your notes.
So if you've got the time join me in the next lecture.
Thank you.