Open garysassano opened 5 months ago
import aws_cdk.aws_signer as signer signing_profile = signer.SigningProfile(self, "SigningProfile", platform=signer.Platform.AWS_LAMBDA_SHA384_ECDSA ) code_signing_config = lambda_.CodeSigningConfig(self, "CodeSigningConfig", signing_profiles=[signing_profile] ) lambda_.Function(self, "Function", code_signing_config=code_signing_config, runtime=lambda_.Runtime.NODEJS_18_X, handler="index.handler", code=lambda_.Code.from_asset(path.join(__dirname, "lambda-handler")) )
The JSII's autogenerated code uses Node.js' __dirname, which isn't valid in Python.
__dirname
Ideally, you should want to use pathlib as best practice:
code=lambda_.Code.from_asset( str(Path(__file__).parent / "lambda-handler") )
Also, the default Lambda function's handler in Python is:
handler="lambda_function.lambda_handler"
https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_lambda/Function.html
I guess this might be a bug from JSII as the sample is auto generated from the one in TypeScript. Thank you for the report.
jsii-rosetta, rather
Describe the issue
Example
The JSII's autogenerated code uses Node.js'
__dirname
, which isn't valid in Python.Ideally, you should want to use pathlib as best practice:
Also, the default Lambda function's handler in Python is:
Links
https://docs.aws.amazon.com/cdk/api/v2/python/aws_cdk.aws_lambda/Function.html