Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing ibm_network_vlan resource fails with weird error message #1871

Closed
mindjiver opened this issue Sep 7, 2020 · 3 comments
Closed

Comments

@mindjiver
Copy link
Contributor

Terraform Version

 ./terraform -v
Terraform v0.12.24
+ provider.ibm v1.11.2
+ provider.null v2.1.2
+ provider.random v2.3.0

Affected Resource(s)

Please list the resources as a list, for example:

  • ibm_network_vlan

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

resource "ibm_network_vlan" "private_vlans" {
  for_each        = var.private_vlan_routers
  name            = "private vlan ${each.key}"
  datacenter      = each.key
  type            = "PRIVATE"
  router_hostname = "${each.key}.${each.value}"
  tags            = split(".", var.name)
}

Debug Output

https://gist.github.com/mindjiver/1e5630b5e0c98bb80038c8e3f7277488

Expected Behavior

I expected the resource to be imported into Terraform state

Actual Behavior

An error was printed

Steps to Reproduce

  • Create a VLAN inside IBM
  • Try to import state into Terraform
  • State should be imported, but is not.

Important Factoids

Don't think so

References

Perhaps stripe/stripe-go#642 ?

@mindjiver
Copy link
Contributor Author

I debugged this a bit more and the problem is that we set the IAAS endpoint like this:

iaas_classic_endpoint_url = "https://origin.eu-fr2.containers.cloud.ibm.com"

provider "ibm" {
  ibmcloud_api_key          = var.ibmcloud_api_key
  iaas_classic_username     = var.iaas_classic_username
  iaas_classic_api_key      = var.iaas_classic_api_key
  iaas_classic_endpoint_url = var.iaas_classic_endpoint_url
  region                    = var.region
  version                   = "~> 1.12.0"
}

And when calling out to the VLAN endpoint (or the subnet endpoint in this case) the provider does the following:

2020-09-18T17:56:13.325+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0: 2020/09/18 17:56:13 [DEBUG] Request URL:  GET https://origin.eu-fr2.containers.cloud.ibm.com/SoftLayer_Product_Package/getAllObjects.json?objectFilter=%7B%22type%22%3A%7B%22keyName%22%3A%7B%22operation%22%3A%22ADDITIONAL_SERVICES_PORTABLE_IP_ADDRESSES%22%7D%7D%7D&objectMask=mask%5Bid%2Cn
ame%2Cdescription%2CisActive%2Ctype%5BkeyName%5D%5D&resultLimit=0%2C1
2020-09-18T17:56:13.325+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.

and the response is just a 200 and a Swagger web page without the JSON content that is expected:

2020/09/18 17:56:13 [ERROR] eval: *terraform.EvalApplyPost, err: Error creating subnet: invalid character '<' looking for beginning of value
2020/09/18 17:56:13 [ERROR] eval: *terraform.EvalSequence, err: Error creating subnet: invalid character '<' looking for beginning of value
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0: 2020/09/18 17:56:13 [DEBUG] Status Code:  200
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0: 2020/09/18 17:56:13 [DEBUG] Response:  <!-- HTML for static distribution bundle build -->
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0: <!DOCTYPE html>
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0: <html lang="en">
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:   <head>
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:     <meta charset="UTF-8">
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:     <title>Swagger UI</title>
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:     <link rel="stylesheet" type="text/css" href="./swagger-ui.css" >
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:     <link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:     <link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:     <style>
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:       html
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:       {
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:         box-sizing: border-box;
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:         overflow: -moz-scrollbars-vertical;
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:         overflow-y: scroll;
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:       }
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:       *,
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:       *:before,
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:       *:after
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:       {
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:         box-sizing: inherit;
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:       }
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:       body
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:       {
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:         margin:0;
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:         background: #fafafa;
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:       }
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:     </style>
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:   </head>
2020-09-18T17:56:13.626+0200 [DEBUG] plugin.terraform-provider-ibm_v1.12.0:

@hkantare
Copy link
Collaborator

hkantare commented Sep 21, 2020

The resource "ibm_network_vlans" are targeted to work for Classic infrastructure endpoint ("https://api.softlayer.com/rest/v3")

https://origin.eu-fr2.containers.cloud.ibm.com/global/swagger-global-api/ this endpoint is not supported here we don't have API to create Vlans ...

@mindjiver
Copy link
Contributor Author

@hkantare Yes. turns out we did not need to provide another classic endpoint. Thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants