From 9d8546d8f8b4a22bc6373b01724efcc1fffb3c8a Mon Sep 17 00:00:00 2001 From: Frank Shen Date: Mon, 19 Oct 2020 21:23:24 +0800 Subject: [PATCH] Support the configuration of the interfaces automatically created by FGT #97 --- fortios/resource_system_interface.go | 22 ++++++++++++++----- .../r/fortios_system_interface.html.markdown | 1 + 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fortios/resource_system_interface.go b/fortios/resource_system_interface.go index a2ac4d73a..036b3fe57 100644 --- a/fortios/resource_system_interface.go +++ b/fortios/resource_system_interface.go @@ -29,6 +29,11 @@ func resourceSystemInterface() *schema.Resource { }, Schema: map[string]*schema.Schema{ + "autogenerated": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, "name": &schema.Schema{ Type: schema.TypeString, ValidateFunc: validation.StringLenBetween(0, 15), @@ -1498,7 +1503,8 @@ func resourceSystemInterfaceCreate(d *schema.ResourceData, m interface{}) error var o map[string]interface{} v, _ := d.GetOk("type") - if v == "physical" { + ag, _ := d.GetOk("autogenerated") + if v == "physical" || ag == "auto" { o, err = c.UpdateSystemInterface(obj, (*obj)["name"].(string)) } else { o, err = c.CreateSystemInterface(obj) @@ -1549,11 +1555,15 @@ func resourceSystemInterfaceDelete(d *schema.ResourceData, m interface{}) error c.Retries = 1 v, _ := d.GetOk("type") - if v != "physical" { - err := c.DeleteSystemInterface(mkey) - if err != nil { - return fmt.Errorf("Error deleting SystemInterface resource: %v", err) - } + ag, _ := d.GetOk("autogenerated") + if v == "physical" || ag == "auto" { + d.SetId("") + return nil + } + + err := c.DeleteSystemInterface(mkey) + if err != nil { + return fmt.Errorf("Error deleting SystemInterface resource: %v", err) } d.SetId("") diff --git a/website/docs/r/fortios_system_interface.html.markdown b/website/docs/r/fortios_system_interface.html.markdown index 89a292408..e237e3813 100644 --- a/website/docs/r/fortios_system_interface.html.markdown +++ b/website/docs/r/fortios_system_interface.html.markdown @@ -205,6 +205,7 @@ The following arguments are supported: * `color` - Color of icon on the GUI. * `tagging` - Config object tagging. * `ipv6` - IPv6 of interface. +* `autogenerated` - Indicates whether the interface is automatically created by FortiGate, for example, created during the VPN creation process. If it is, set it to "auto", else keep it empty. The `fail_alert_interfaces` block supports: