如 文档 所述,我为Viewer Response
的CloudFront触发器设置了Lambda@edge。
Lambda函数代码:
'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);
};
我已经适当设置了Viewer Response
事件的触发器。
现在,当我通过CloudFront提交请求时,它应该被记录在CloudWatch中,但实际上并没有。
如果我使用按钮进行简单的测试Lambda函数
,则可以正确记录。
这里可能出了什么问题?
response.headers['x-lambda-region'] = [{ key: 'X-Lambda-Region', value: process.env.AWS_REGION }];
,如果你的触发器成功运行,你会看到一个X-Lambda-Region
标头已经添加到响应中,告诉你参与处理请求的区域。你有什么想法? - Michael - sqlbot