I am trying to redirect few domains to one with AWS Lambda
The logic is following:
- Hosted zone for domain example.eu with A record being Alias to an LB
- LB forwarding traffic to a Target Group and has a valid certificate
- Target is a Lambda function:
exports.handler = async (event) => {
const response = {
statusCode: 301,
headers: {
Location: 'https://example.com'
}
};
return response;
};
- When I click on test and pass something to Lambda - it works and returning 301 but it is never getting triggered when I open example.eu in browser or using curl.
Expected result:
When I open example.eu it returns me 301 Moved Permanently https://example.com