aws-cdk-lib.aws_cloudfront.FunctionProps

interface FunctionProps

LanguageType name
.NETAmazon.CDK.AWS.CloudFront.FunctionProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awscloudfront#FunctionProps
Javasoftware.amazon.awscdk.services.cloudfront.FunctionProps
Pythonaws_cdk.aws_cloudfront.FunctionProps
TypeScript (source)aws-cdk-lib » aws_cloudfront » FunctionProps

Properties for creating a CloudFront Function.

Example

// Add a cloudfront Function to a Distribution
const cfFunction = new cloudfront.Function(this, 'Function', {
  code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'),
});

declare const s3Bucket: s3.Bucket;
new cloudfront.Distribution(this, 'distro', {
  defaultBehavior: {
    origin: new origins.S3Origin(s3Bucket),
    functionAssociations: [{
      function: cfFunction,
      eventType: cloudfront.FunctionEventType.VIEWER_REQUEST,
    }],
  },
});

Properties

NameTypeDescription
codeFunctionCodeThe source code of the function.
comment?stringA comment to describe the function.
functionName?stringA name to identify the function.

code

Type: FunctionCode

The source code of the function.


comment?

Type: string (optional, default: same as functionName)

A comment to describe the function.


functionName?

Type: string (optional, default: generated from the id)

A name to identify the function.