splunk / terraform-provider-splunk

Terraform Provider for Splunk
Mozilla Public License 2.0
103 stars 75 forks source link

Handle missing roles and failed requests to create/update roles #97

Open micahkemp-splunk opened 2 years ago

micahkemp-splunk commented 2 years ago

Similar to the issue addressed in #89, the roles resource doesn't properly handle resources that are in state but missing on the remote Splunk instance. This is made worse by insufficient checking of the response returned within [CreateAuthorizationRoles](https://github.com/splunk/terraform-provider-splunk/blob/master/client/authorization_roles.go#L10), as a failed creation of a role won't be handled as a failure within the provider, resulting in a resource being added to state but with no remote configuration actually having been created. To resolve this issue, the response's status code needs to be checked for success, instead of relying on a returned error.

While looking into the issue it was also identified that [UpdateAuthorizationRoles](https://github.com/splunk/terraform-provider-splunk/blob/master/client/authorization_roles.go#L35) also needs to handle failures by response code as well.