DimensionDataResearch / terraform-provider-ddcloud

Terraform provider for Dimension Data cloud compute.
MIT License
16 stars 13 forks source link

Deploying ddcloud_vlan in different ddcloud_networkdomain #59

Closed mingsheng36 closed 7 years ago

mingsheng36 commented 7 years ago

When deploying multiple vlans in different network domains, the VLANs will not deploy in sequence and will have errors like below.

* ddcloud_vlan.dmz_vlan_2: Request to deploy VLAN 'Public' failed with status code 400 (RESOURCE_BUSY): Another deploy or delete Network or VLAN operation for your organization (e2c43
389-90de-4498-b7d0-056e8db0b381) is in progress. Please try again later.

Understand that it could be solve by using "depends_on" field as only one VLAN can be deployed at any point of time for a DimensionData MCP account, but the code would not look nice.

Is it possible to queue up the VLANs deployment for multiple network domains like how it will behave in VLAN deployment in a single network domain? e.g.

resource "ddcloud_vlan" "dmz_vlan_1" {
  networkdomain = "${ddcloud_networkdomain.nd_1.id}"
  name = "Public"
  description = "Public Network"
  ipv4_base_address = "10.0.2.0"
  ipv4_prefix_size = 24
  //  ipv6_base_address = <computed>
  //  ipv6_prefix_size = <computed>
  depends_on = [
    "ddcloud_networkdomain.nd_1"
  ]
}

resource "ddcloud_vlan" "dmz_vlan_2" {
  networkdomain = "${ddcloud_networkdomain.nd_2.id}"
  name = "Public"
  description = "Public Network"
  ipv4_base_address = "10.0.0.0"
  ipv4_prefix_size = 16
  //  ipv6_base_address = <computed>
  //  ipv6_prefix_size = <computed>
  depends_on = [
    "ddcloud_networkdomain.nd_2",
  ]
}
tintoy commented 7 years ago

Hi.

The short answer is no, unfortunately - it's a deliberate design decision in Terraform that providers are not given the option to control the ordering of resources (that's a choice made purely by Terraform) because otherwise it would be hard to make them play nicely together in mixed configurations (e.g. server in CloudControl, DNS in Azure). You'd also run into this problem if someone else in your organisation was running their own Terraform deployment with VLANs at the same time as you were (something we couldn't fix by messing with ordering at the provider level).

For now, unfortunately, you'll need to have one VLAN depend on another. I know it's a little ugly but once you've worked with Terraform for a while you'll yourself setting up explicit dependencies every now and then because a lot of providers are like this (their back-ends often have similar constraints).

It's not all bad though 😃

We can automatically retry operations (in some circumstances) if CloudControl returns RESOURCE_BUSY. This has been on the backlog for a while as #11 but I've not had time to look at it properly yet. I'll try to have a look again in a week or 2 depending on what other work I have on, so it'll get done eventually :)

tintoy commented 7 years ago

I'm closing this as a duplicate of #11, but feel free to add any other notes you may have to this issue (or #11).