-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(apigateway): Add LambdaIntegrationOptions to LambdaRestApi #17065
feat(apigateway): Add LambdaIntegrationOptions to LambdaRestApi #17065
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just one minor question.
@@ -1,6 +1,6 @@ | |||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we add the Duration
import here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a newline to the end of this file.
proxy: false, | ||
integrationOptions: {}, | ||
})).not.toThrow(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should explain the interaction between integrationOptions.proxy
and props.proxy
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably no longer necessary
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)) { | ||
throw new Error('Cannot specify "props.integrationOptions.proxy". Instead use "props.proxy".'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We reference props.integrationOptions
several times. Could we extract this to a local variable, integrationOptions
?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
integrationOptions
field to theLambdaRestApiProps
and ensures thatproxy
cannot be set differently from the baseproxy
flag (but discourages setting it at all). This will allow setting thecacheKeyParameters
,allowTestInvoke
, andvpcLink
configuration 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