aws / aws/aws-extensions-for-dotnet-cli
How to integrate dotnet lambda layers in a CI/CD pipeline
- Dominant language
- C#
- Stars
- 393
- Forks
- 90
- Avg merge
- 2d 19m
- Merged PRs (30d)
- 3
Description
My current CI/CD looks like this:
1. code: source code on github
2. build: automatically executes after code is pushed to github. The code is transformed in deployment artifacts in TeamCity. For example, my build script runs the `dotnet lambda package` command. This generates a zip file in the TeamCity artifacts.
3. deploy: when a developer is ready to run a deployment, he manually triggers a deployment in octopus. This uses the deployment artifacts created in the previous step. My octopus project uses terraform to deploy my AWS infrastructure.
I have the feeling that this a pretty standard CI/CD pipeline. I could easilly map this to AWS CodeBuild and AWS Code Pipeline.
I then have some problems figuring how to integrate the `dotnet lambda publish-layer` and `dotnet lambda deploy-function` commands in this pipeline. Since both commands operate on my source code, the only option is to integrate them in step 2 (build step). The problem is that this step is only there to build. It is not there to deploy. In fact, it does not have any access to AWS. Furthermore, all my AWS infrastructure is deployed in step 3. It therefore wouldn't make sense to deploy my lambda layers and lambdas in step 2.
To resolve this, I have the feeling that a new command like `dotnet lambda package-layer` would be more helpful. It would work in a way similar to `dotnet lambda package`, i.e.:
- it would run in the build step of my CI/CD pipeline
- it would generate a zip file (including the manifest) that corresponds to the lambda layer
- this zip file would become a build artifact that could be used by my deployment step
Then, the `--function-layers` parameters of `dotnet lambda package` could accept this local zip file as an input (i.e. the command would not only accept layer arns).
I feel that this would be a more natural way to integrate lambda layers in a CI/CD pipeline.
If you look at the [lambda layers integration in terraform](https://www.terraform.io/docs/providers/aws/r/lambda_layer_version.html), you will see that only nodejs layers are supported. Also, you will see that the `aws_lambda_layer_version` resource takes a zip file as input (`filename`). So, if a command like `dotnet lambda package-layer` could create a zip file, it could be integrated naturally in a CI/CD pipeline that uses terraform.
So, any clarification on how to use lambda layers in a CI/CD pipeline would be appreciated.
Contributor guide
Assessment
This issue has not been assessed yet.