fortinetdev / terraform-provider-fortimanager

Mozilla Public License 2.0
10 stars 9 forks source link

Add prerun_cliprof attribute to fortimanager_dvm_cmd_add_device resource #55

Closed Almujalled closed 2 months ago

Almujalled commented 2 months ago

Hey there,

I've been using the fortimanager_dvm_cmd_add_device resource and it's been great. But, I noticed that it's missing the prerun_cliprof attribute that I use in the FortiManager GUI when adding a new model device.

It would be super helpful if we could get this attribute added to the resource.

Thanks!

MaxxLiu22 commented 2 months ago

Hi @Almujalled ,

Thank you for raising this question. Upon investigation, I discovered that the GUI uses a separate API, /pm/config/adom/74/obj/cli/template/cli_tmp/scope member, to achieve prerun_cliprof function. Unfortunately, this API is not public at the moment. I have reported this issue to the development team, who are working to find a solution. In the meantime, could you kindly try using the generic method after your fortimanager_dvm_cmd_add_device resource to see if it functions well?

resource "fortimanager_object_cli_template" "trname" {
  scopetype   = "adom"
  adom        = "74"
  description = "This is a Terraform example"
  name        = "pre_run_cli_tmp"
  script      = "terr-script"
  provision   = "enable"
}

resource "fortimanager_json_generic_api" "tfname" {
  depends_on   = [fortimanager_object_cli_template.trname]
  json_content = <<JSON
{
    "method": "add",
    "params": [
        {
            "url": "/pm/config/adom/${var.adom}/obj/cli/template/${pre_run_cli_tmp}/scope member",
            "data": [
                {
                    "name": "managed_fgt",
                    "vdom": "global"
                }
            ]
        }
    ]
}
JSON
}

Thanks, Maxx

Almujalled commented 2 months ago

Hi @MaxxLiu22,

I've tried the generic method as you suggested, and I'm happy to report that it worked!

Thank you for your support!

Regards, Ghaith