j a m i e

Creating an s3 image bucket and automating it.

One thing I’ve always wanted to do was create my own image host where I can dump screenshots and random junk. Tools like Sharex (windows) and Monosnap (mac) are great and have the functionality built in to both take the screenshot and upload it wherever you want. Sharex especially comes with a boatload of other features and it’s (In my opinion) one of the best tools currently available for windows.

Getting started

So, to get started go and grab a domain name or choose a subdomain you want to use for this. I recommend pairing this with Cloudflare as you’ll need to use CNAME flattening if you’re using a full domain.

So we’re going to be using Amazon S3 for this, it’s super easy to setup and we’ll have everything sorted within 30 minutes easy. We’ll also be using the EU-West region because Ireland is an option, hell yeah.

Creating your S3 bucket

So go ahead and get logged into amazon or create an account if you haven’t already. Once you’re in, click on services and select s3. You’ll want to name your bucket the same as your domain, so www.domain.com or domain.com, depending on your preference, then choose your preferred bucket location. You don’t need to change any options and can click next, next to finish up.

Creating the necessary S3 permissions

With that created, you now need to create an additional user so again, browse to services and select ‘IAM’, then click ‘Users’ and ‘Add new user’. Tick ‘Programmatic access’ and *not* console access. Click next and then, ‘Attach existing policies directly’, then search for ‘s3’ and tick the permission ‘AmazonS3FullAccess’. Next, create user.

Next you want to do is generate access keys to attach to Sharex/Monosnap to allow them to upload images. Services, IAM and click on the User you created then click on ‘security credentials’. In here you can create two access keys, one for each program if you use both windows and mac, or just one if you’re using either.

Linking it to your snap tool

For monosnap, this is super easy.

Just replace the keys, set your region, select your bucket and your path. I suggest putting it in a subfolder just to keep it tidy. The base URL ensures your domain name is used and not the long amazon s3 URL. If you’re using a subfolder, you should create it within the bucket in the amazon console also.

Sharex is pretty similar;

Both programs also support randomizing the imagename which is pretty cool too.
Sharex is in Hotkey Settings > Action > File Naming
Monosnap is in Preferences > Advanced

Enabling static website hosting at S3

To clean up some loose ends, click into the bucket again and click ‘properties’ then enable ‘Static website hosting’.

Whip together a quick index.html and error.html and drop them both inside the bucket, ensure both are public and readable.

DNS

Next, go back to Cloudflare and lets CNAME the domain. Create a CNAME for www and point it to

bucketname.s3-website-eu-west-1.amazonaws.com

Note: If you’re using buckets from a different region this URL can be different so check this page again to get an idea what you’ll need.

Do the same for domain.com, then hop into the ‘Crypto’ tab on Cloudflare and set it to Flexible. Lastly, hop into Page Rules and make a new page rule. For domain enter http://*yourdomain.com* and choose the ‘always use HTTPS’ rule, then save and deploy.

Then test out with uploading a screenshot, enjoy!