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

Discrepencies with api spec and the terraform syntax

Open KumarGanesanIBM opened this issue 5 months ago • 3 comments

Regarding this document https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/is_lb_listener_policy#sample-to-create-a-load-balancer-listener-policy-for-a-https_redirect-action It doesn't seem to be self-consistent - e.g., based on the property names, target_https_redirect_status_code should be target_https_redirect_http_status_code. And why would there be a need to create unique property names when the schema can already be differentiated by the value of the action property? What other oneOf instances use this convention? please help to understand ?

FYI: https://pages.github.ibm.com/vpc/vpc-spec-artifacts/branch/master/swagger-ui.html?version=today#/Load%20balancers/create_load_balancer_listener_policy

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform IBM Provider Version

Affected Resource(s)

  • ibm_is_lb_listener_policy

Terraform Configuration Files

Current config

resource "ibm_is_lb" "example" {
  name    = "example-lb"
  subnets = [ibm_is_subnet.example.id]
}

resource "ibm_is_lb_listener" "example_http_source" {
  lb       = ibm_is_lb.example.id
  port     = "9080"
  protocol = "http"
}

resource "ibm_is_lb_listener" "example_https_target" {
  lb                   = ibm_is_lb.example.id
  port                 = "9086"
  protocol             = "https"
  certificate_instance = "crn:v1:staging:public:cloudcerts:us-south:a2d1bace7b46e4815a81e52c6ffeba5cf:af925157-b125-4db2-b642-adacb8b9c7f5:certificate:c81627a1bf6f766379cc4b98fd2a44ed"
}

resource "ibm_is_lb_listener_policy" "example" {
  lb                                = ibm_is_lb.example.id
  listener                          = ibm_is_lb_listener.example_http_source.listener_id
  action                            = "https_redirect"
  priority                          = 2
  name                              = "example-listener"
  target_https_redirect_listener    = ibm_is_lb_listener.example_https_target.listener_id
  target_https_redirect_status_code = 301
  target_https_redirect_uri         = "/example?doc=geta"
  rules {
    condition = "contains"
    type      = "header"
    field     = "1"
    value     = "2"
  }
}

### Debug Output

<!---
Please provide a link to a GitHub Gist containing the complete debug output. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

To obtain the debug output, see the [Terraform documentation on debugging](https://www.terraform.io/docs/internals/debugging.html).
--->

### Panic Output

<!--- If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the `crash.log`. --->

### Expected Behavior

<!--- What should have happened? --->

### Actual Behavior

#### Expected config

```hcl
resource "ibm_is_lb" "example" {
  name    = "example-lb"
  subnets = [ibm_is_subnet.example.id]
}

resource "ibm_is_lb_listener" "example_http_source" {
  lb       = ibm_is_lb.example.id
  port     = "9080"
  protocol = "http"
}

resource "ibm_is_lb_listener" "example_https_target" {
  lb                   = ibm_is_lb.example.id
  port                 = "9086"
  protocol             = "https"
  certificate_instance = "crn:v1:staging:public:cloudcerts:us-south:a2d1bace7b46e4815a81e52c6ffeba5cf:af925157-b125-4db2-b642-adacb8b9c7f5:certificate:c81627a1bf6f766379cc4b98fd2a44ed"
}

resource "ibm_is_lb_listener_policy" "example" {
  lb                                = ibm_is_lb.example.id
  listener                          = ibm_is_lb_listener.example_http_source.listener_id
  action                            = "https_redirect"
  priority                          = 2
  name                              = "example-listener"
  target {
      https_redirect_listener         = ibm_is_lb_listener.example_https_target.listener_id
      https_redirect_status_code = 301
      https_redirect_uri                 = "/example?doc=geta"
  }
  rules {
    condition = "contains"
    type      = "header"
    field     = "1"
    value     = "2"
  }
}

### Steps to Reproduce

<!--- Please list the steps required to reproduce the issue. --->

1. `terraform apply`

### Important Factoids

<!--- Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? --->

### References

<!---
Information about referencing Github Issues: https://help.github.com/articles/basic-writing-and-formatting-syntax/#referencing-issues-and-pull-requests

Are there any other GitHub issues (open or closed) or pull requests that should be linked here? Vendor documentation? For example:
--->

* #0000

KumarGanesanIBM avatar Jan 30 '24 17:01 KumarGanesanIBM

looking into this

ujjwal-ibm avatar Jan 31 '24 05:01 ujjwal-ibm

@ujjwal-ibm can you please let us know what is the ETA for this?

KumarGanesanIBM avatar Feb 05 '24 04:02 KumarGanesanIBM

New terraform config

resource "ibm_is_lb_listener_policy" "example" {
  lb       = ibm_is_lb.example.id
  listener = ibm_is_lb_listener.example.listener_id
  action   = "redirect"
  priority = 4
  name     = "example-listener-policy"
  target {
    http_status_code = 302
    url              = "https://www.example.com"
  }
}

@astha-jain @sumitkumartiwari This issue can be closed

deepaksibm avatar Feb 20 '24 17:02 deepaksibm