Adding Domain and SSL2:49
show us the certificate or the validation CNAME records for the certificate. And we need to add this record to our DNS provider in order for AWS to verify our control over that domain. So I will copy the name, then head over to my DNS provider, add a new record with the type CNAME and paste the name. Then back to Weber, copy the value and paste it in the DNS provider's dashboard. I'm also going to disable proxying so the traffic goes directly to AWS. And now the certificate is issued. So let's switch to our code editor and edit the Weber.yaml file. We will add our domain to the domain attribute. And then we deploy. I am going to skip the wait for the deployment to finish. And here we go. Weber finished the deployment successfully. But let's scroll up here a little. And we can see that Weber displays two DNS records that we need to add in order for the domain to point to our function.
Domain Variations Setup5:10
we can see that it serves our Laravel application. And if we visit the www domain, it redirects us to our root domain and serves the application. If you want to use a subdomain instead, all you have to do is replace the root domain in the weber.yaml file with a subdomain. Same if you want to use a wildcard subdomain. You will still have to add the root domain to Weber even if you intend to use a subdomain or a wildcard in your weber.yaml file. Weber will issue an SSL certificate that covers the root domain and wildcard subdomains. So it can be used with any kind of domain that you use in your weber.yaml file. Also if you want to use multiple domains, you can put an array for the domain attribute value. So here we will add an array, add our first domain and then the second domain. Now let's talk about asset files. In a normal Nginx setup, asset files are served by Nginx directly. Nginx checks if the request
Assets on Lambda Overview6:07
array, add our first domain and then the second domain. Now let's talk about asset files. In a normal Nginx setup, asset files are served by Nginx directly. Nginx checks if the request path matches an existing file on the server and then it serves that file. But when running on AWS Lambda, we don't have Nginx to do that for us. So we will need to handle serving asset files differently. AWS recommends that the asset files get uploaded to S3, which is a storage service provided by Amazon. We then use the S3 URL for each asset to display it in our HTML. We can also put CloudFront in front of S3 and CloudFront is a content delivery network and using it in front of S3 means the assets will be served from an edge location close to the website visitor. Now Weber takes care of that for us and it also allows us to use a custom domain to serve our asset files. Let's take a look at that. In our application's routes file, I have a route that
Inspecting Asset Delivery7:08
Now Weber takes care of that for us and it also allows us to use a custom domain to serve our asset files. Let's take a look at that. In our application's routes file, I have a route that responds to the asset path. This route represents a view named asset. Let's open the view file and we can see that we have an img tag that serves an image.png file. Now let's go check the image in our public directory and that's our image right there. If we go to the browser and head over to the asset path, the image will be displayed for us. Let's check the source of this image and we can see that this image is coming from a CloudFront domain. The UUID part in this path represents the ID of our deployment and it changes with every deployment to serve a fresh asset file. Now let's see how we can serve assets from our own domain. Let's head over to our code editor, open the weber.yaml file and then add an asset domain attribute and provide an assets.mahbari.com domain.
Configuring Custom Asset Domain8:16
see how we can serve assets from our own domain. Let's head over to our code editor, open the weber.yaml file and then add an asset domain attribute and provide an assets.mahbari.com domain. Finally, we will deploy. The deployment will take some time so I will skip the waiting as usual. And here we go. After the deployment finishes, Weber displays a message indicating that a custom asset domain was created and it displays the DNS records we need to add for that domain. We will copy the name, add a new record in our DNS providers dashboard. This record should be a CNAME and we paste the name here. Then we go get the value and then paste it here. And then we click save. It might take some time for the DNS records to propagate so make sure you give it enough time. I'll skip the waiting through the power of video editing as usual and we'll head over to our asset route, refresh and check the source of our image. And here we go. Our assets are now served from our
