-
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
(apigatewayv2): IAM Permissions not being created for Api Gateway to access http lambda integration #18201
Comments
I got the same problem on CDK v1.137.0. The following workaround (calling import { HttpApi, HttpMethod } from "@aws-cdk/aws-apigatewayv2";
import { HttpLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations";
const api = new HttpApi(...);
const integration = new HttpLambdaIntegration(...);
api.addRoutes({
path: '/foo',
methods: [HttpMethod.GET],
integration,
});
const [barRoute] = api.addRoutes({
path: '/bar',
methods: [HttpMethod.GET],
integration,
});
integration.bind({ route: barRoute, scope: barRoute }); |
WebSocket API also has the same issue #18208. Another workaround is to create an integration instance per route. Since we are calling aws-cdk/packages/@aws-cdk/aws-apigatewayv2/lib/websocket/integration.ts Lines 112 to 113 in 626e6aa
|
This might be related, but I also have similar behavior after updating from 1.134.0 to 1.139.0. I have 2 routes added to an httpGateway. however only 1 route is added to the lambda trigger (the first one listed). i.e
it no longer adds the {proxy+} which is not the correct behavior but makes sense as to why it's not created the IAM permissions in your case as well since the second route isn't being added. (I only noticed this because I deleted all routes to the lambda and redeployed, the second route is missing in aws console now as shown in the image there should be 2 triggers. |
Same issue here after upgrading to cdk v2 and to "@aws-cdk/aws-apigatewayv2-integrations-alpha" I get "The IAM role configured on the integration or API Gateway doesn't have permissions to call the integration. Check the permissions and try again" for all routes but the first one. If you create a "HttpLambdaIntegration" for each route it works. Is this the expected behaviour? |
@fullstackcreatives it works if you define multiple HttpLambdaIntegrations? i.e
|
…execute permission is created (#18716) When multiple routes are defined for a single lambda integration, only one of the routes gets permission to execute the function. This is because the permissions are added when the integration is bound to the route, which happens only once per integration. Split the `_bindToRoute` workflow into two parts: 1. The actual bind, followed by the creation of an `HttpIntegration`. We keep doing this only once per integration. 2. A post-bind step, that happens for every route. In the case of `HttpLambdaIntegration`, adding the permission has been moved to the post bind step. All other integrations remain the same. Fixes #18201. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
…execute permission is created (aws#18716) When multiple routes are defined for a single lambda integration, only one of the routes gets permission to execute the function. This is because the permissions are added when the integration is bound to the route, which happens only once per integration. Split the `_bindToRoute` workflow into two parts: 1. The actual bind, followed by the creation of an `HttpIntegration`. We keep doing this only once per integration. 2. A post-bind step, that happens for every route. In the case of `HttpLambdaIntegration`, adding the permission has been moved to the post bind step. All other integrations remain the same. Fixes aws#18201. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
What is the problem?
API gateway does not create needed IAM roles to connect to an HTTP Lambda integration, this started when upgrading to CDK v2
Reproduction Steps
When using AWS-CDK 2.3.0-alpha.0
We have 2 routes that point to the same integration, permissions in cloudformation are only created for the first one
cloudformation:
API gateway access logs:
What did you expect to happen?
It to create permissions for both routes
What actually happened?
It only created for the first route - see above cloudformation output
work around is as follows - create a new integration linked to the same function
CDK CLI Version
2.3.0
Framework Version
No response
Node.js Version
14.18.0
OS
Windows 11
Language
Typescript
Language Version
4.5.2
Other information
No response
The text was updated successfully, but these errors were encountered: