I have a .NET 8 Lambda function that is deployed to AWS via CDK. The problem is that it gets saved to the bucket as a .zip archive, yet my function is expecting to see the (unzipped) binaries. As a result, I encounter Error: executable assembly /var/task/My.Lambda.Function.dll or binary /var/task/My.Lambda.Function not found
when I execute the function via the gateway invoke URL.
What do I need to change to either get the binaries to unzip when deployed? (Or, alternatively, allow AWS’s Lambda engine to process the zip file directly)?
const functionProps: lambda.FunctionProps = {
functionName: 'mylambda',
runtime: lambda.Runtime.DOTNET_8,
code: lambda.Code.fromAsset('../Infrastructure/build'),
handler: 'My.Lambda.Function', //Namespace of my .NET assembly
timeout: cdk.Duration.seconds(300)
};
const codeBucket = new s3.Bucket(this, 'S3Bucket', {
removalPolicy: cdk.RemovalPolicy.DESTROY
});
new s3deploy.BucketDeployment(this, 'DeployLocation', {
sources: [s3deploy.Source.asset('../Infrastructure/build')],
destinationBucket: codeBucket,
destinationKeyPrefix: 'var/task',
extract: true
});
var lambdaFunc = new lambda.Function(this, "mylambda", functionProps);
const api = new apigateway.LambdaRestApi(this, 'mylambda-api', {
'handler': lambdaFunc,
'proxy': true
});