AWS S3 Static Website Hosting with AWS Cloudfront

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello and welcome back to another session today's session we are going to see how to host a website with aws cloud print and s3 as origin before getting into the console let's discuss about cloudfront on a high level cloudfront is a content delivery network service offered by aws in short cdn so as the name suggests it's used to deliver content to your end users and the content can be stored in aws s3 ec2 or load balancers these are called as origins that is from where the content originates from apart from these aws services you can even host the content in your own custom origins so why is this even required and why can't the users directly access the content from the origin itself it's because of the following features the first main reason is cloudfront offers global edge network as you see in the background these edge locations are across the globe and your content is cached in these locations which reduces the latency and serves the global user base it ensures that your content is delivered securely as it automatically integrates with aws waff and ssl encryption is enabled and also prevents any ddos attacks you need not worry about any of it as your content is cached redundantly in various edge locations the availability of your application increases and also it's cost effective there are various discounts that aws offers for longer term commitments and includes pay as you go model now let's get into the console and see how to host a website using cloudfront with s3 as origin okay so we are in the console now the first thing which we want to do is create a bucket and upload few objects to it which will act as the origin for us so i'm naming the bucket as listen to learn and using the region as us east and blocking all the public access so that any of your bucket content will not be able to be accessed directly enabling the bucket versioning and leaving rest of the configurations pretty much default so we have our bucket and the objects of the bucket are not public let's go ahead and upload few files which will be served through cdn so i'm just adding a couple of html files here and once those are uploaded let's just quickly check if the buckets if the files are accessible so i'm just going to try accessing one of the files so ideally you should be getting an access tonight this is because we haven't enabled any of the permissions for any of the files so now let's go get into cloud print and see how to host it using cloudprint so for that first we have to create a distribution so this distribution is the one which will link to your origin and we have to select a content delivery method so in case of origin we are going to select s3 rs3 bucket so you have various options like load balancers and other origins as well but for this use case we are going to select s3 bucket and then if you have a specific prefix path you can specify that for now we have stored our content in the root so we are going to leave it as such and if you like you can enable origin shield which is acting as a one more layer of shield before directly accessing your content from the origin itself and you can enable restricting the bucket access so the users will not be able to access your bucket directly apart from through the cloud print so which will by default create a access identity and then we can ask aws itself to create a bucket policy for us which will state that only cloudfront has access to the bucket and its content and these are the connection items that cloudfront will make to your origin to crop your content so it's very helpful in case of hosting your own website in case of s3 this should all work with the default settings so i'm going to go ahead with the default settings and if your application requires any custom headers to be passed then you can specify them there and view a protocol policy it's always advised to redirect your http to https so that it stays secured and if your application always serves https only content then you can go for that as well and a lot of http methods in this case we are just going to go with get and head as this is only a static website in case of dynamic websites you can go ahead and select put post options as well and the cached http methods are going to be again get an head because those are the only methods which we have enabled and then you can attach your cache policy to your cloudframe distribution so aws by default provides few of these policies we can try to view what the policy says it mainly controls the ttl settings that is time to live it is how long you want to retain the content in the cache before considering it as a cache miss and reaching out to the origin to grab the actual content so the minimum ttl by default is one second and then the maximum ttl is 365 days and the default atl is one day and you have the option to change this by creating your own policy as per your application requirements so right now i'm going with the default and the origin request policy allows you to specify any headers or the query string parameters that needs to be passed to your origin and smooth streaming if enabled it is used for delivering video content and restricting viewer access to any signed urls or signed cookies and even you can attach a lambda function which will run at your edge location itself in case you have to execute any specific code specific to your application and also you have an option to select the edge locations which needs to be enabled by default it is all edge locations but even you can constrain it to specific locations like us or canada and or asia based on your user base which will result in some cost reduction and also you can specify any alternate domain names if you are hosting your own domains and then you can specify your own custom ssl certificate or use the default cloudfront certificate so i'm going with the default one here the supported http versions right now the versions are http 2 and http 1.1 if you are using a lower version you can use that as well and you can enable logging if required and you have an option to either leave the distribution state enabled or disabled and you can enable it as a later point so let's go ahead and create the distribution so if you click on the distributions you will see that the distribution creation is in progress this will take almost four or five minutes and if you go into the identity access you should be able to see a new identity created there so let's wait for a couple of minutes for the distribution to get created so we have the distribution created i actually paused the video for a while to let the distribution be created so before trying to access it i want to show you something quickly that is the bucket policy which cloudfront has created us for us so if you go into the buckets and take a look at the permissions you should be seeing a bucket policy attached now which allows get object only from the cloudfront origin access identity so this is the way how cloudfriend is accessing your s3 objects so this is very important to restrict the access so that your objects still stay private and no one will be able to access your objects so this identity id will match the identity id in your bucket policy okay so now let's go ahead and see try accessing our domain so just crop the domain name and open a new window and hit it there so in along with that i'm just including the index.html as a file that we want to access so there you go so you will be able to access your index file directly so this is how simple you can uh host various uh other origins just in a similar way so it's very simple and very easy to organize it so that's it for today guys hope you found it useful if there are any questions please leave them in the comments below see you soon in the next video thank you [Music] you
Info
Channel: Cloud Guru
Views: 1,036
Rating: undefined out of 5
Keywords: s3 static website hosting, s3 static website, aws static website, route 53 aws, route 53 deep dive, route 53 hosted zone, route 53 cloudfront, route 53 tutorial, route 53 cname, cloutfront net, cloudfront s3, cloudfront deep dive, cloudfront wordpress, cloudfront s3 static website, cloudfront signed url, cloudfront aws, aws s3 tutorial, aws s3 bucket, aws s3 static website hosting, aws s3 static website, aws s3 static website https, aws s3 static website tutorial, aws
Id: fGspu_Sa8co
Channel Id: undefined
Length: 11min 5sec (665 seconds)
Published: Sun Aug 22 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.