Use Terraform to set Node Version

I am using Terraform to deploy a Vercel project. I cannot seem to figure out how to get the NodeJS version set for the project.

Here is my current configuration

resource "vercel_project" "project" {
  name                                              = var.projectname
  framework                                         = "nextjs"
  git_repository                                    = var.git_repository
  automatically_expose_system_environment_variables = true
  build_command                                     = "pnpm -w run format && cd ../../ && pnpm run build:app"
  install_command                                   = "pnpx @puppeteer/browsers install chrome && cd ../../ && pnpm install -r --no-frozen-lockfile && cd ./apps/app"
  root_directory                                    = "apps/app"
}

Perplexity suggested adding an environment section but that didn’t seem to work. Sometimes it’s pretty bad with the hallucinations and insistence that it’s correct and in this case I think it’s just making things up.

resource "vercel_project" "project" {
  name                                              = var.projectname
  framework                                         = "nextjs"
  git_repository                                    = var.git_repository
  automatically_expose_system_environment_variables = true
  build_command                                     = "pnpm -w run format && cd ../../ && pnpm run build:app"
  install_command                                   = "pnpx @puppeteer/browsers install chrome && cd ../../ && pnpm install -r --no-frozen-lockfile && cd ./apps/app"
  root_directory                                    = "apps/app"

   environment = [
     {
       key    = "NODE_VERSION"
       value  = "18.x" # Specify your desired Node.js version
       target = ["production", "preview", "development"]
     }
   ]
}

Additionally checking the docs ( vercel_project | Resources | vercel/vercel | Terraform | Terraform Registry I don’t see any indication that I can set the Node Version.

I am almost certain I can do this with a Rest API call but I’d rather not kick out to external calls if I don’t have to, even though I have for other parts of my solution.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.