#using subdomain for s3 bucket but domain is hosted with vercel

122 messages · Page 1 of 1 (latest)

thorn dagger
#

How do i for example have example.com with vercel but maybe i want cdn.example.com for s3 bucket with aws? i've been trying but still cant make it work..

odd sundialBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

raven nest
thorn dagger
#

yup but more confuse is, do i set it on vercel like cdn.example.com or aws side?

raven nest
thorn dagger
#

vercel

raven nest
#

create it on vercel

thorn dagger
raven nest
#

what is that?

#

like this

thorn dagger
#

🫠

raven nest
#

you should add it in DNS records

thorn dagger
#

i've added media cdn with bucket value

#

404: NOT_FOUND
Code: DEPLOYMENT_NOT_FOUND
ID: sin1::92c4p-1711068857287-e457b4043b0d

raven nest
#

what is your bucket value?

raven nest
#

of the cname

thorn dagger
raven nest
#

run it on terminal

thorn dagger
#

-removed

raven nest
#

look like it is set

thorn dagger
#

so in my s3 static website hosting, i should point it to to media.xxx.com?

raven nest
thorn dagger
#

do i need to set anything on aws side?

raven nest
#

no

raven nest
thorn dagger
#

err base on what im reading they say i have to on this?

#

if i dont have to turn this on, then how do i get the url?

#

am i not suppose to use that + cloudfront?

thorn dagger
#

from Static website hosting

#

i enabled it just now

#

and it creates a url for me

#

if i enable

raven nest
#

it redirect me to other site

thorn dagger
#

im confused 🤣

so what url do i have to put at vercel cname?

#

bucket url? but how do i get that?

raven nest
#

choose host a static website

thorn dagger
raven nest
#

is your hompage on index.html?

thorn dagger
#

no, i got no page tho

i just wanna run a s3 bucket using a subdomain that is hosted at vercel

raven nest
#

oh then you don't need to enable it

thorn dagger
#

okay so i have hyperfuse.studio as my main site right ~

then i just wanna use media.hyp... as s3 bucket cdn?

thorn dagger
#

so the thing is, what url do i put with media cname then

raven nest
#

this one

thorn dagger
#

okay added

raven nest
#

it should work

thorn dagger
#

let me try

raven nest
thorn dagger
#

hmm how to fix the https thingy ?

raven nest
#

then change the value to the cloudfront address in DNS record on vercel

thorn dagger
#

hmm okay, lemme try

raven nest
#

but it will double the cost
the cost on cloudfront and the cost on vercel for bandwidth

thorn dagger
#

thinq whats the best solution

drifting surge
#

This is how you can use a CNAME in Vercel DNS to point at your CloudFront distro https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-https-alternate-domain-names.html

#

The DNS verification is still pretty easy with Vercel DNS, you just add the verification records it tells you to

thorn dagger
#

@drifting surge in your opinion should i use WAF when creating distribution? thinq

drifting surge
#

@thorn dagger for your case I think maybe the WAF wouldn't have much to do, there is not really a web app or anything to hack on your S3 origin

thorn dagger
#

hmm make sense, then i can turn it off sunglasses_1 cause i saw while i was testing im getting charged $5 + for waf

#

so i've finally able to create ACM, im trying to assign the acm to my cloudfront now

drifting surge
#

yeah, definitely not worth that. It is more for if you have like a wordpress site behind cloudfront and it will try to filter out common/known exploit traffic

#

everything in AWS is really a headache

thorn dagger
#

yes 😦

#

so basically

on vercel side, i just need to create cname pointing to s3 bucket url

then create cdn for that bucket

then im good to go?

drifting surge
#

so yeah, you get the ACM cert for like cdn.yoursite.dev

#

and tell the cloudfront distro to use the ACM cert for requests from your custom domain

#

the main (and non-negligible) risk of using AWS is that there is not way to set a hard upper limit on budget

#

One kind of legit attack is to use a botnet to just like download a bunch of crap from your CDN and run up the bill

thorn dagger
#

im confused again AHHAA

so we have this

drifting surge
#

yeah that is not right

thorn dagger
#

^ on vercel

drifting surge
#

exclusively

#

delete the url for the s3 bucket

#

wait 60 seconds... profit?

thorn dagger
drifting surge
#

delete the cname for media

thorn dagger
#

okay

#

so i add new one, media > cname > cloudfront url?

drifting surge
#

yeah

#

exactly

#

I have an application with a lot of images in S3 and use twicpics as the cdn instead of cloudfront

#

it has a handy url scheme for resizing/compressing images

thorn dagger
#

whats your recommendation tho

#

i just wanna store lolsob

drifting surge
#

its ok, I know how to use cloudfront & s3 for a reason too

thorn dagger
#

it works now!

drifting surge
#

there you go!

thorn dagger
#

i read too many tuts/docs on this with 0 leads

#

🤣

drifting surge
#

AWS can be really frustrating

#

friendly life advice: if you ever consider using S3 object lambdas please seriously consider an image CDN instead ☠️

#
Amazon Web Services

March 15, 2023 – You can now use S3 Object Lambda with Amazon CloudFront to tailor content for end users. When you store data in Amazon Simple Storage Service (Amazon S3), you can easily share it for use by multiple applications. However, each application has its own requirements and may need a different view of […]

thorn dagger
#

you lost me at object lambdas 🤣

drifting surge
#

they are a kind of... the raw materials to process media before serving it, just not convenient

thorn dagger
#

will take note on this!

drifting surge
#

it can be handy to store the size of images in the filename if you don't keep the size anywhere else

#

because your image component can always parse the sizes out and do stuff like have the right aspect ratio

#

without making a fetch

#

The Storyblok CDN encodes the original dimension info the URLs it provides https://a.storyblok.com/f/39898/3310x2192/e4ec08624e/demo-image.jpeg/m/

#

but you can fake it using names (ahem, keys) of files in S3