feat(apigateway): Add LambdaIntegrationOptions to LambdaRestApi#17065
feat(apigateway): Add LambdaIntegrationOptions to LambdaRestApi#17065mergify[bot] merged 5 commits intoaws:mainfrom
Conversation
643796e to
87e3a45
Compare
a6e655c to
c7f8a77
Compare
2714a44 to
1ff28a7
Compare
|
Turns out apparently API Gateway doesn't allow the Event Information |
1ff28a7 to
31c3a42
Compare
comcalvi
left a comment
There was a problem hiding this comment.
Looks great! Just one minor question.
| // Fixture with packages imported, but nothing else | ||
| import { Construct } from 'constructs'; | ||
| import { Stack } from '@aws-cdk/core'; | ||
| import { Duration, Stack } from '@aws-cdk/core'; |
There was a problem hiding this comment.
Why did we add the Duration import here?
There was a problem hiding this comment.
It seems to be necessary based on the changes I also made to README.md. I got a build failure without it since jsii-rosetta couldn't find Duration (if I interpreted the error message correctly). I guess it might be possible to choose another possible integration example but that might still require another import.
comcalvi
left a comment
There was a problem hiding this comment.
This is looking pretty good, but there's a few small issues I'd like to see resolved. Please fix the merge conflicts as well, they're preventing our usual automation from running.
| } | ||
|
|
||
| const app = new App(); | ||
| new LambdaApiIntegrationOptionsStack(app); No newline at end of file |
There was a problem hiding this comment.
Please add a newline to the end of this file.
| proxy: false, | ||
| integrationOptions: {}, | ||
| })).not.toThrow(); | ||
|
|
There was a problem hiding this comment.
could we remove this blank line?
| Note that `proxy: false` may not be specified in the `integrationOptions` | ||
| and must be specified directly in `props`. |
There was a problem hiding this comment.
why is this only proxy: false and not proxy?
| * | ||
| * @default - see defaults defined in {@link LambdaIntegrationOptions}. | ||
| */ | ||
| readonly integrationOptions?: LambdaIntegrationOptions; |
There was a problem hiding this comment.
We should explain the interaction between integrationOptions.proxy and props.proxy here.
There was a problem hiding this comment.
This is probably no longer necessary
| } | ||
| // Forbid setting `integrationOptions.proxy = false` unless `proxy = false` | ||
| if (props.integrationOptions?.proxy !== undefined && props.integrationOptions?.proxy !== (props?.proxy ?? true)) { | ||
| throw new Error('Cannot specify "props.integrationOptions.proxy". Instead use "props.proxy".'); |
There was a problem hiding this comment.
could we change this message to reflect the precise behavior of this interaction?
| throw new Error('Cannot specify "defaultIntegration" since Lambda integration is automatically defined'); | ||
| } | ||
| // Forbid setting `integrationOptions.proxy = false` unless `proxy = false` | ||
| if (props.integrationOptions?.proxy !== undefined && props.integrationOptions?.proxy !== (props?.proxy ?? true)) { |
There was a problem hiding this comment.
We reference props.integrationOptions several times. Could we extract this to a local variable, integrationOptions?
| if (props.options?.defaultIntegration || props.defaultIntegration) { | ||
| throw new Error('Cannot specify "defaultIntegration" since Lambda integration is automatically defined'); | ||
| } | ||
| // Forbid setting `integrationOptions.proxy = false` unless `proxy = false` |
There was a problem hiding this comment.
The comment on the line above should be more specific about this behavior, as well as the reasoning behind why this is desirable. Ideally this would be written with positive terms, instead of the currently used negative. I don't understand the desired interaction between integrationOptions.proxy and proxy.
| expect(() => new apigw.LambdaRestApi(stack, 'lambda-rest-api2', { | ||
| handler, | ||
| proxy: false, | ||
| integrationOptions: { | ||
| proxy: false, | ||
| }, | ||
| })).not.toThrow(); |
There was a problem hiding this comment.
How does this work? The readme change has this:
Note that `proxy: false` may not be specified in the `integrationOptions`
and must be specified directly in `props`.
same goes everywhere else with proxy: false in these tests.
| throw new Error('Cannot specify "defaultIntegration" since Lambda integration is automatically defined'); | ||
| } | ||
| // Forbid setting `integrationOptions.proxy = false` unless `proxy = false` | ||
| if (props.integrationOptions?.proxy !== undefined && props.integrationOptions?.proxy !== (props?.proxy ?? true)) { |
There was a problem hiding this comment.
Please simplify this if as well, it's very complicated right now.
I think it should be broken apart like this:
if (props.integrationOptions?.proxy !== undefined) {
if (props.integrationOptions.proxy !== (props?.proxy ?? true)) { ...
// ...
}
}
and I think the props?.proxy ?? true should be extracted into a variable with a name that describes what that part of the expression represents.
31c3a42 to
a561d12
Compare
|
@comcalvi Thanks for the review feedback! As I was working on implementing changes based on the feedback, I realized that the There should be no reason to forbid
I think forbidding anything around |
a561d12 to
a751a41
Compare
a751a41 to
9b07f25
Compare
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…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 aws#12004 and its review comments, which was closed earlier this year due to inactivity. Resolves: aws#3269 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This adds an
integrationOptionsfield to theLambdaRestApiPropsand ensures thatproxycannot be set differently from the baseproxyflag (but discourages setting it at all). This will allow setting thecacheKeyParameters,allowTestInvoke, andvpcLinkconfiguration fields without having to fall back to using a regularRestApi.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