citrix / terraform-provider-citrixadc

Part of NetScaler Automation Toolkit | https://github.com/netscaler/automation-toolkit
https://registry.terraform.io/providers/citrix/citrixadc
Apache License 2.0
118 stars 58 forks source link

[BUG] Unable to remove citrixadc_policystringmap_pattern_binding with / or special char #1018

Closed RafaelloLollipop closed 1 year ago

RafaelloLollipop commented 1 year ago

Bug Report

Describe the bug

If key in string map contains "/'" or "%" it can not be removed by terraform. But i'm pretty sure that it was working like 1-2 months ago.

To Reproduce Steps to reproduce the behaviour:

  1. My terraform files are

resource "citrixadc_policystringmap" "tf_policystringmap" { name = "tf_tests" }

resource "citrixadc_policystringmap_pattern_binding" "tf_bind1" { name = "tf_tests" key = "test" value = "test" }

resource "citrixadc_policystringmap_pattern_binding" "tf_bind2" { name = "tf_tests" key = "test/test" value = "random" }


Plan:

string_maps: Perform terraform plan

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:

Terraform will perform the following actions:

module.ns_tst_string_maps.citrixadc_policystringmap.tf_policystringmap will be created

Plan: 3 to add, 0 to change, 0 to destroy.


After apply:

![image](https://user-images.githubusercontent.com/6643759/225026765-14371a13-0b8c-4ecc-93c4-a5a8ceb27bb4.png)

Removing bindings:

```hcl

resource "citrixadc_policystringmap" "tf_policystringmap" {
  name    = "tf_tests"
}

plan:

string_maps: Perform terraform plan
-------------------------------------------------------------------------
module.ns_tst_string_maps.citrixadc_policystringmap_pattern_binding.tf_bind1: Refreshing state... [id=tf_tests,test]
module.ns_tst_string_maps.citrixadc_policystringmap.tf_policystringmap: Refreshing state... [id=tf_tests]
module.ns_tst_string_maps.citrixadc_policystringmap_pattern_binding.tf_bind2: Refreshing state... [id=tf_tests,test/test]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  - destroy

Terraform will perform the following actions:

  # module.ns_tst_string_maps.citrixadc_policystringmap_pattern_binding.tf_bind1 will be destroyed
  # (because citrixadc_policystringmap_pattern_binding.tf_bind1 is not in configuration)
  - resource "citrixadc_policystringmap_pattern_binding" "tf_bind1" {
      - id    = "tf_tests,test" -> null
      - key   = "test" -> null
      - name  = "tf_tests" -> null
      - value = "test" -> null
    }

  # module.ns_tst_string_maps.citrixadc_policystringmap_pattern_binding.tf_bind2 will be destroyed
  # (because citrixadc_policystringmap_pattern_binding.tf_bind2 is not in configuration)
  - resource "citrixadc_policystringmap_pattern_binding" "tf_bind2" {
      - id    = "tf_tests,test/test" -> null
      - key   = "test/test" -> null
      - name  = "tf_tests" -> null
      - value = "random" -> null
    }

Plan: 0 to add, 0 to change, 2 to destroy.

apply:

-------------------------------------------------------------------------
string_maps: Perform terraform apply
-------------------------------------------------------------------------
module.ns_tst_string_maps.citrixadc_policystringmap_pattern_binding.tf_bind2: Destroying... [id=tf_tests,test/test]
module.ns_tst_string_maps.citrixadc_policystringmap_pattern_binding.tf_bind1: Destroying... [id=tf_tests,test]
module.ns_tst_string_maps.citrixadc_policystringmap_pattern_binding.tf_bind2: Destruction complete after 0s
module.ns_tst_string_maps.citrixadc_policystringmap_pattern_binding.tf_bind1: Destruction complete after 0s

Apply complete! Resources: 0 added, 0 changed, 2 destroyed.

State:

image

Expected behaviour Both citrixadc_policystringmap_pattern_binding. removed

Environment (please complete the following information):

go version go1.18 linux/amd64



**Additional context**
-
ravager-dk commented 1 year ago

This issue is caused by the AddResource function in the client escaping special characters, while the DeleteResourceWithArgs does not.

https://github.com/citrix/adc-nitro-go/issues/66

rohit-myali commented 1 year ago

Hello @RafaelloLollipop , Thanks for raising this issue. I did fix this issue and it will be released to the terraform registry in our next releases. I will update you on that soon.

Hey @ravager-dk , thanks for working on this issue, I saw your PR but currently we are not accepting 3rd party contribution due to some company policies. Our internal team is working on accepting 3rd part contribution we will update this soon.

Thanks, Rohit

ravager-dk commented 1 year ago

Hello @RafaelloLollipop , Thanks for raising this issue. I did fix this issue and it will be released to the terraform registry in our next releases. I will update you on that soon.

Hey @ravager-dk , thanks for working on this issue, I saw your PR but currently we are not accepting 3rd party contribution due to some company policies. Our internal team is working on accepting 3rd part contribution we will update this soon.

Thanks, Rohit

Hi Rohit

No problem, I am actually internal, just not in engineering.

Regards, Martin Nygaard Jensen

rohit-myali commented 1 year ago

Hi @RafaelloLollipop , Thanks for raising this issue. I have fixed the resource you can use the latest terraform plugin v1.34.0.

Thanks Rohit