Skip to content

Resource 'cloudflare_magic_wan_static_route' is not working #5520

@omallo

Description

@omallo

Confirmation

  • This is a bug with an existing resource and is not a feature request or enhancement. Feature requests should be submitted with Cloudflare Support or your account team.
  • I have searched the issue tracker and my issue isn't already found.
  • I have replicated my issue using the latest version of the provider and it is still present.

Terraform and Cloudflare provider version

❯ terraform -v
Terraform v1.11.3
on darwin_arm64
+ provider registry.terraform.io/cloudflare/cloudflare v5.3.0

Affected resource(s)

  • cloudflare_magic_wan_static_route

Terraform configuration files

resource "cloudflare_magic_wan_static_route" "test" {
  account_id  = "XXXXXXXXXX"
  description = "test"
  prefix      = "111.111.111.0/24"
  nexthop     = "222.222.222.222"
  priority    = 100
}

Link to debug output

https://gist.github.com/omallo/d7c2e58e2469897cbb98109699cb7e20

Panic output

No response

Expected output

The static route should be created successfully.

Actual output

POST "https://api.cloudflare.com/client/v4/accounts/XXXXXXXXXX/magic/routes": 400 Bad Request {
  "result": null,
  "success": false,
  "errors": [
    {
      "code": 1022,
      "message": "Invalid Request: json: cannot unmarshal array into Go value of type map[string][]interface {}"
    }
  ],
  "messages": []
}

Steps to reproduce

  1. Use valid values for the cloudflare_magic_wan_static_route in your environment.
  2. Run a terraform apply.
  3. See the resource creation fail.

Additional factoids

  • Any resource of type cloudflare_magic_wan_static_route fails, independently of the attributes.
  • Based on the Terraform debug output, the provider version 5.3.0 is creating a wrong payload for the Cloudflare API endpoint. This is the request generated by the provider:
    POST /client/v4/accounts/XXXXXXXXXX/magic/routes
    
    # the following payload is generated by the provider, but it is wrong
    [{"description":"test","nexthop":"222.222.222.222","prefix":"111.111.111.0/24","priority":100}]
  • With the provider version 4.52.0, the resource is created correctly. That provider version generates the following, correct payload:
    {"routes":[{"prefix":"111.111.111.0/24","nexthop":"222.222.222.222","priority":100,"description":"test","scope":{}}]}

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.version/5Categorizes issue or PR as related to version 5 of the provider.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions