Skip to content

Conversation

@cogwirrel
Copy link
Member

Issue # (if applicable)

Fixes #9327
Fixes #19535

Reason for this change

The maximum Lambda permission policy size can be exceeded for APIs which reuse the same Lambda function for multiple operations, as the integration adds a new permission for each operation, scoped down to the specific operation.

Description of changes

This change updates both the REST and HTTP API lambda integrations with options to scope the permission to any operation on the API, adding a single statement and avoiding overflowing the maximum policy size.

Raised this as a new PR to replace #35705 so we have a clearer history in case we ever wanted to consider the more automatic implementation which collapses permissions.

Describe any new or updated permissions being added

Permission for API Gateway to invoke the lambda is scoped to any resource/method/stage when scopePermissionToMethod (for REST) or scopePermissionToRoute (for HTTP) is set to false.

Description of how you validated changes

Unit tests, Integ tests

Added an integration test for both REST and HTTP (integ.lambda-permission-consolidation).

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@aws-cdk-automation aws-cdk-automation requested a review from a team November 12, 2025 02:36
@github-actions github-actions bot added beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/medium Medium work item – several days of effort p1 labels Nov 12, 2025
@Abogical Abogical self-assigned this Nov 12, 2025
});

this.handler = handler;
this.enableTest = options.allowTestInvoke ?? true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allowTestInvoke will be ignored if scopePermissionToMethod is set. This makes sense, but can we leave a warning to the user that the property if allowTestInvoke is set to false as the option will be ignored in that situation?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good shout! Added a warning to the documentation as well as annotating with a warning if both are set to false.

The following code configures a `$connect` route with a AWS integration that integrates with a dynamodb table. On websocket api connect,
it will write new entry to the dynamodb table.
it will write new entry to the dynamodb table.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes in spaces are not needed.

@cogwirrel cogwirrel force-pushed the feat/apigw-lambda-permission-scope branch from 92cc608 to f15b1a3 Compare November 12, 2025 23:55
@mergify mergify bot dismissed Abogical’s stale review November 12, 2025 23:55

Pull request has been modified.

… rest and http lambda integrations

The maximum Lambda permission policy size can be exceeded for APIs which reuse
the same Lambda function for multiple operations, as the integration adds a new
permission for each operation, scoped down to the specific operation.

This change updates both the REST and HTTP API lambda integrations with options
to scope the permission to any operation on the API, adding a single statement
and avoiding overflowing the maximum policy size.

Fixes aws#9327
Fixes aws#19535
@cogwirrel cogwirrel force-pushed the feat/apigw-lambda-permission-scope branch from f15b1a3 to 95cf138 Compare November 13, 2025 00:25
Copy link
Member

@Abogical Abogical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@mergify
Copy link
Contributor

mergify bot commented Nov 13, 2025

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).

@mergify
Copy link
Contributor

mergify bot commented Nov 13, 2025

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).

@mergify mergify bot merged commit 35f8e46 into aws:main Nov 13, 2025
19 of 20 checks passed
@github-actions
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK bug This issue is a bug. effort/medium Medium work item – several days of effort p1

Projects

None yet

2 participants