forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f54b1c
commit 8673979
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...k-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-function-runtime.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { IntegTest } from '@aws-cdk/integ-tests-alpha'; | ||
import { TestOrigin } from './test-origin'; | ||
import * as cloudfront from 'aws-cdk-lib/aws-cloudfront'; | ||
|
||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, 'integ-distribution-function', { env: { region: 'eu-west-1' } }); | ||
|
||
const cfFunctionRequest = new cloudfront.Function(stack, 'FunctionRequest', { | ||
code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'), | ||
}); | ||
|
||
const cfFunctionResponse = new cloudfront.Function(stack, 'FunctionResponse', { | ||
code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.response }'), | ||
}); | ||
|
||
new cloudfront.Distribution(stack, 'Dist', { | ||
defaultBehavior: { | ||
origin: new TestOrigin('www.example.com'), | ||
cachePolicy: cloudfront.CachePolicy.CACHING_DISABLED, | ||
functionAssociations: [{ | ||
function: cfFunctionRequest, | ||
eventType: cloudfront.FunctionEventType.VIEWER_REQUEST, | ||
}, { | ||
function: cfFunctionResponse, | ||
eventType: cloudfront.FunctionEventType.VIEWER_RESPONSE, | ||
}], | ||
}, | ||
}); | ||
|
||
new cdk.CfnOutput(stack, 'RequestFunctionArn', { value: cfFunctionRequest.functionArn }); | ||
new cdk.CfnOutput(stack, 'RequestFunctionStage', { value: cfFunctionRequest.functionStage }); | ||
|
||
new cdk.CfnOutput(stack, 'ResponseFunctionArn', { value: cfFunctionResponse.functionArn }); | ||
new cdk.CfnOutput(stack, 'ResponseFunctionStage', { value: cfFunctionResponse.functionStage }); | ||
|
||
new IntegTest(app, 'CF2Runtime', { | ||
testCases: [stack], | ||
}); | ||
|
||
app.synth(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters