-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: Linking Authorizers to Lambda functions using the invocation URI #5196
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a286a70
Link authorizer to lambda function invoke URI
lucashuy 1abb682
Merge branch 'develop' of github.com:aws/aws-sam-cli into link_tf_aut…
lucashuy 11677e4
Updated doc string
lucashuy bee4eab
Updated exception messages back
lucashuy 8c3f56c
Merge branch 'develop' into link_tf_authorizers
lucashuy cec2f98
Merge branch 'develop' of github.com:aws/aws-sam-cli into link_tf_aut…
lucashuy 01d3a18
Merge branch 'link_tf_authorizers' of github.com:lucashuy/aws-sam-cli…
lucashuy 5d861db
Added check for one element in reference list
lucashuy 9dd1412
Merge branch 'develop' of github.com:aws/aws-sam-cli into link_tf_aut…
lucashuy fdbbdd4
Updated empty ref list check to not block
lucashuy eff7ad8
Updated log message
lucashuy 1c9541d
Merge branch 'develop' of github.com:aws/aws-sam-cli into link_tf_aut…
lucashuy e1a008e
Fix long line lint error
lucashuy 11d6180
Merge branch 'develop' into link_tf_authorizers
moelasmar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 are checking if
lambda_function_resource_valuesare greater than 1 but we are not checking if there is at least 1 element in it. Should we also check that before accessing it directly?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.
In theory,
lambda_function_resource_valueswill contain something, whether the linking happens with an applied resource, or a non applied resource.With that being said though, I don't think it would add too much we just coded more defensively since both these checks can be done in a helper method, and applied to all the different callbacks.
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.
After some discussion with another team member, a new check will likely happen earlier in the call stack in a different PR to not expand the scope of this PR.
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 not change if statement above with
if len(lambda_function_resource_values) != 1:and also update the exception message?I do understand that we are adding another check in the flow, but that still leaves a possible error in the future since it will be added in another place. If the execution flow changes or if we call this method from somewhere else then we will get an unexpected exception 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.
That's a good point about using the call back methods elsewhere. Was going just log the failed linking attempt (if there aren't any references) and skip linking, but failing early at the hook stage is likely better customer UX rather than waiting until it gets to the
start-apiphase to see an error.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.
I think we should not raise exception if this list is empty. I see if this list is empty, so it means we could not find any destination resources to be linked to the source resource. It may be invalid semantically, but the purpose of the hook is to map between the TF project and the CFN, and these type of validations are left to the core SAM functionalities.
For example, if the customers want to run
sam local invoketo test lambda function, but the TF project is not complete, and the customers do not add all the required API Gateway resources, I do not think we should stop them from using SAM CLI.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.
I am ok for raising some exception here in the callback, but not to call the callback function at all if there is no destinations to be linked.