vercel / terraform-provider-vercel

Terraform Vercel Provider
Mozilla Public License 2.0
144 stars 23 forks source link

Error when trying to deploy prebuilt project #236

Open antspy opened 5 days ago

antspy commented 5 days ago

Hi,

I have a monorepo setup:

.vercel/
src/
  frontend/
    ...
    terraform/
      main.tf 

(Note how the .vercel folder is at the root of the monorepo - this is required for vercel build to work correctly).

I can build & deploy this manually just fine:

pnpm vercel build --prod --token=$VERCEL_TOKEN
pnpm vercel deploy --prebuilt --prod --token=$VERCEL_TOKEN

Now I want to do the same, deploying with terraform. Following the docs, I do:

data "vercel_prebuilt_project" "frontend_dir" {
  path = "../../../"
}

# TODO: How does this interact with the .vercel/project.json stuff?
resource "vercel_deployment" "prod_deployment" {
  project_id  = vercel_project.frontend_project.id
  files       = data.vercel_prebuilt_project.frontend_dir.output
  path_prefix = data.vercel_prebuilt_project.frontend_dir.path
  production = true
}

But this raises an error when running terraform -chdir=src/frontend/terraform apply (after having run pnpm vercel build --prod --token=$VERCEL_TOKEN already):

│ Error: Error reading prebuilt output
│ 
│   with data.vercel_prebuilt_project.frontend_dir,
│   on main.tf line 61, in data "vercel_prebuilt_project" "frontend_dir":
│   61: data "vercel_prebuilt_project" "frontend_dir" {
│ 
│ An unexpected error occurred reading files from the .vercel directory: could not read file
│ ../../../.vercel/output/functions/_not-found.rsc.func: read ../../../.vercel/output/functions/_not-found.rsc.func: is a directory

And that's correct, .vercel/output/functions/_not-found.rsc.func is indeed a directory, not sure why terraform expects it to be a file. The vercel provider version is vercel/vercel v2.3.0, and I am using next 14.2.

I couldn't find anything about this error online. Do you have an idea? Thanks!

dglsparsons commented 4 days ago

Hi @antspy, this sounds super weird and not at all intentional. Are you able to provide a minimal reproduction of the issue?