S3 and Cloudfront - Setup Not Working

Hello all!

I followed this guide to setup s3.

The only option I couldn’t find is " make sure the “Programmatic access ” checkbox is checked"

I couldn’t find any option like that.

But S3 is not working.

Notes: CDN is via CloudFront (s3 is the source of CloudFront)

Thanks

The rake task you’re running insists the specified values are in environment variables, it will not use the ones in the site settings.

2 Likes

Thanks for the response.

I used rake, thinking that image urls would be replaced with CDN link.

But the S3 setting itself is not working.

Did I miss anything in the S3 configuration?

Yes, you need to set the environment variables to run the rake task to migrate to S3.

I’m not getting. Hope you reviewed my discourse settings.

Any extra steps needed apart from this guide? Set up file and image uploads to S3

I believe you can get an overview of what environment variables you need here:
Configure an S3 compatible object storage provider for uploads

EDIT: In the context of a rake command, see the answer below :point_down:

or from the error:

They must be set in the environment, not in site settings.

You can provide them at the time the rake task is run by doing e.g.:

DISCOURSE_S3_BUCKET=foo DISCOURSE_S3_REGION=us-east-1 DISCOURSE_S3_USE_IAM_PROFILE=true rake uploads:migrate_to_s3

oh okay!

So, I’ll add this to app.yml

Example:

DISCOURSE_USE_S3: true
  DISCOURSE_S3_REGION: us-west-1
  DISCOURSE_S3_ACCESS_KEY_ID: myaccesskey
  DISCOURSE_S3_SECRET_ACCESS_KEY: mysecretkey
  DISCOURSE_S3_CDN_URL: https://falcoland-files-cdn.falco.dev
  DISCOURSE_S3_BUCKET: falcoland-files
  DISCOURSE_S3_BACKUP_BUCKET: falcoland-files/backups
  DISCOURSE_BACKUP_LOCATION: s3

Please read Michael’s answer instead!

Since my installation is fresh!

My only concern is new images. Rake, I did because the article suggested.

I thought just adding S3 settings via discource admin was enough to serve new images from S3!

See Configure an S3 compatible object storage provider for uploads

2 Likes

Yeah, since my setup is S3 and Cloudfront, I added the S3 code as following.

Now rebuilding. I hope S3 will work!

Didn’t work! I think something is missing related to S3 permissions!

Any suggestions?

There’s 3 parts here:

  • can Discourse read/write/etc. on the bucket?
  • can anonymous users read from the bucket?
  • can the CDN read from the bucket?

Looks like it’s the second part not working?

3 Likes

Please review my setup and kindly let me know if I missed anything: S3 and CloudFront CDN

Based on this Guide

Created two buckets:

One for CDN (Enabled ACL also)
One for Backups
Created policy by adding two buckets, attached with IAM user, and generated the access keys.

Created two CloudFront distributions:

  1. cdn.mysite.com (origin is the cdn bucket) by configuring CNAME.

  2. assets.mysite.com (origin is mysite.com) (Community is on the main domain, not sub-domain) by configuring CNAME.

Based on this guide:

Added the AWS S3 code, and configuration to app.yml as follows:

Thank You.

Thanks a lot to @pfaffman

Who gave me a clue about using www in the host address. My forum was using a non-www version!

I changed to www version, and rebuilt it!

Everything now works fine including cdn and assets!

Thank You.

1 Like

I can’t quite see how that fixed it, but glad you got it sorted!

2 Likes

As I explained here, after I did this, the site was offline. So, I was unable to see the outcome of that. But when I tried the same setup on a test sub-domain, all was working fine. Therefore, I suspect there is something wrong with the SSL.

Based on your clue of www, I changed the host address, and the issue was fixed immediately.

I also suspect that the site may have gone offline because of Cloudflare’s recent service outage.

Anyway, it got fixed.

Thank you!

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.