fortinetdev / terraform-provider-fortios

Terraform Fortios provider
https://www.terraform.io/docs/providers/fortios/
Mozilla Public License 2.0
67 stars 49 forks source link

Terraform cannot import rules in fortios_router_prefixlist #261

Open fungy01 opened 1 year ago

fungy01 commented 1 year ago

I tried to use the following command to import fortios_router_prefixlist to my Terraform state. It only imported the prefixlist with the name and id but not the rule block within the prefixlist. "ID_10" is the name of the prefixlist.

terraform import fortios_router_prefixlist.pl_10 ID_10

$ terraform state show fortios_router_prefixlist.pl_10

fortios_router_prefixlist.pl_10:

resource "fortios_router_prefixlist" "pl_10" { id = "ID_10" name = "ID_10" }

MaxxLiu22 commented 1 year ago

Hi @fungy01 ,

Thank you for raising this issue. May I know which FGT and terraform version are you using, since on my side, it works as expected.

Thanks, Maxx

trrogi commented 1 year ago

Hi @MaxxLiu22 , i have same problem with importing prefixlists and route-maps. Using FTG v7.2.4, terraform v1.4.2 and frotios provider v1.16.0

MaxxLiu22 commented 3 months ago

Hi all,

Could you please try setting export "FORTIOS_IMPORT_TABLE"="true" before running terraform import? This should import the block into the state file.

root@liang:~/iac/demo_test/Terraform_env/FGT/terraform# export "FORTIOS_IMPORT_TABLE"="true"
root@liang:~/iac/demo_test/Terraform_env/FGT/terraform# terraform import fortios_router_prefixlist.pl_10 1
fortios_router_prefixlist.pl_10: Importing from ID "1"...
fortios_router_prefixlist.pl_10: Import prepared!
  Prepared fortios_router_prefixlist for import
fortios_router_prefixlist.pl_10: Refreshing state... [id=1]

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

root@liang:~/iac/demo_test/Terraform_env/FGT/terraform# terraform state show fortios_router_prefixlist.pl_10
# fortios_router_prefixlist.pl_10:
resource "fortios_router_prefixlist" "pl_10" {
    id   = "1"
    name = "1"

    rule {
        action = "permit"
        flags  = 0
        ge     = 0
        id     = 1
        le     = 0
        prefix = "0.0.0.0 0.0.0.0"
    }
}
root@liang:~/iac/demo_test/Terraform_env/FGT/terraform# 

Thanks, Maxx