Function
Provides a CloudFront Function
Sample Code
exports.createResources = () => [
{
type: "Function",
group: "CloudFront",
properties: ({}) => ({
ContentType: "application/octet-stream",
FunctionCode:
"//A version of the homepage\nvar X_Experiment_A = 'index.html';\n//B version of the homepage\nvar X_Experiment_B = 'index_b.html';\n\nfunction handler(event) {\n var request = event.request;\n if (Math.random() < 0.8) {\n request.uri = '/' + X_Experiment_A;\n } else {\n request.uri = '/' + X_Experiment_B;\n }\n //log which version is displayed\n console.log('X_Experiment_V ' + (request.uri == '/index.html' ? 'A_VERSION' : 'B_VERSION'));\n return request;\n}",
Name: "us-east-1CloudfronS3CdkPythonStackFunction980062BC",
FunctionConfig: {
Runtime: "cloudfront-js-1.0",
},
FunctionMetadata: {
Stage: "DEVELOPMENT",
},
}),
},
];
Examples
Properties
Used By
List
gc list -t CloudFront::Function