terraform-provider-vercel icon indicating copy to clipboard operation
terraform-provider-vercel copied to clipboard

vercel_deployment does not deploy preview if production = false

Open typytypytypy opened this issue 2 years ago • 1 comments

Hi, I am trying to make a preview deployment in terraform, but every time it makes a production deployment

resource "vercel_project" "projname" {
  name      = "projname"
  framework = "remix"
  team_id   = "team_id"

  git_repository = {
    type = "github"
    repo = "${github_repository.projname.full_name}"
  }
}

resource "vercel_deployment" "projname_preview" {
  project_id        = vercel_project.projname.id
  team_id           = "team_id"
  ref               = "preview"
  production        = false
  delete_on_destroy = true

  environment = {
    for tuple in regexall("(.*?)=(.*)", file("./.env.prod")) : tuple[0] => tuple[1]
  }
}

I would expect when I apply this that the preview branch is deployed to a preview deployment, but my production deployment gets updated. Do I have something wrong in the syntax?

typytypytypy avatar Oct 21 '22 14:10 typytypytypy

Hi, the first deployment of any project is always a production deployment. Could it be that? Or are you seeing the same issue on subsequent deployments too?

This could be exacerbated with delete_on_destroy = true too.

dglsparsons avatar Oct 21 '22 14:10 dglsparsons

Closing this as it looks stale! :)

dglsparsons avatar Nov 14 '22 17:11 dglsparsons

@dglsparsons yes, this can be closed. The issue was as you described, the first deployment pushes to production and preview, which was a behavior I was not expecting. Thank you for the insight!

typytypytypy avatar Nov 14 '22 18:11 typytypytypy