Skip to main content

dtcloud_router (Data Source)

Looks up one router by ID.

Example Usage​

# Lookup is by id. Use this for a router Terraform did not create -- declaring it
# as a resource would hand Terraform ownership, and a later destroy would take
# down everything behind it.
data "dtcloud_router" "edge" {
id = "3f2a1c9e-77b4-4a01-9d3e-2b6c81f4e5a7"
}

# Attach a network to a router somebody else manages.
resource "dtcloud_router_interface" "app" {
router_id = data.dtcloud_router.edge.id
network_id = dtcloud_network.app.id
}

output "gateway_addresses" {
value = [for ip in data.dtcloud_router.edge.external_fixed_ip : ip.ip_address]
}

Schema​

Required​

  • id (String) ID of the router to look up.

Read-Only​

  • admin_state_up (Boolean) Whether the router is administratively enabled.
  • created_at (String) When the router was created, as the platform reports it.
  • description (String) Description held by the platform. There is no way to set one through this API, so it is reported but not managed.
  • enable_snat (Boolean) Whether the gateway masquerades traffic from the networks behind it.
  • external_fixed_ip (List of Object) Addresses the external network allocated to the gateway. The create endpoint always asks for IPv4 and never accepts a specific address, so these are read-only. (see below for nested schema)
  • external_network_id (String) ID of the external network the router's gateway is on. Empty if the gateway was removed outside Terraform.
  • name (String) Name of the router.
  • project_id (String) ID of the project the router belongs to.
  • status (String) Status reported by the platform. ACTIVE is the resting state.
  • updated_at (String) When the router last changed.

Nested Schema for external_fixed_ip​

Read-Only:

  • ip_address (String)
  • subnet_id (String)

Behaviour worth knowing​

  • Use this for a router Terraform did not create -- attaching a network to it, or reading the address its gateway holds. Declaring such a router as a resource instead would hand Terraform ownership, and a later destroy would take down everything behind it.
  • This reports the external network by id, where dtcloud_routers reports it by name. The two read different endpoints and only this one is given the id.
  • A router that does not exist is an error, not an empty result.