Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Route 53 point different paths to different s3 buckets

Is it possible to use Route 53 to point a path url like mydomain.com/app to a different s3 bucket than the one accessed by the rest of mydomain.com?

So for example:

mydomain.com/* would point to normal-bucket

mydomain.com/app would point to app-bucket

Is it necessary instead to just use a subdomain like app.mydomain.com?

Would a routing rule make this possible?

like image 229
blaineh Avatar asked Dec 19 '22 09:12

blaineh


2 Answers

You can create an Amazon CloudFront distribution, then defining an origin for each of your Amazon S3 buckets. You can then define which path should use which origin.

See the (confusing) documentation page: Values that You Specify When You Create or Update a Web Distribution

like image 145
John Rotenstein Avatar answered Feb 04 '23 17:02

John Rotenstein


This is possible, but not with route53 or DNS generally.

If you are using S3 static website hosting, you can use a redirect rule instead, to do HTTP redirects. See Amazon documentation for more information about that feature: https://docs.aws.amazon.com/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html

Here is an example of a routing rule that redirects to my-other-bucket on S3, where both the bucket with the rule and my-other-bucket are using static website hosting.

<RoutingRules>
    <RoutingRule>
        <Condition>
            <KeyPrefixEquals>app</KeyPrefixEquals>
        </Condition>
        <Redirect>
            <HostName>my-other-bucket.s3-website-us-west-2.amazonaws.com</HostName>
        </Redirect>
    </RoutingRule>
</RoutingRules>
like image 32
jwang Avatar answered Feb 04 '23 19:02

jwang