Reputation: 23
I have a Route53 subdomain (test.site.co.uk) and I want to be able to point it at a main S3 bucket (testing.uat.co.uk). I will also have more subdomains soon needing to do the same thing.
I cannot set the Alias Target to the S3 bucket because it is a different name which it needs to be. I am changing the content displayed on the bucket's site to respond to the targetted URL. For this reason, I need to keep the URL because I have also tried to redirect a bucket of the same name to the domain of the main bucket but that changes the URL.
Is there any way around this where I can keep the targeted domain?
Upvotes: 2
Views: 149
Reputation: 1952
The ideal approach to do is using Amazon CloudFront with Lambda@Edge. In CloudFront, you can set multiple Alternate Domain Names (CNAMEs) and with Lambda@Edge you can process the request to display different content:
import json
def lambda_handler(event, context):
request = event['Records'][0]['cf']['request']
headers = request['headers']
if request['domainName'] == 'example1.com':
# Do this 1
elif request['domainName'] == 'example2.com':
# Do this 2
else:
# Do this else
Upvotes: 3