SchwarzIT / terraform-provider-stackit

Community-maintained STACKIT Terraform provider
Apache License 2.0
18 stars 6 forks source link

TF destroy not possible in stackit_postgres_flex_user #168

Closed docbyte86 closed 1 year ago

docbyte86 commented 1 year ago

Hello,

terraform destroy is not possible while user is still owner of a database.

Error message:

│ Error: failed to delete user │ │ call error: │ HTTP status code: 500 │ HTTP status message: Internal Server Error │ Server response: │ URL: │ https://postgres-flex-service.api.eu01.stackit.cloud/v1/projects/a300eae4-9e89-484b-9dc1-0aefa592de59/instances/de69e53f-7950-40ef-9cf6-7e21ace779a2/users/16691

do87 commented 1 year ago

i don't have access to the URL you provided, but i'm not sure what would you expect the provider to solve in this case?

acceptance tests for user creation & deletion passed last night

the test can be found here:

https://github.com/SchwarzIT/terraform-provider-stackit/blob/f7ea6da5fd5505a81a96ed51f468a3f5dc319c60/stackit/internal/resources/postgres-flex/user/resource_test.go#L78-L89

(note that the test runs both apply and destroy)

pipeline job:

https://github.com/SchwarzIT/terraform-provider-stackit/actions/runs/5684754640/job/15408955334

you may want to reach out to STACKIT support in this case

docbyte86 commented 1 year ago

I think you didn't properly tested with data inside of the database. A simple create and destroy is not problem. But what is about a tf destroy where a database has been created, where the user (created with TF) is the owner?

do87 commented 1 year ago

@docbyte86 again, the question is - what do you expect the provider to do in this case?

do87 commented 1 year ago

statement from the team: "if the user owns an object you are not able to the delete the user because we decided not to use the drop cascade option"

as the provider has no way of knowing of objects it doesn't maintain (and shouldn't delete them as it's an anti pattern), the only thing i would suggest here is that it returns a more informative response of why a failure may happen