@@ -5,6 +5,7 @@ import { RoutingLambdaEdge } from '../constructs/RoutingLambdaEdge'
5
5
import { CloudFrontDistribution } from '../constructs/CloudFrontDistribution'
6
6
import { CacheConfig } from '../../types'
7
7
import { CheckExpirationLambdaEdge } from '../constructs/CheckExpirationLambdaEdge'
8
+ import { ViewerResponseLambdaEdge } from '../constructs/ViewerResponseLambdaEdge'
8
9
9
10
export interface NextCloudfrontStackProps extends StackProps {
10
11
nodejs ?: string
@@ -21,6 +22,7 @@ export interface NextCloudfrontStackProps extends StackProps {
21
22
export class NextCloudfrontStack extends Stack {
22
23
public readonly routingLambdaEdge : RoutingLambdaEdge
23
24
public readonly checkExpLambdaEdge : CheckExpirationLambdaEdge
25
+ public readonly viewerResponseLambdaEdge : ViewerResponseLambdaEdge
24
26
public readonly cloudfront : CloudFrontDistribution
25
27
26
28
constructor ( scope : Construct , id : string , props : NextCloudfrontStackProps ) {
@@ -55,6 +57,11 @@ export class NextCloudfrontStack extends Stack {
55
57
region
56
58
} )
57
59
60
+ this . viewerResponseLambdaEdge = new ViewerResponseLambdaEdge ( this , `${ id } -ViewerResponseLambdaEdge` , {
61
+ nodejs,
62
+ buildOutputPath
63
+ } )
64
+
58
65
const staticBucket = s3 . Bucket . fromBucketAttributes ( this , `${ id } -StaticAssetsBucket` , {
59
66
bucketName : staticBucketName ,
60
67
region
@@ -65,6 +72,7 @@ export class NextCloudfrontStack extends Stack {
65
72
renderServerDomain,
66
73
requestEdgeFunction : this . routingLambdaEdge . lambdaEdge ,
67
74
responseEdgeFunction : this . checkExpLambdaEdge . lambdaEdge ,
75
+ viewerResponseEdgeFunction : this . viewerResponseLambdaEdge . lambdaEdge ,
68
76
cacheConfig,
69
77
imageTTL
70
78
} )
0 commit comments