208_man
208_man

Reputation: 1728

How to specify the dotnet 6 runtime for aws lambda, using terraform?

I can deploy a dotnetcore3.1 runtime using this input in my terraform (executed from GitLab CI pipeline):


variable "runtime" {
  type = string
  default = "dotnetcore3.1"
}

After it deploys, I can manually change the runtime from .NET Core 3.1 to .NET 6:

enter image description here

But how do I specify .NET 6 in the terraform to begin with?

I have tried:


variable "runtime" {
  type = string
  default = "dotnet6"
}

But I get the following error in my pipeline:

Error: expected runtime to be one of [nodejs nodejs4.3 nodejs6.10 nodejs8.10 nodejs10.x nodejs12.x nodejs14.x java8 java8.al2 java11 python2.7 python3.6 python3.7 python3.8 dotnetcore1.0 dotnetcore2.0 dotnetcore2.1 dotnetcore3.1 nodejs4.3-edge go1.x ruby2.5 ruby2.7 provided provided.al2], got dotnet6

How does one select the .NET 6 runtime in TF?

Upvotes: 0

Views: 3349

Answers (2)

Ervin Szilagyi
Ervin Szilagyi

Reputation: 16795

It would seem that .NET 6 isn't supported via Terraform.

This is not entirely true, the AWS provider supports dotnet6 runtime, you just have to have a version of the provider has support for it.

Currently the latest version of the AWS provider is 4.27.0. The support for dotnet6 was introduced around version 4.4.0. Adjusting the provider to have a version greater than 4.4.0 should be enough to have dotnet6 support.

So you would want to modify your required_providers block to something like this:

terraform {
  required_providers {
    aws = {
      source = "hashicorp/aws"
      version = ">=4.4.0"
    }
  }
}

Upvotes: 2

Charles
Charles

Reputation: 23803

dotnet6 works just fine.

I suspect your TF version and/or AWS provider are out of date. I'm using dotnet6 for a lmabda just fine with the following..

"terraformVersions": {
    "terraformMajorVersion": "1",
    "providerVersions": {
        "aws": "4.14.0",
    }

Upvotes: 1

Related Questions