-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(apigateway): Add LambdaIntegrationOptions to LambdaRestApi (#17065)
This adds an `integrationOptions` field to the `LambdaRestApiProps` and ensures that `proxy` cannot be set differently from the base `proxy` flag (but discourages setting it at all). This will allow setting the `cacheKeyParameters`, `allowTestInvoke`, and `vpcLink` configuration fields without having to fall back to using a regular `RestApi`. Some of this is inspired by #12004 and its review comments, which was closed earlier this year due to inactivity. Resolves: #3269 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Showing
16 changed files
with
2,538 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
35 changes: 35 additions & 0 deletions
35
packages/@aws-cdk/aws-apigateway/test/integ.lambda-api-nonproxy.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,35 @@ | ||
import { Code, Function, Runtime } from '@aws-cdk/aws-lambda'; | ||
import { App, Stack } from '@aws-cdk/core'; | ||
import { Construct } from 'constructs'; | ||
import { LambdaRestApi, PassthroughBehavior } from '../lib'; | ||
|
||
class LambdaApiIntegrationOptionsNonProxyIntegrationStack extends Stack { | ||
constructor(scope: Construct) { | ||
super(scope, 'LambdaApiIntegrationOptionsNonProxyIntegrationStack'); | ||
|
||
const fn = new Function(this, 'myfn', { | ||
code: Code.fromInline('foo'), | ||
runtime: Runtime.NODEJS_14_X, | ||
handler: 'index.handler', | ||
}); | ||
|
||
new LambdaRestApi(this, 'lambdarestapi', { | ||
handler: fn, | ||
integrationOptions: { | ||
proxy: false, | ||
passthroughBehavior: PassthroughBehavior.WHEN_NO_MATCH, | ||
integrationResponses: [ | ||
{ | ||
statusCode: '200', | ||
responseTemplates: { | ||
'application/json': JSON.stringify({ message: 'Hello, word' }), | ||
}, | ||
}, | ||
], | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
const app = new App(); | ||
new LambdaApiIntegrationOptionsNonProxyIntegrationStack(app); |
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,26 @@ | ||
import { Code, Function, Runtime } from '@aws-cdk/aws-lambda'; | ||
import { App, Duration, Stack } from '@aws-cdk/core'; | ||
import { Construct } from 'constructs'; | ||
import { LambdaRestApi } from '../lib'; | ||
|
||
class LambdaApiIntegrationOptionsStack extends Stack { | ||
constructor(scope: Construct) { | ||
super(scope, 'LambdaApiIntegrationOptionsStack'); | ||
|
||
const fn = new Function(this, 'myfn', { | ||
code: Code.fromInline('foo'), | ||
runtime: Runtime.NODEJS_14_X, | ||
handler: 'index.handler', | ||
}); | ||
|
||
new LambdaRestApi(this, 'lambdarestapi', { | ||
handler: fn, | ||
integrationOptions: { | ||
timeout: Duration.seconds(1), | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
const app = new App(); | ||
new LambdaApiIntegrationOptionsStack(app); |
Oops, something went wrong.