An AWS S3 Integration with Discourse Tutorial would be nice

After banging my head into a wall for 3 hours trying to make my AWS S3 configuration work with Discourse on AWS Lightsail instance I am of the strong belief that a simple straightforward tutorial on this would be nice. There are ALL sorts of rabbit holes to go down with this. I mean I have no problems making a bucket that can remotely pull files using the AWS S3 URL provided, but once you bring in the CDN, the S3 Endpoint (which the settings UX clearly states can be blank but on trying to upload gives the internal message of “Endpoint can’t be blank”), and just basic things like what permissions level do you ACTUALLY need if using a CDN via Amazon’s CloudFront.

It’s just a lot. I have scoured the internet and nothing even close exists and certainly nothing I could find that was current with Discourse today.

Thanks for any pointers.

I think my main stumbling block atm is the permissions at least from the standpoint of Discourse asking for Key ID and Key Secret. I have a user in IAM for this but there is NOTHING in the S3 Buckets info that seems to associate this user to that bucket so I have not a clue if this is the disconnect. Honestly I have used LightSail and AWS for 8+ years now but this S3 area is written in a sort of Dev UX style obfuscation with 50 different ways to do things. Not intuitive in the least.

Did you look at Configure an S3 compatible object storage provider for uploads?

לייק 1

(post deleted by author)

Hi Jay. Yes I have looked at that one many times now. Being that it’s from 2020 it has things like DISCOURSE_S3_REGION settings, but the admin area has no such setting.

Also.. wouldn’t I rake my old data AFTER setting up the S3 properly and verifying it works?

This is the kind of stuff I am talking about though. The settings in Discourse make a whole lot of assumptions on a user knowing AWS, shell, and Discourse like a dev would.

Here is where I am at currently.

I have a CDN working and manually uploaded a file which works:

https://s3.kitmaker.net/IMG_7184.JPG

When I upload via Discourse I get:

Failed to open TCP connection to discourse-kitmaker.s3.kitmaker.net:443 (getaddrinfo: Name or service not known)

Here are my current settings:

Oh and hey there is that Region setting I was ignoring. Yeah but that didn’t help once set properly. :smiley:

But you show that you’re not following those instructions.

That’s why you need to follow those instructions and not do it in the ux.

Those are the instructions to follow.

And don’t miss the bit that you add to the yml to have the assets uploaded to s3.

I would do it on a test site so you don’t screw up your live one.

Yes. Add the s3 settings to env in the yml, rebuild, then test that they work, then run the rake task. They have to be set there, not in the database. I’m not sure why they haven’t hidden them from the UX.

But there is also this: How are you authenticating Discourse to AWS? Help us improve the settings!

לייק 1

Thanks for those links. The first link you posted has another link in the AWS area ( Set up file and image uploads to S3 ) from 2013 so I am running up immediately against them saying to put in X bucket policy (which seems outdated) when the AWS CDN via Cloudfront has already replaced the policy with it’s own. Change it? Leave it? This is the crap I mean. Ugggg!

לייק 1

It’s not really the “Fill in the blank” settings in app.yml or the admin settings that are the issue. It’s more a combination of how those settings are interacting with the bucket created or the CDN, etc. So it’s the Amazon side of things that needs some enlightening. I mean I get it, that’s not Discourse, but it sure would be helpful to DISCOURSE users getting actually functionally working via S3. I hope that makes sense.

I see. I haven’t set up an aws bucket in a while. That part can be more complicated, but it’s not what you posted how you did.

But that too is pretty straight forward, you paste the stuff in and then if you have errors you can address them.

That’s the only issue you have described.

How did you set up the bucket? What permissions for you give the user? Did you generate the keys? What errors did you get (but I thought you said that you added an image to a post and it worked?

לייק 1