terraform-provider-fortios icon indicating copy to clipboard operation
terraform-provider-fortios copied to clipboard

Feature Request: Foritos provider can't be configured with an alternative port

Open carinadigital opened this issue 5 years ago • 1 comments

I don't have direct connections to the Fortigates to use the REST API. I have to port forward through SSH. Ideally I'd not like to do this on a local privileged port (443), e.g.

ssh -L 9443:<fortigate ip>:443 ssh-bastion-jump-box

Ideally, I'd like provider config and environment variable to use a different port but still default to 443 if not specified. An altered example from your documentation at https://registry.terraform.io/providers/fortinetdev/fortios/latest/docs is below.

provider "fortios" { hostname = "192.168.52.177" port = "9443" token = "jn3t3Nw7qckQzt955Htkfj5hwQ6jdb" insecure = "false" cabundlefile = "/path/yourCA.crt" }

carinadigital avatar Aug 04 '20 11:08 carinadigital

Hi @carinadigital , can you please try with:

provider "fortios" {
  hostname = "192.168.52.177:9443"
  token    = "wjcpq40s5ctH5gtsk0r0Gr7mrHnzdm"
  insecure = "true"
}

Validation:

# cat main.tf
provider "fortios" {
  hostname = "192.168.52.177:9443"
  token    = "wjcpq40s5ctH5gtsk0r0Gr7mrHnzdm"
  insecure = "true"
}

resource "fortios_firewall_object_address" "s1" {
  name     = "s1"
  type     = "iprange"
  start_ip = "1.0.0.0"
  end_ip   = "2.0.0.0"
  comment  = "dd"
}

# terraform plan
.....
Terraform will perform the following actions:

  # fortios_firewall_object_address.s1 will be created
  + resource "fortios_firewall_object_address" "s1" {
      + associated_interface   = (known after apply)
      + comment                = "dd"
      + country                = (known after apply)
      + end_ip                 = "2.0.0.0"
      + fqdn                   = (known after apply)
      + id                     = (known after apply)
      + name                   = "s1"
      + show_in_address_list   = (known after apply)
      + start_ip               = "1.0.0.0"
      + static_route_configure = (known after apply)
      + subnet                 = (known after apply)
      + type                   = "iprange"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
.....

# terraform apply
2020/08/06 02:27:44 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
  Use TF_LOG=TRACE to see Terraform's internal logs.
  ----

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # fortios_firewall_object_address.s1 will be created
  + resource "fortios_firewall_object_address" "s1" {
      + associated_interface   = (known after apply)
      + comment                = "dd"
      + country                = (known after apply)
      + end_ip                 = "2.0.0.0"
      + fqdn                   = (known after apply)
      + id                     = (known after apply)
      + name                   = "s1"
      + show_in_address_list   = (known after apply)
      + start_ip               = "1.0.0.0"
      + static_route_configure = (known after apply)
      + subnet                 = (known after apply)
      + type                   = "iprange"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

fortios_firewall_object_address.s1: Creating...
fortios_firewall_object_address.s1: Creation complete after 0s [id=s1]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Thanks

frankshen01 avatar Aug 05 '20 18:08 frankshen01

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

MaxxLiu22 avatar Jul 07 '23 20:07 MaxxLiu22