I'm converting a ELB to be an external (internal = false) one. That was done in a previous run, but I also realised I need to put it on the/a public network.
So changing the subnet doesn't seem to work.
0.9.1
From
subnets = [ # One per AZ
"${aws_subnet.vpc_subnet_0.id}"
"${aws_subnet.vpc_subnet_1.id}"
"${aws_subnet.vpc_subnet_2.id}"
]
to
subnets = [
"${aws_subnet.vpc_subnet_public.id}"
]
Gives me:
module.mymodule.aws_elb.myelb: Modifying... (ID: myelb)
subnets.#: "3" => "1"
subnets.12345678902: "subnet-abcdefghi" => ""
subnets.23456789012: "subnet-bcdefghij" => ""
subnets.34567890123: "subnet-cdefghijk" => ""
subnets.45678901234: "" => "subnet-defghijkl"
Error applying plan:
1 error(s) occurred:
* module.mymodule.aws_elb.myelb: 1 error(s) occurred:
* aws_elb.myelb: Failure removing ELB subnets: InvalidConfigurationRequest: Requested configuration change for LoadBalancer "myelb" is invalid because you attempted to detach all the subnets for this LoadBalancer and a LoadBalancer cannot be attached to zero subnets in VPC.
status code: 409, request id: adeeeb86-2c0e-11e7-93ae-92361f002671
ELB subnet should be created without failing. ALTERNATIVELY (?) destroyed and created again with the new settings.
TF error out.
Please list the steps required to reproduce the issue, for example:
Hey @FransUrbo – Terraform is trying to remove all subnets and then add new ones. The closest test we have for this doesn't remove all of them, so I don't suppose we've hit this error before :( We'll add a regression test for that.
A workaround would be to do this in 2 steps:
Or any combination of steps that doesn't result in the ELB having zero subnets.
Unfortunately it's not as easy as swapping the code to add subnets new first and then remove the old ones; ELB won't allow users to add more than one subnet in an AZ. I imagine we can work this out with a call to DescribeSubnets and logic to determine if we'd be violating either rule and deciding how to proceed then, but that would be a bit of work and I can't promise it to come this week or next :/
I'm still in a build phase, so it was just simpler to delete the ELB in the Console and then re-run TF.
But the workaround looks decent enough. Update the docs until a correct solution can be found?
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.