betr-io / terraform-provider-mssql

Terraform provider for Microsoft SQL Server
https://registry.terraform.io/providers/betr-io/mssql/latest
MIT License
35 stars 29 forks source link

New resource: `mssql_database_permissions` #70

Open favoretti opened 6 months ago

favoretti commented 6 months ago

This PR introduces a new resource mssql_database_permissions that allows to manage permissions of a single user on the server.

cj-dalley commented 6 months ago

Godsend! Yes, please!

favoretti commented 6 months ago

@magne ping? I know it's holiday season, but... :) Thanks for looking!

magne commented 6 months ago

I will have another look at this if you include acceptance tests. Also, the update and import operations should be working.

Other than that, it looks OK (haven't tested it yet). Thanks for your work.

favoretti commented 6 months ago

Makes sense. I'll add tests in the next couple of days. I tested functionality itself - it works, but I got a bit lost in your test suite, need to dive in.

Thank you!

favoretti commented 6 months ago

@magne Looking at your comment on update and import operations. Re: update - I don't really wanna compare the lists of permissions, and I don't see a lot of harm in dropping them and creating them again (i.e. we can opt in to skip update op altogether and just leave all fields as ForceNew) - what's your take on this?

magne commented 6 months ago

@favoretti, I'm not really sure. It's been some time since I did real terraform provider coding, and I don't remember how it behaved without the update. Why don't you add import and the tests, and I'll take it for a spin and see how it behaves. (Does it recreate the resource on every apply?)

favoretti commented 6 months ago

Without update it just assumes replacement on every change. It does not recreate them every apply, only if any of the arguments change. I'll add tests and import then first. Thank you!

favoretti commented 6 months ago

@magne for some reason when I'm trying to run local acceptance tests it fails to connect to docker image..

=== RUN   TestAccUser_Local_Update_Roles
    resource_user_test.go:320: Step 1/4 error: Error running apply: exit status 1

        Error: unable to create login [user_update]: db connection failed after 30s timeout

          with mssql_login.update,
          on terraform_plugin_test.tf line 2, in resource "mssql_login" "update":
           2:            resource "mssql_login" "update" {

Any pointers on what might be happening here?

favoretti commented 6 months ago

Ahh, I see now. I'm on a M2 Mac, so mssql just doesn't want to start up... Could use some help running/finalizing actual tests... Anyone please? :)