chronark / terraform-provider-vercel

A terraform provider for vercel's hosting platform
ff789693-5a72-142e-e45d-326ead4ae7a4.vercel.app
Mozilla Public License 2.0
25 stars 9 forks source link

Allows importing #32

Closed thiagoarrais closed 3 years ago

thiagoarrais commented 3 years ago

First of all, thanks for the provider. Great work!

I am trying to import some Vercel projects to Terraform, but I see that the provider doesn't include the needed ResourceImporters. I wonder if you'd be interested in adding those. This PR currently implements a (very crude) importer for the vercel_project resource.

With this im place, it is possible to do:

$ terraform import vercel_project.myproject team_y4tZByVi8ZSPSvHGptjP21Lu/prj_caqJd29Md3VVCUQogqsBgeSNPSJO

or (for a non-team project)

$ terraform import vercel_project.myproject projectid

Would you be interested in some along those lines (with TODOs resolved, of course) for this and some other resource types?

If so, I am willing to add importers to:

chronark commented 3 years ago

Hi @thiagoarrais

Yeah that seems very useful. I resorted to recreating the projects in the past but importing them would be a way better experience.

I'd love to merge your PR. Thank you so much.

thiagoarrais commented 3 years ago

Yay! Good to hear that!

I'll get the CI to green and work on the other resources I mentioned and get back to you.

chronark commented 3 years ago

Great, let me know if I can help with anything.

chronark commented 3 years ago

34 should fix the ci pipeline, I'd like to have some tests for these features.

I know that I haven't set a great example with test coverage yet but I'd like to improve it.

I've had my trouble testing terraform but please let me know how I can help @thiagoarrais

thiagoarrais commented 3 years ago

I am used to writing tests for the main CRUD operations with the Terraform SDK testing framework, but I'm not really sure how to (properly) test resource importing... Any pointers?

chronark commented 3 years ago

I have no idea to be honest, never used it. But I'll try and find some examples from the official providers perhaps.

chronark commented 3 years ago

@thiagoarrais just a heads up: I will be on vacation starting monday until the end of the week, but I'd be happy to merge your progress until sunday, if that's beneficial for you or your work.

thiagoarrais commented 3 years ago

No need. I can happily wait for you to get back. Have a great vacation!

thiagoarrais commented 3 years ago

Hey, @chronark. I think this deserves a new look now. I've changed the import ids to use more visible names instead of the Vercel IDs themselves that are only accessible through fiddling directly with API calls. And I've also added some tests. They work by calling the import functions directly and are thus a little less integration-y than the other tests. But I think this may work.

chronark commented 3 years ago

Hey @thiagoarrais, thank you so much for your work. I agree, human readable names are probably better for this application.

I've created a copy of this pr (#44) to allow the e2e tests to run. Unfortunately the vercel token secret is not available to forks, and I haven't come up with a better way yet. But I'll merge this as soon as they pass.

Thanks again for your contribution.

chronark commented 3 years ago

@thiagoarrais The v0.12.0 release is building right now with your changes