Skip to content

Commit

Permalink
chore(cloudfront): update README.md with examples on how to use pre-e…
Browse files Browse the repository at this point in the history
…xisting lambda@edge functions with cloudfront (aws#9940)


Relates to aws#9901

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
robertd authored Sep 2, 2020
1 parent 9ea8d5c commit 5c9e6f6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/@aws-cdk/aws-cloudfront/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,24 @@ myDistribution.addBehavior('images/*', myOrigin, {
});
```

Adding an existing Lambda@Edge function created in a different stack to a CloudFront distribution.

```ts
const functionVersion = lambda.Version.fromVersionArn(this, 'Version', 'arn:aws:lambda:us-east-1:123456789012:function:functionName:1');

new cloudfront.Distribution(this, 'distro', {
defaultBehavior: {
origin: new origins.S3Origin(s3Bucket),
edgeLambdas: [
{
functionVersion,
eventType: cloudfront.LambdaEdgeEventType.VIEWER_REQUEST
},
],
},
});
```

### Logging

You can configure CloudFront to create log files that contain detailed information about every user request that CloudFront receives.
Expand Down

0 comments on commit 5c9e6f6

Please sign in to comment.