terraform-provider-kafka icon indicating copy to clipboard operation
terraform-provider-kafka copied to clipboard

Fix remove acls when not exist

Open leonardobiffi opened this issue 2 years ago • 2 comments

Closes #237

When the ACL has already been removed from kafka, and terraform destroy is executed, the error occurs:

Error: There were no acls matching this filter

This suggestion is to avoid this error

leonardobiffi avatar Mar 18 '22 18:03 leonardobiffi

@leonardobiffi Can you add a test? As for the change, I think we should keep returning this error in the client, but just catch it, and do a d.SetId("") in the read of the acl_resource...

Mongey avatar Apr 07 '22 20:04 Mongey

Hi @Mongey, if no ACL found, d.SetId("") is already being defined in aclRead

https://github.com/Mongey/terraform-provider-kafka/blob/master/kafka/resource_kafka_acl.go#L154

Again taking the aws provider as an example, when the bucket does not exist the delete function returns nil. So the idea would be the same: https://github.com/hashicorp/terraform-provider-aws/blob/9f3fce2617489a9ec7f3486a51e2981a4410c085/internal/service/s3/bucket.go#L1417

leonardobiffi avatar Apr 13 '22 15:04 leonardobiffi

@Mongey this PR can be accepted? what is missing?

leonardobiffi avatar Oct 05 '22 19:10 leonardobiffi

@leonardobiffi can you add a test to demonstrate the behaviour that this is fixing?

Mongey avatar Oct 05 '22 19:10 Mongey