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

Changing git_repository in a project resource forces recreation

Open arbourd opened this issue 2 years ago • 2 comments

If you create a project:

resource "vercel_project" "example" {
  name      = "example"
  framework = "nextjs"
}

And change it to (assuming you actually have the GitHub app setup in the account)

resource "vercel_project" "example" {
  name      = "example"
  framework = "nextjs"

  git_repository = {
    type              = "github"
    repo              = "vercel/example"
    production_branch = "main"
  }
}

The provider wants to do a delete/create action, rather than an update.

Is this intended? Manually adding the GitHub app to the project and then running the terraform plan again showed that the API was able to update the project without recreation.

arbourd avatar Feb 03 '23 21:02 arbourd

Hey, thanks for raising this. It is the intended behaviour at the moment - I haven't added support for linking/unlinking a git_repository without recreating the project.

We have the right APIs for linking/unlinking though, so it should be possible to make the terraform provider not delete + recreate the project.

dglsparsons avatar Feb 06 '23 09:02 dglsparsons

I'm wondering what those API's are. Looking at the Vercel REST API there is no option to patch the gitRepository in the documentation. Would love to see this change happen soon and can help out with it if there's more information around it. This makes migrating git repositories quite painful as we need to do manual terraform imports to update the git repository in the state file. Failure to do so removes the complete project including all of the accumulated stats (like analytics, build history etc)

blurrah avatar Feb 28 '23 09:02 blurrah

Hi @arbourd, @blurrah. This has been fixed in v1.8.0 of the Terraform Provider.

Please give it a go and let me know if you encounter any issues 🙏

dglsparsons avatar Apr 23 '24 08:04 dglsparsons