I'm attempting to use an S3 bucket to host media files (images, video and static files) for a small web application and came across a strange catch-22...
According to the S3 documentation, to serve a static website (it's not a static website, just static files), the bucket name must be the same as the domain/subdomain that the files are being served from, so that Route53 lists it as an ALIAS option under S3 buckets. I did this, named the bucket media.domain.com
and added the record to Route53 as an A record for media.domain.com
.
However, when using S3FS to mount this S3 bucket to the file system of my EC2 instance, the mount failed because of the dots in the bucket name: https://github.com/s3fs-fuse/s3fs-fuse/issues/602
I need to mount this bucket to the EC2 instance because we need to accept file uploads via a NodeJS microservice and set the storage destination to a location the S3 bucket with full read/write permissions, hence the need to mount the S3 bucket so the microservice on the EC2 instance can write to the S3 bucket.
The catch-22: To serve these static files from S3 using Route53, the name must be the same as the A record. To mount a bucket, there cannot be dots in the filename - A records have dots...
My question is if someone has a solution, or can see the big picture and tell me if I'm going about this in the entirely wrong manner. I'm fairly new to AWS.
We're using S3 and not CloudFlare because of cost, we need the less expensive solution for now.
Thanks!