Hi, everyone, and welcome back.
Now, in today's video, we are going to discuss about cloud front functions.
Now, the overall cloud front functions are also referred to as a lightweight lambda edge, primarily
because of the similarities between both of them.
Now, at the high level overview, the cloud front functions allows the users to write lightweight functions
in JavaScript for high scale latency sensitive CD and customization.
So CD customization your refers to the cloud front.
Now, one of the benefits here of the cloud front functions is that you can manipulate the request and
response that flows through cloud.
So let's go ahead and understand this with a simple diagram where you have a user, you have the origin,
you have the client user sends a request to the cloud front cloud and sends the request to the EC two,
EC two sends the response, which is welcome cloud and sends the response, which is a dot Amazon.com.
So here the response is completely different when compared to the origin response and why the response
is different is because there is a cloud front function, and in this function there is a logic which
states redirect all the requests to the docks.
So this is one of the simple use cases where cloud trend function can prove to be useful.
So let's go ahead and have a quick demo.
Now, for today's demo, I have a simple cloud print function that is available.
The name is demo function.
If we'll quickly open this up now within the function code, you will see that in the response.
The status is 302, which is related to the redirect and where it is redirecting.
It is redirecting to the cloud front page of AWS and the response is return.
So a very simple code that will be returned when this function is invoked.
Now, if you look into this function, this function is associated with the cloud front, with this
specific distribution ID ending with v u n, and we also have a cloud distribution ending with v u and
now this specific cloud distribution.
If you look into the origin, there are multiple origins which are set up.
So ideally without our function, the response from this origin should be received.
However, since the function is associated with the distribution, we should get a different response
related to the cloud front page.
So let's quickly try it out.
So let me copy the domain name associated with the cloud from distribution and from the CLI.
If we capture the response headers here, you see we are getting a302, which is primarily for the URL
redirection and the location is the Amazon.com cloud front.
So if you want to quickly test it out in the browser, you can add the URL of the cloud front distribution
and it is redirecting to the Amazon cloud front page.
All right.
So I hope with this at a very high level overview, you understood what the cloud front functions allows
us to do.
You can write simple lightweight functions and associate with the cloud trend, and based on that,
the request and the responses can be manipulated accordingly.
So with this will conclude today's video.