Due to a limitation arising from differences between the CloudControl model and the Terraform life-cycle model, additional network adapters in a server are currently modelled as separate resources (see previous discussion relating to this change in #33 and #52). This is inelegant and unintuitive.
Now, however, I've worked out a way that we can do better :)
We now have the ability to match up network adapters by index (ddcloud_server.network_adapter is a List instead of a Set).
So for the simplest (default) case, you'd have something like:
resource "ddcloud_server" "server1" {
name = "server1"
# ...
# Equivalent to primary_adapter_ipv4 = "10.0.12.30"
#
# This works because the default value for the index property is 0 (i.e. the primary adapter).
network_adapter {
ipv4 = "10.0.12.30"
}
}
Or with multiple adapters:
resource "ddcloud_server" "server1" {
name = "server1"
# ...
# Equivalent to primary_adapter_ipv4 = "10.0.12.30"
network_adapter {
ipv4 = "10.0.12.30"
}
# Equivalent to ddcloud_server_nic
network_adapter {
vlan = "${var.vlan_id}"
type = "VMXNET3"
}
# Equivalent to ddcloud_server_nic
network_adapter {
ipv4 = "10.1.17.10"
type = "E1000"
}
}
Note that the adapters must appear in the same order that they appear in CloudControl (with the primary network adapter being first, at index 0).
When we create each network adapter, we can store a calculated id property on it representing the adapter Id from CloudControl. This Id allows us to match up the adapter state with information returned by CloudControl.
Implements #56.
Due to a limitation arising from differences between the CloudControl model and the Terraform life-cycle model, additional network adapters in a server are currently modelled as separate resources (see previous discussion relating to this change in #33 and #52). This is inelegant and unintuitive.
Now, however, I've worked out a way that we can do better :)
We now have the ability to match up network adapters by index (
ddcloud_server.network_adapter
is a List instead of a Set).So for the simplest (default) case, you'd have something like:
Or with multiple adapters:
Note that the adapters must appear in the same order that they appear in CloudControl (with the primary network adapter being first, at index 0).
When we create each network adapter, we can store a calculated
id
property on it representing the adapter Id from CloudControl. This Id allows us to match up the adapter state with information returned by CloudControl.