OK hello flowers and welcome to this lecture this lecture we're going to build a surplus 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 well when new 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 servers whatsoever.
We use a combination of ungulate J 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 history which we then back off to cloud front.
So we have built a survivalist 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 Raxton 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 that user and they're making a get request all they're making.
They're trying to resolve a domain name which will be hello cloggers 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 S3 we're going
to have our index dot page D-Mo. web page there.
We're also going to have an area of the mill 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 will 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 cloggers 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 J-ws con. 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 creator function.
Now the UI has changed off to reinvent 28 names so you either have or to 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 and their 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 have 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 always have at least privilege.
So you need to create a row 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 rules to go ahead and hit create a function
and that can take a little bit of time.
That is hanging a little bit and there we go.
We have now created Ahlam 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 idea which has 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.
If 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'd empted the description for our lambda functions so we'd say my basic columned Web
site and something like that in here we can do our time out.
So after three seconds automatically terminate this for the Holy Land 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 trigger just yet.
What we're going to do is we're going to put our code in two years ago over the way you downloaded Joe
code down where I downloaded my code Ion's 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 hear 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 and 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 as default.
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 is 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 associate exam.
So you will need to try and commit these to memory or what I would do is try and remember what triggered
lambda.
So right now dynamite IDB can trigger lambda but cannot for example.
So just you know keep Bear in mind.
So what we're going to do is we're going to add a trigger and we're going to add API gateway and you
can see down here that it says configuration is required.
So we go down to configuring our triggers.
Note that the ideal 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 to deployment deployment stage will be my Prod. production environment security
I'm just going to use I am leave everything as 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 You 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 up in both 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 liked 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 d d p method and you know it's
a get to request essentially this get request goes to your you are ill 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 here we go.
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 or DTP methods and we only want to allow a 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 secure.
And then 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 a lambda function or through to TDP or through
to mock d'Este basically a mock response or returns a response purely using API gateway mappings and
transformations which will cover off mappings to actually color off in the next couple of lectures.
Or you could just 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 one e us to which is where I am so you select whichever reach 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 that deployment stage we wanted 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 stages and then click on get and you get this invoke you
are.
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 S3.
OK so I'm back in the AWOS console.
We just need to go down to three under storage.
And as you remember we created our bucket a little bit earlier so it was a cloud during my service web
site 2.0.
Go into there and now we're going to upload our assets so if you go back over to the resources section
of the course in here we had three files we had our indexed on page CMO.
Hello cloggers dot Python which Sal and lambda function and we had erudite Tomales we just want to open
up our index start Timo and in here we can see that you know it's pretty pretty simple but in here we
have our headings 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.
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.
Here 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 K so I'm in the three cons so I'm going to hit upload
and add my files and I only want my index and my arrow we don't want my lambda function up there.
Click OK.
Instead of clicking upload just go ahead to next because we want to set our permissions and we're going
to change our public permissions to grant public access to the object.
It can give you a big warning message his saying that it already has public access.
Just go ahead and hit upload and upload to files.
Sometimes my eye takes a little bit to refresh.
There we go in see my two files.
I will teach you how to make everything public essentially using.
I think it's under a backup policy.
You can put a policy in here that makes all your objects public so you don't have to keep doing that
thing.
We will cover that in a couple of lectures from now.
And so what we want to do to test this.
We click on index and we click on this link here.
And here we go.
It says Hello cloggers there's a little button that says Click me.
This is the a cloud Guri team at several this camp in Austin Texas.
That is me.
Hello cloggers.
And yeah it was great fun if you guys ever want to come to a soulless camp.
We've got them all around the world so do check out our Web site.
List.
I.
And hopefully when we click this button we should get a written 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 are and several This web site using
both the S3 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 to identity access management you remember right at the start we created a role and
we called that role.
Hello cloggers lambda.
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 rule that allows lambda to do basic execution.
We also have the AWOS lambda microstates Micro's service execution role if we click in there we'll be
able to see the actual policies statements in Jason we could go at 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 we type in S-3 and maybe you want only read only access or maybe you want your lambda functions
to write to S-3 et cetera.
And as we go throughout this course and create more a more complex lambda functions we will need to
continuously update our permissions to allow lammed 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 a stray we'll be able to go into API gateway then onto 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
off yet but 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 itself to be $39 etc. but if you don't want to go do that it can be useful
specially 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 hosted zones.
So hello how gurus dot com if I click in here we always have an in-house record and a start over 30
record of what we would want to do is create a record set in here you'd have it as an alias.
You leave this blank because you want Hello cloggers dot com to resolve to your S-3 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 website and points
but I just wanted to point this out.
There we go it has loaded now says no targets available and you might be thinking oh hang on we've got
this three bucket set up as a web site why can't I use the three Web site in point.
Why isn't it showing 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 cloggers 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 a Web site that's using a domain name.
Make sure that when you go to register the domain name that that 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 note for the future.
So I really hope you enjoyed it.
If you think about what you've just accomplished you started out just learning what AC too is.
We've gone through and we've learned how to make web servers we've learned about security groups we've
learnt about elastic load 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 1 million free executions per month.
So it is very very cheap.
So the level of debate as to whether or not Cephalus is actually Servilius.
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 so we no longer have to worry
about our auto scaling group configurations.
That's the great thing about API gateway and LAMDA.
It just scales automatically.
You don't have to worry about peak performance.
Our biggest Paik 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 go.
And the reason for that is because of what was 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 Poly's 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 unit and we'll be able to get Alexis to randomly read out your notes.
So if you've got the time join me in the next lecture.
Thank you.