You can add a header with x-frame parameters in response from CloudFront / S3 using the Lambda @Edge function . Lambda code works in local places of edges, but it needs to be created and maintained in the area us-east-1
.
The sample code here uses nodeJS 6.10 to add a response header
'use strict';
exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
response.headers['x-frame-options'] = [{"key":"X-Frame-Options","value":"SAMEORIGIN"}];
console.log(response.headers);
callback(null, response);
};
Lambda, Lambda Version CloudFront origin-response
.
CloudWatch . , IAM , CloudWatch edgelambda.amazonaws.com
lambda.amazonaws.com
.
Lambda, CloudWatch:
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*",
"Effect": "Allow"
}
]
}
, Lambda Lambda @Edge :
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": [
"edgelambda.amazonaws.com",
"lambda.amazonaws.com"
]
},
"Action": "sts:AssumeRole"
}
]
}
, AWS x-frame-options , .