Setup
- VS Code
- Terraform (v0.11)
Problem
I'm having difficulty understanding how to manage Lambda Functions in a dotnet core 2.0 project
Current Approach (not implemented just how I think it could work)
- Create the Function structure in Terraform
- Create the Function code in a dotnet core project, as described here
- Zip the publish folder and upload to S3
- Reference the Handler for the Function in the Terraform Function definition as per the AWS documentation for c# (assembly::namespace.class-name::method-name)
Terraform Lambda Function Example
resource "aws_lambda_function" "this" {
function_name = "test_function"
role = "lambda_exec_role"
s3_bucket = "my_bucket"
s3_key = "object_key/package.zip"
handler = "MyApp::Example.Hello::MyHandler"
runtime = "dotnetcore2.0"
}
This approach means that if I change a single function in a project, I have to upload the entire code base to S3 which doesn't feel like a clean way to handle code changes.
Alternative Approach
- Use the dotnet core CLI to manage Lambda Functions instead of Terraform
- Deploy each function using the dotnet core CLI
dotnet lambda deploy-function
This approach feel cleaner from a Lambda code version management perspective, but it means that I'm no longer using Terraform to manage my Lambda Functions.
I've used NodeJs and Go to create Lambda functions before, each seems more lightweight than the dotnet approach (in that it's easier to de-couple each functions source code).
Question
Do either of these setups appear optimal?