Skip to main content

dtcloud_router_interface (Resource)

Attaches a private network to a router, which is what gives the machines on that network a route to everywhere else.

Example Usage​

resource "dtcloud_router_interface" "app" {
router_id = dtcloud_router.main.id
network_id = dtcloud_network.app.id
}

# With a chosen address rather than one the platform picks. This is also the only
# path on which port_security_enabled reaches the platform.
resource "dtcloud_router_interface" "db" {
router_id = dtcloud_router.main.id
network_id = dtcloud_network.db.id
ip_address = "10.0.20.1"
port_security_enabled = true
}
note

Nothing here changes in place. The platform has an attach endpoint and a detach endpoint and nothing in between, so every argument replaces the attachment.

Schema​

Required​

  • network_id (String) ID of the network to attach. Changing this forces a new resource to be created.
  • router_id (String) ID of the router to attach the network to. Changing this forces a new resource to be created.

Optional​

  • ip_address (String) Address the interface takes on the network. When omitted, the platform attaches to the network's first subnet and allocates an address from it. Changing this forces a new resource to be created.
  • port_security_enabled (Boolean) Whether port security applies to this interface. It only reaches the platform when ip_address is set; attaching without one goes through a path that does not take the setting. Changing this forces a new resource to be created.
  • timeouts (Block, Optional) (see below for nested schema)

Read-Only​

  • cidr (String) CIDR of the attached network's first subnet.
  • id (String) The ID of this resource.
  • network_name (String) Name of the attached network.
  • port_id (String) ID of the port the platform created for this interface.
  • status (String) Status of the interface's port.
  • subnet_id (String) ID of the subnet the interface's address came from.

Nested Schema for timeouts​

Optional:

  • create (String)
  • delete (String)

Behaviour worth knowing​

  • Without ip_address you land on the network's first subnet. Not one you name, and not all of them. Networks created by dtcloud_network have exactly one subnet, so this only matters on a network built elsewhere with several.
  • port_security_enabled applies only when ip_address is set. The two ways of attaching are different operations, not one operation with a field left out: asking for a specific address creates a port and applies port security to it, while letting the platform choose goes down a path that never looks at the setting. It is kept as an argument rather than silently ignored, because it does apply on the other path.
  • Security groups are not offered. A router interface is created without any and no endpoint adds them afterwards. They belong on the machines behind the router.
  • A static route through an interface pins it. The platform refuses to detach an interface while a route's next hop sits on the network behind it, so a router's routes have to be destroyed before its interfaces. Terraform only knows that if the configuration says so -- which route needs which interface is a routing decision the API does not report. Put a depends_on on every route that points through an interface you manage, or a destroy can stop with … cannot be deleted, as it is required by one or more routes. The same applies to any change that replaces the interface, such as setting ip_address on one that did not have it.
  • Destroying the router takes its interfaces with it. Terraform's graph already destroys these first, so this only shows up for something attached outside Terraform.

Timeouts​

create and delete each default to 10 minutes. Create does not return until the new port appears on the router: the attach endpoint answers with the router rather than the port it made, so the port id -- the only handle detaching has -- is found by watching the router's interface list.

Import​

# <router-id>:<port-id>. The port id is the `id` of the entry whose `type` is
# "Internal interface" in dtcloud_router_interfaces.
terraform import dtcloud_router_interface.app 3f2a1c9e-77b4-4a01-9d3e-2b6c81f4e5a7:8b41d0c6-5e29-4f77-a0d3-9c2e7b1a4f60

port_security_enabled is not recovered: nothing reports it back, so an import assumes the default, true. If the interface was attached with port security off, say so in the configuration before importing -- otherwise the value in state is wrong and nothing will tell you.