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

packetfabric_cs_azure_hosted_connection: json: cannot unmarshal string into Go struct field #64

Closed
rjouhann opened this issue Aug 19, 2022 · 5 comments · Fixed by #80
Closed
Assignees
Labels
bug Something isn't working

Comments

@rjouhann
Copy link
Contributor

rjouhann commented Aug 19, 2022

Using:

# From the PacketFabric side: Create a PacketFabric Hosted Cloud Connection.
resource "packetfabric_cs_azure_hosted_connection" "cs_conn1" {
  provider          = packetfabric
  description       = "${var.tag_name}-${random_pet.name.id}"
  account_uuid      = var.pf_account_uuid
  azure_service_key = azurerm_express_route_circuit.azure_express_route_1.service_key
  port              = var.pf_port_circuit_id
  speed             = var.pf_cs_speed # will be deprecated
  vlan_private      = var.pf_cs_vlan_private
  #vlan_microsoft = var.pf_cs_vlan_microsoft
}

With those variables: (set your own account_uuid and azure_service_key)

# Azure Hosted Connection
variable "pf_port_circuit_id" {
  type    = string
  default = "PF-AP-WDC1-1726464" # replace with a port you have created in your account
}
variable "pf_cs_speed" {
  type    = string
  default = "50Mbps"
}
variable "pf_cs_vlan_private" {
  type    = number
  default = 100
}
variable "pf_cs_vlan_microsoft" {
  type    = number
  default = 101
}

Getting this error:

packetfabric_cs_azure_hosted_connection.cs_conn1: Still creating... [10s elapsed]
╷
│ Error: json: cannot unmarshal string into Go struct field AzureComponents.components.ifd_port_circuit_id_cust of type int
│ 
│   with packetfabric_cs_azure_hosted_connection.cs_conn1,
│   on main.tf line 91, in resource "packetfabric_cs_azure_hosted_connection" "cs_conn1":
│   91: resource "packetfabric_cs_azure_hosted_connection" "cs_conn1" {
│ 
╵
@rjouhann rjouhann added the bug Something isn't working label Aug 19, 2022
@pontovinte
Copy link
Contributor

Hi @rjouhann, I believe there's a discrepancy between docs and the API. Since we're relying on docs as our source of truth, it shows both ifd_port_circuit_id_cust and ifd_port_circuit_id_pf with int values.

image

Please see this link for reference (https://docs.packetfabric.com/api/v2/redoc/#tag/Cloud-Services-Azure/operation/azure_hosted_connection_post)

@rjouhann
Copy link
Contributor Author

Hey @pontovinte, in the link you shared, the port is a string, not an int.

port | required | string The port to connect to Azure.

Example: "port": "PF-AP-LAX1-1002",

@pontovinte
Copy link
Contributor

@rjouhann, either port is string (here) and ifd_port_circuit_id_cust is int (here). The issue above was complaining about ifd_port_circuit_id_cust not being parsed correctly. But I'm confused if there's any discrepancy between API doc and the actual API as I explained here

@rjouhann
Copy link
Contributor Author

rjouhann commented Aug 23, 2022

@pontovinte I understand the confusion the ifd_port_circuit_id_cust and ifd_port_circuit_id_pf are part of the API response, not the body of the request.

To my knowledge and understanding, ports which is part of the body of the request is always a string because there is always a prefix and PoP name like PF-AP-LAX-1234 and sometime a suffix like PF-AP-LAX-1234-PF.

I actually tried to create a connection using /services/cloud/hosted/azure and look what I am getting in the response:

    "components": {
        "ifd_port_circuit_id_cust": "PF-AP-LAX2-1729130",

ifd_port_circuit_id_cust is a string. I will follow up with PF dev team and get the API schema example updated so it uses a string, not an int for ifd_port_circuit_id_cust and ifd_port_circuit_id_pf response examples.

But the schema does say those are string:

Screen Shot 2022-08-22 at 19 40 40

pontovinte added a commit that referenced this issue Aug 24, 2022
Signed-off-by: Yrineu Rodrigues <yrineu@pontovinte.com>
@pontovinte pontovinte linked a pull request Aug 24, 2022 that will close this issue
pontovinte added a commit that referenced this issue Aug 24, 2022
Signed-off-by: Yrineu Rodrigues <yrineu@pontovinte.com>
@rjouhann
Copy link
Contributor Author

Verified fix in feature/google-service branch

pontovinte added a commit that referenced this issue Aug 26, 2022
Signed-off-by: Yrineu Rodrigues <yrineu@pontovinte.com>
pontovinte added a commit that referenced this issue Aug 26, 2022
Signed-off-by: Yrineu Rodrigues <yrineu@pontovinte.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants