Mastercard / terraform-provider-restapi

A terraform provider to manage objects in a RESTful API
Other
808 stars 217 forks source link

Parameters write_returns_object and create_returns_object individually for each resource "restapi_object" #133

Closed binlab closed 3 years ago

binlab commented 3 years ago

Currently, parameters write_returns_object and create_returns_object can be configured just globally in the provider section, but I stuck with some problem when some of the REST API (Okta API) endpoint response code was 204 and empty BODY, no JSON. So I got an error:

Error: unexpected end of JSON input

But in fact, a resource created successfully

Of course, a workaround was just to set write_returns_object=false and create_returns_object=false but for other resources need to return a response by PUT or POST actions

Additionally, this gave me the idea that it would be nice to also allow an empty BODY

@DRuggeri what do you think?

DRuggeri commented 3 years ago

Thanks for the idea @binlab, but I don't think that can work because of the data the provider needs to know in order to manage the object properly. In your case, it sounds like an empty BODY is provided - which means there's no way to learn what the created ID of the object is (unless you set the object_id on the resource manually... maybe that's possible?). Without knowing the ID of the object, the next run will not know what to manage in the API.

I guess it's possible to do what you describe if you know what the object ID will be when it's created, but in that case, maybe this provider is overkill for the use case?

If that doesn't make sense, please feel free to reopen the issue and share some more details of the API and how it's day 2 lifecycle works - we might be able to cook up a recipe!