As explained in the Docs , I set up Lambda@edge for cloudfront trigger of Viewer Response
.
The lambda function code :
'use strict';
exports.handler = (event, context, callback) => {
console.log('----EXECUTED------');
const response = event.Records[0].cf.response;
console.log(event.Records[0].cf_response);
callback(null, response);
};
I have set up trigger appropriately for the Viewer Response
event.
Now when I make a request through cloudfront, it must be logged in cloudwatch, but it doesn't.
If I do a simple Test Lambda Function
(using Button), it is logged properly.
What might be the issue here ?
response.headers['x-lambda-region'] = [ { key: 'X-Lambda-Region', value: process.env.AWS_REGION } ];
to your code (before the callback) and if your trigger is running successfully, you'll see that anX-Lambda-Region
header has been added to the response, telling you which region was involved in processing your request. Your thoughts? – Michael - sqlbot