fortinetdev / terraform-provider-fortimanager

Mozilla Public License 2.0
11 stars 10 forks source link

Error creating fortimanager_object_webfilter_profile #11

Closed pedrojgsbraga closed 1 year ago

pedrojgsbraga commented 2 years ago

Hi,

I'm trying to create the webfilter_profile and I get an error when call the webfilter_urlfilter (urlfilter_table).

`resource "fortimanager_object_webfilter_urlfilter" "webfilter_urlfilter" { scopetype = "adom" adom = "XX" name = "XX-webfilter_urlfilter" fosid = 1 entries { url = "XX.org" type = "wildcard" action = "allow" status = "enable" } }

resource "fortimanager_object_webfilter_profile" "webfilter_profile" { scopetype = "adom" adom = "XX" name = "XX-egress" feature_set = "flow" extended_log = "disable"

web { urlfilter_table = "1" } } `

The error message is: Error: Error creating ObjectWebfilterProfile resource: err -10: The data is invalid for selected url

versions: Terraform v0.13.7 fortinetdev/fortimanager = 1.3.6 fortimanager = 7.0.2

Thank you.

lix-fortinet commented 2 years ago

Hi @pedrojgsbraga,

Thank you for raising this issue. For your configuration, what you need to do is that you need add the depends_on argument on fortimanager_object_webfilter_profile. For instance:

resource "fortimanager_object_webfilter_profile" "webfilter_profile" {
scopetype = "adom"
adom = "XX"
name = "XX-egress"
feature_set = "flow"
extended_log = "disable"

web {
urlfilter_table = "1"
}
depends_on = [
  fortimanager_object_webfilter_urlfilter.webfilter_urlfilter
]
} 

However, we do found some issue on the web block of resource fortimanager_object_webfilter_profile. Team are woking on this issue. And we will get back to you when it's solved. Before that, you could use generic resource as alternatives: https://registry.terraform.io/providers/fortinetdev/fortimanager/latest/docs/resources/fortimanager_json_generic_api

For example:

resource "fortimanager_json_generic_api" "test1" {
  json_content = <<JSON
{
    "method": "add",
    "params": [
        {
            "url": "/pm/config/adom/root/obj/webfilter/profile",
            "data": {
                "name": "XX-egress",
                "extended-log": "disable",
                "feature-set": "flow",
                "web": {
                  "urlfilter-table": "1"
                }
            }
        }
    ]
}
JSON
}

Thanks, Xing

lix-fortinet commented 2 years ago

Hi @pedrojgsbraga,

This issue has been fixed in the latest release of FortiManager Terraform provider v1.5.0. Please switch to the latest version of FortiManager Terraform provider and try it again.

Please let me know if you have any questions.

Thanks, Xing

MaxxLiu22 commented 1 year ago

I will go ahead to close this case, if you still have questions, feel free to reopen it or another case.