terraform-provider-pritunl
terraform-provider-pritunl copied to clipboard
Refreshing state problem
Currently when you create resources using Terraform and delete them on UI, terraform will give an error like this:
╷
│ Error: Non-200 response on getting the organization
│ body=500: Internal Server Error
│
│ with module.test_org.pritunl_organization.this,
│ on ../../modules/pritunl_org/main.tf line 1, in resource "pritunl_organization" "this":
│ 1: resource "pritunl_organization" "this" {
│
╵
Hey @zahornyak. It looks weird and strange, but for non-exists resources, foe example organizations, Pritunl API returns status code 500 (internal server error) instead of 404 (not found):
when I directly make a HTTP requests
or do an import of an organizations that doesn't exist
terraform import pritunl_organization.guests abcd123
pritunl_organization.guests: Importing from ID "abcd123"...
pritunl_organization.guests: Import prepared!
Prepared pritunl_organization for import
pritunl_organization.guests: Refreshing state... [id=abcd123]
╷
│ Error: Non-200 response on getting the organization
│ body=500: Internal Server Error
│
│
I faced with an issue when I started working on the provider, but didn't find a solution. Probably I will look into it again.
Hello,
I got the same issue with server resource:
│ Error: Error on starting server: Non-200 response on starting the server
│ body=500: Internal Server Error
│
│ with pritunl_server.server["my_server"],
│ on main.tf line 15, in resource "pritunl_server" "server":
│ 15: resource "pritunl_server" "server" {
Maybe a retry could be added and configured in the provider declaration?
Unfortunately, the issue reproduces with various resources (servers and organizations) due to a possible issue in the Pritunl servers API. It has no validation if a requested resource does exist and it fails on a json-marshaling stage of a nil object.