-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(lambda-python): incorrect handler name when the handler is in a subdirectory #15981
fix(lambda-python): incorrect handler name when the handler is in a subdirectory #15981
Conversation
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
Thanks for submitting this PR. I just have one main comment.
I can't find any docs on how the handler name should be specified when it is in the inner directory - https://docs.aws.amazon.com/lambda/latest/dg/python-handler.html
Can you supply how you tested and confirmed that this is the correct solution, or point me to some docs?
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.
Setting the status to 'request changes' to address the comment above.
@nija-at His explanation aligns with my understanding. The problem is that the Lambda function handler is imported with slashes, when dot notation is what is needed for Python imports. |
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.
Hi @vincent-turato -
Looks good generally. Just one comment.
@@ -113,7 +113,7 @@ export class PythonFunction extends lambda.Function { | |||
assetHashType: props.assetHashType, | |||
assetHash: props.assetHash, | |||
}), | |||
handler: `${index.slice(0, -3)}.${handler}`, | |||
handler: `${index.replace(/\.py$/i, '').replace('/', '.')}.${handler}`, |
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.
Can you add a little comment with a small example explaining this string replace?
924c117
to
ebfd5f2
Compare
Closing this PR since there has been no traction in a while. |
If a handler function is located in a subdirectory of the lambda code package, the aws_lambda.Function handler property would be set to an incorrect value.
Copied from: #15391
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license