Missing nuGet packages after deploying Web Serverless with CDK in C#
See original GitHub issueI created a single web serverless application using the default template for the AWS toolkit. I created a CDK project to deploy it with a simple lambda function and the LambdaRestApi.
When deploying with cdk everything goes fine, the asset file is created and the stack deploys without any problem.
When I try to browse the url returned in output, I get {“message”: “Internal server error”}. Checking the logs at CloudWatch the error is totally unexpected:
`
Error:
An assembly specified in the application dependencies manifest (CdkMissingLib.deps.json) was not found:
package: 'Amazon.Lambda.APIGatewayEvents', version: '1.2.0'
path: 'lib/netstandard2.0/Amazon.Lambda.APIGatewayEvents.dll'
START RequestId: 938d4091-a8d2-4e5c-a4eb-3ffbb69b090a Version: $LATEST
Failed to execute the Lambda function. The dotnet CLI failed to start with the provided deployment package. Please check CloudWatch logs for this Lambda function to get detailed information about this failure.: LambdaException
END RequestId: 938d4091-a8d2-4e5c-a4eb-3ffbb69b090a
REPORT RequestId: 938d4091-a8d2-4e5c-a4eb-3ffbb69b090a Duration: 457.96 ms Billed Duration: 500 ms Memory Size: 128 MB Max Memory Used: 64 MB Init Duration: 239.59 ms
`
The package it’s complaining is not even used in my solution. Furthermore, the solution where I found this problem was complaining about another nuget package “AWSSDK.Core” that WAS referenced in the solution…
Reproduction Steps
- Use the solution I provide at github https://github.com/LechuckThePirate/CdkMissingLibExample
This is how I define the stack for CDK:
public class CdkMissingLibInfraStack : Stack
{
public CdkMissingLibInfraStack(Construct parent, string id, IStackProps props) : base(parent, id, props)
{
var lambdaFunction = new Function(this, "webapi-function",
new FunctionProps
{
Code = Code.FromAsset(@"C:\Users\joanv\Source\Repos\CdkMissingLib\CdkMissingLib\bin\Debug\netcoreapp2.1"),
Handler = "CdkMissingLib::CdkMissingLib.LambdaEntryPoint::FunctionHandlerAsync",
Runtime = Runtime.DOTNET_CORE_2_1,
Timeout = Duration.Seconds(30),
MemorySize = 128
}
);
var api = new LambdaRestApi(this, "webapi-function-api", new LambdaRestApiProps
{
Handler = lambdaFunction
});
}
}
Error Log
Error: An assembly specified in the application dependencies manifest (CdkMissingLib.deps.json) was not found: package: ‘Amazon.Lambda.APIGatewayEvents’, version: ‘1.2.0’ path: ‘lib/netstandard2.0/Amazon.Lambda.APIGatewayEvents.dll’ START RequestId: 938d4091-a8d2-4e5c-a4eb-3ffbb69b090a Version: $LATEST Failed to execute the Lambda function. The dotnet CLI failed to start with the provided deployment package. Please check CloudWatch logs for this Lambda function to get detailed information about this failure.: LambdaException
END RequestId: 938d4091-a8d2-4e5c-a4eb-3ffbb69b090a REPORT RequestId: 938d4091-a8d2-4e5c-a4eb-3ffbb69b090a Duration: 457.96 ms Billed Duration: 500 ms Memory Size: 128 MB Max Memory Used: 64 MB Init Duration: 239.59 ms
Environment
- CLI Version : 11.12.0 (build 923055e)
- Framework Version: 2.1
- OS : Windows
- Language : C# .Net Core
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9 (5 by maintainers)
Top GitHub Comments
Also please be aware you will need to build your .NET project before running the CDK deploy on it. CDK will not build for you.
Fixed guys… thanks for your help… here’s the final “deploy.ps1” script I created … it works like a charm:
In my CDK project I just changed the Code.FromAsset to point to the packaged ZIP:
This did the trick… the website is now working.
Going to apply this to the real project now… Thanks again for your help