Skip to content

Unable to extract the install preview output #86

@liftconfig

Description

@liftconfig

Is there a way to extract the install preview using the provider? I've tried using the security console resources below - although the install preview task is successful in FortiManager, I can't see a way to get the results as an output.

resource "fortimanager_securityconsole_install_package" "install" {
  fmgadom = "testadom"
  pkg     = "aws"
  flags   = ["preview"]
  force_recreate = uuid()

  scope {
    name = "testfg1"
    vdom = "root"
  }
}

resource "fortimanager_securityconsole_install_preview" "preview" {
  fmgadom        = "testadom"
  flags          = ["none"]
  force_recreate = uuid()

  scope {
    name = "testfg1"
    vdom = "root"
  }
}

Reviewing https://community.fortinet.com/t5/FortiManager/Technical-Tip-How-to-install-preview-and-review-the-output-of/ta-p/301325 it seems there isn't a securityconsole resource for the final step calling /securityconsole/preview/result

I've tried using a generic api resource to for this API call but it's failing:

resource "time_sleep" "wait_30s" {
  create_duration = "30s"
  triggers = {
    preview_id = fortimanager_securityconsole_install_preview.preview.id
  }
}

resource "fortimanager_json_generic_api" "result" {
  json_content = <<JSON
{
    "id": 1,
    "method": "exec",
    "params": [
        {
            "data": {
               "adom": "testadom",
               "device": "testfg1"
            },
            "url": "/securityconsole/preview/result"
        }
    ],
    "verbose": 1
}
JSON
  depends_on   = [fortimanager_securityconsole_install_preview.preview, time_sleep.wait_30s]
}

Apply result:

fortimanager_json_generic_api.result: Creating...
╷
│ Error: Error createGeneric:
│ err -1: runtime error 0: invalid value
│
│   with fortimanager_json_generic_api.result,
│   on main.tf line 106, in resource "fortimanager_json_generic_api" "result":
│  106: resource "fortimanager_json_generic_api" "result" {
│
╵

Is there a different way I should be doing this? The provider documentation is unclear.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions