hashicorp / terraform-provider-consul

Terraform Consul provider
https://www.terraform.io/docs/providers/consul/
Mozilla Public License 2.0
124 stars 113 forks source link

Don't panic on missing role in consul_acl_role_policy_attachment #379

Closed remilapeyre closed 9 months ago

remilapeyre commented 9 months ago

resourceConsulACLRolePolicyAttachmentCreate() and resourceConsulACLRolePolicyAttachmentDelete() were not checking properly if the given role ID was not found in Consul.

Some functions in the Consul SDK return an error when the object is missing, other return a nil object.

In the case of RoleRead() I was checking for the wrong thing. I checked the rest of the ACL resources and as far as I know it, this was the only resource impacted.

I also update the consul_acl_policy data source to use the new PolicyReadByName() function.

Closes https://github.com/hashicorp/terraform-provider-consul/issues/378