terraform-provider-fortios
terraform-provider-fortios copied to clipboard
virtual-switch resource creates system-interface that cannot be configured
I have the following resources:
resource "fortios_system_virtualswitch" "my_vsw" {
name = "bms"
physical_switch = "sw0"
span = "disable"
vlan = 0
port {
name = "internal2"
}
port {
name = "internal3"
}
}
resource "fortios_system_interface" "my_vsw" {
name = "my_vsw"
vdom = "root"
ip = "10.0.1.1 255.255.255.0"
allowaccess = "ping ssh snmp fgfm"
role = "lan"
stp = "enable"
}
When creating the virtual switch my_vsw the fortios will also create the my_vsw system-interface my_vsw. Becasue this newly created system interface is not managed by terraform (it is not in the terraform state file) the fortios_system_interface.my_vsw resource will fail because terraform wants to create (POST) the object instead of update (PUT) the object.
I have tried to first create the system interface my_vsw, but I cannot produce an object equal to the object created by the virtual-switch.
Hi @mdekoster,
Thank you very much for your question. I’d like to suggest using the autogenerated parameter, which can assist in automatically importing the FortiOS auto-generated interface into your Terraform configuration for streamlined management. Please feel free to let me know if this does not fully address your question.
resource "fortios_system_interface" "my_vsw" {
name = "my_vsw"
vdom = "root"
ip = "10.0.1.1 255.255.255.0"
allowaccess = "ping ssh snmp fgfm"
role = "lan"
stp = "enable"
autogenerated = "auto"
}
Let me know if this works for you, or if there’s anything further I can assist with!
Thanks, Maxx
Hi @MaxxLiu22,
Thanks you for pointing me to this attribute. That did the trick. I over read the attribute in the documentation.