4

I'm trying to figure out if there is a way I can package up an aws serverless project in an automated way so that we can split our build and release pipeline up.

Using the dotnet lambda command line tools, I can see there is a dotnet lambda package command to package the lambda as a .zip file ready for deployment. But I can't find anything for packaging the whole serverless application up.

Is this possible? If so what commands do I run?

We're running on VSTS for the Build and Release pipelines, however I don't really think I makes any difference as long as I can script it out.

Kevin Smith
  • 13,746
  • 4
  • 52
  • 77
  • The key phrase is `visual studio aws serverless project`. Did you install the [Visual Studio AWS Toolkit](https://aws.amazon.com/visualstudio/)? It contains [AWS Serverless project templates](https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/lambda-index.html). As for creating .NET Core projects from the command line, the relevant command is `dotnet new whatever`. Once you install the toolkit run `dotnet new` without arguments in a console to list the names of the new templates – Panagiotis Kanavos May 21 '18 at 13:08
  • [This guide](https://docs.aws.amazon.com/lambda/latest/dg/lambda-dotnet-coreclr-deployment-package.html) shows how to install the AWS templates from the commandline – Panagiotis Kanavos May 21 '18 at 13:15
  • I've already created the project and can deploy it using the right click project and `Publish to AWS Lambda` in visual studio or by running `dotnet lambda deploy-serverless`, however I want this to build run as a multiple steps on our build server, so step 1 - "build the C# code and package artifacts", Step 2 - "Deploy to DevTest stack", Step 3 - "Deploy to Production Stack" – Kevin Smith May 21 '18 at 13:15
  • You didn't ask how to configure your XYZ build server to run a build script. Which build server are you using? Does it support .NET commands, scripts, batches? Worst case you can create a `build.cmd` file with the commands. – Panagiotis Kanavos May 21 '18 at 13:18
  • It doesn't really matter which build environment I'm running, ideally I want to use cake, but that can drop back to using any old command. I'll update the question with more clarity – Kevin Smith May 21 '18 at 13:26

1 Answers1

7

Looks like this is possible by packaging up the lambda function into a zip file with the dotnet lambda package command and then copying across the serverless.template file to be used later.

dotnet lambda package

Once we've got our *.zip and our serverless.template handy we can then run the dotnet lambda deploy-serverless with the following arguments:

dotnet lambda deploy-serverless --package .\drop\MyApp.zip --template .\drop\serverless.template
Kevin Smith
  • 13,746
  • 4
  • 52
  • 77