Jump to content

Guide to Setting up Amazon Cloudfront + S3


Recommended Posts

Hello!

I have looked around and it seems that there were a lot of questions about to setup Amazon S3, Cloudfront or even both. For those of you that would a setup like this, i have decided to write up a very quick and simple tutorial. I hope this helps.

 

Step 1: Create Amazon Account (duh) while creating the account is free, their services are not and it's pay as you go so be sure to check their pricing. 

Step 2: Create an Amazon S3 bucket. When naming the bucket, it HAS to be a global unique name so best practice is to name it whatever you want your domain name to be. e.g. cdn.example.com. For this purpose, i have named mine "tbucket2" Leave everything else default.

Step 3: Go to your AWS console and go to CloudFront.

Step 4: Create Web Distribution. For the Origin Domain Name, you will need to select the bucket you just created. Amazon will auto generate this in the drop down menu.

  • For the "Origin Path", this can be left alone if you have your board at the root of your host.  
  • In the "Restrict Bucket Access", you would want to select "Yes". This will allow Amazon to restrict access to users from using your bucket URL. 
  • "Origin Access Identity, You can either create a new one or use your existing identity. I created a new one for this purpose. 
  • in the "Grant Read Permissions on Bucket" you would want to select "Yes, Update Bucket Policy. This will auto update your bucket policy with the settings above. 

You can leave the rest of the options by default or change your preferences, it's up to you.

 

Now that you have created your bucket and web distribution, it's time to set them up on your board. 

Step 5: Go to ACP -> System -> Files -> Storage Settings -> Configurations -> Create New.

  • Select the "Amazon S3" method
  • Enter your bucket name you created
  • Endpoint can be left alone, Amazon will automatically choose the endpoint based on your bucket's region.
  • Enter your access and secret key
  • Use a Custom URL and enter the URL that cloudfront gives you when you created the web distribution. It looks something like xxxxxx.cloudfront.net or use the CNAME if you entered one. 

Capture5_LI.thumb.jpg.742f87978e3758f6043105cb023f38e3.jpg

 

 

Then "Save". You are done.  Using both of these services, you will free up some storage space with your hosting and still have a functioning CDN. 

Please keep in mind this was a generic guide to setting some of this up. Some may not have to use both services and only choose to use one or the other. It's entirely up to you. 

i hope this is helpful to some of you. 

It's my first tutorial. :) 

Link to comment
Share on other sites

On 7/12/2017 at 7:39 PM, NoGi said:

Thanks for this. How are you finding S3 performance with serving images to your community? I've just turned this on with my test site and it seems ok. Just images though, haven't used the cloudfront.

It's not bad at all. Although using JUST S3 will only use the region where its locates so if you have your region in Oregon but you have a EU member uploading an image, it will be a slower upload for them (unless you turn on S3 Acceleration). That's why i use Cloudfront since it pulls from the S3 storage and distributes them. 

Link to comment
Share on other sites

Running well on my test site and was about to hit the button on my live site but than I thought of something......how are you guys managing test sites when your live site is using S3? If you flick your test back to local, won't it migrate your live photos back to the test site breaking your live site?

Link to comment
Share on other sites

4 hours ago, NoGi said:

Running well on my test site and was about to hit the button on my live site but than I thought of something......how are you guys managing test sites when your live site is using S3? If you flick your test back to local, won't it migrate your live photos back to the test site breaking your live site?

Both sites can use the same bucket. All you need to do is configure each site to use a unique Bucket Path in your Invision Community S3 configuration. It will then only work with files in that path.

Although, I would recommend using separate buckets per site. :) 

IMG_1740.PNG

Link to comment
Share on other sites

Thank you for the tutorial this would have been very helpful for me a few months ago. My question is, does cloud front offer a significant savings? When I was using S3 for hosting my bills were 300 - 500 per month, so I switched back to local storage.  

Link to comment
Share on other sites

4 hours ago, ProSkill said:

Thank you for the tutorial this would have been very helpful for me a few months ago. My question is, does cloud front offer a significant savings? When I was using S3 for hosting my bills were 300 - 500 per month, so I switched back to local storage.  

If you were using S3 for both storage AND distribution, it would be extremely expensive.  S3 screws you over on pricing for bandwidth but super cheap for storage.  Cloudfront is the CDN to distribute your files and using S3 + CDN ought to be cheaper than using S3 alone.

There are even cheaper CDNs out there.  I personally use Amazon S3 for storage + BelugaCDN for distribution.  

Link to comment
Share on other sites

  • 2 weeks later...
45 minutes ago, NoGi said:

Anyone? How are you keeping the test bucket in sync with the live sites bucket?

I'm not entirely sure what you mean - if you're creating a test site using data from your live site, you would simply copy the files from one bucket to another manually.

Link to comment
Share on other sites

5 minutes ago, Ryan Ashbrook said:

I'm not entirely sure what you mean - if you're creating a test site using data from your live site, you would simply copy the files from one bucket to another manually.

Ok that's what I was chasing. So you manually do a bucket copy from live to test. I am assuming that this is a S3 function? Sorry to ask an obvious question, I just haven't used S3 in this way before that's all so all pretty new to me.

Link to comment
Share on other sites

5 minutes ago, NoGi said:

Ok that's what I was chasing. So you manually do a bucket copy from live to test. I am assuming that this is a S3 function? Sorry to ask an obvious question, I just haven't used S3 in this way before that's all so all pretty new to me.

Yes, you would do that all on S3 itself.

Link to comment
Share on other sites

2 hours ago, Wonko12 said:

I have S3 + cloudfront set up but the files are still on my server and on the bucket in S3 is this correct? I thought the files on my server would have been deleted.

I had the exact same issue with mine and just came out of a world of pain. Before you try and fix anything, make sure you have a backup of the files and the forum db. Mine started exactly like this and then ended up deleting all my images on S3 and local when I changed it back from S3 and did something else which then killed the 4.2.2 upgrade and made a mess of my site. Thankfully support have fixed it all up now.

Link to comment
Share on other sites

10 hours ago, Wonko12 said:

I have S3 + cloudfront set up but the files are still on my server and on the bucket in S3 is this correct? I thought the files on my server would have been deleted.

They should be deleted if the filestorage move is successful.  

 

Link to comment
Share on other sites

On 8/9/2017 at 5:40 PM, David.. said:

I'm debating whether I should get Cloudfront and whether it's worth the money?

If you have an abundance of international visitors to your site, its well worth it. That's normally what CDNs are for. 

 

On 8/12/2017 at 1:11 PM, bassangler said:

How do I set  up S3 to use a different CDN other than cloudfront? 

This will depend on the CDN provider you're using. Check to see if they documentation for it. But since most CDNs are pull type, should be fairly simple. 

 I also use BelugaCDN and i simply have the cname point to the bucket on S3 according to their documentation. 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...