You mentioned keeping this compatible with Terraform v0.11. That’s not always possible because v0.12 fixed a number of bugs in v0.11 which, prior to v0.12, required odd workarounds.
This is possibly one of those situations: setting an argument that expects a list to be a list of lists instead was a somewhat-common workaround for a bug in the provider SDK where it would fail if given a list whose length or contents aren’t known until apply time, incorrectly reporting “a list is required”. Making it a list of lists ended up being an accidental workaround for that by relying on an old backward-compatibility behavior introduced in Terraform v0.7, to support configurations that predated Terraform having a first-class list type, but we removed that legacy behavior in Terraform v0.12 along with adding a workaround for the aforementioned SDK bug the workaround was for.
With all of that said, you could try writing the following to perhaps get a cross-compatible module:
addresses = "${module.company_db.instances_ips}"
More modern versions of Terraform will produce a warning with the above to point out that it’s deprecated syntax, but the current version of Terraform as I write this (v0.14) will still accept this as valid in spite of the warning.
The trick will be whether Terraform v0.11 (or, more accurately, the Terraform SDK without the workaround that Terraform v0.12 introduced) can accept it. This will depend on whether this instances_ips
value is known at plan time or not. Given the name of it I’m betting it’s a list of IP addresses decided by the remote system, in which case it probably wouldn’t be known at plan time unless those instances happen to already be created. If they aren’t already present, the DNS provider might incorrectly report “a list is required” for that addresses
argument.
If you only need v0.11 compatibility briefly during a transition, the above might be acceptable with an additional workaround: as long as the instances whose IP addresses you are using already exist when you run terraform plan
this will likely work without any special tricks. But if you do end up needing to replace any of those instances or create new ones while you’re still on v0.11 you may see the error and need to work around it by running Terraform once with the -target
option to tell Terraform to create the instances first, without also trying to create the record sets:
terraform apply -target=module.company_db
I hope this helps! The v0.11 knowledge is getting harder to recall now because it’s been some years so I might’ve got some details wrong here but hopefully it’s close enough to get something working. If you run into trouble then feel free to ask follow-up questions; I can’t promise I’ll be able to answer them promptly myself, but someone else in the forum might know the answer.