Replies: 1 comment
-
Hello, I'm currently encountering the same issue. I am eager to establish a Lambda layer in C# within .NET 6.0, wherein I have incorporated various shared methods for AWS services like S3, SNS, etc. The process entails the inclusion of NuGet packages for S3 and SNS, such as AWSSDK.S3.dll. By executing the CLI command "dotnet lambda publish-layer --layer-type runtime-package-store --s3-bucket bucket-name" I can generate the requisite NuGet packages. This command provides a Layer ARN, which can be used during the deployment of the Lambda function. layer-type runtime-package-store To enable the .NET Core runtime in Lambda to locate the NuGet assemblies from the layer, it is imperative to configure the DOTNET_SHARED_STORE environment variable to point to the paths where the runtime package store layer will be extracted. For more detailed information, please refer to this link. While using AWS CDK, I have yet to come across a method to deploy, create, or download NuGet packages for the Lambda layer in a specified location, akin to the procedure explained using the CLI command.
Sample code for reference as below:
If anyone could kindly provide a reference link or a code example detailing how to achieve these tasks within AWS CDK, it would be greatly appreciated! Thank you, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Kia ora, AWS CDK! 🇳🇿
I am wanting to use the CDK to describe a new Lambda Layer, which can then be used by a number of subsequent Lambdas within our stack. We are a .NET shop, so we instinctively want to do this work with .NET. However, I am finding it difficult to find examples of:
cdk deploy
Do such examples exist?
The closest I can find include:
but they all use the
Amazon.Lambda.Tools
.NET Global Tool to deploy a Lambda Layer direct to an S3 Bucket, and do not use the CDK.I am able to code up a Lambda in C# and then get that Lambda to be referenced/defined in a C# CDK Project, similar to this:
When executing
cdk deploy
, the source directory gets zipped up, uploaded to an S3 Bucket, and the Lambda is created. Great.It seems, however, than the automatic creation of a Lambda Layer -- specifically, with the generation of NuGet packages -- does not happen via
cdk deploy
. This then means that manual steps are required to get the source into the desired state before executingcdk deploy
. See: https://stackoverflow.com/questions/72992860/how-to-correctly-deploy-a-dotnet-lambda-layer-with-aws-cdk#comment128928520_72992860If anyone can point me in the direction of an example that shows this has been done, that would be awesome.
Many thanks,
Jon
Beta Was this translation helpful? Give feedback.
All reactions