_This issue was originally opened by @FransUrbo as hashicorp/terraform#14072. It was migrated here as part of the provider split. The original body of the issue is below._
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:
Any update for this issue? I seem to run into it.
I'm still facing this issue on below versions.
terraform 0.11.1
aws-provider 1.5.0
Edit: I will take a look if this is easy to modify/fix.
Edit 2: I took a stab at reordering Removal and Addition for elb resource. The new problem is that now I get an error regarding Multiple Subnets in same AZ.
Failure adding ELB subnets: InvalidConfigurationRequest: ELB cannot be attached to multiple subnets in the same AZ.
This still happens on the following versions:
terraform 0.11.6
aws-provider 1.20.0
Still happens for me too with last version
Same error:
* aws_elb.my-elb: Failure removing ELB subnets: InvalidConfigurationRequest: Requested configuration change for LoadBalancer "my-elb" is invalid because you attempted to detach all the subnets for this LoadBalancer and a LoadBalancer cannot be attached to zero subnets in VPC.
for terraform v0.11.11 and provider.aws v1.56.0.
Is it that difficult to remove and attach the subnets one-by-one?
I don't expect this will happen to me often, but wouldn't the solution here be to switch Terraform from modifying the ELB to making this a "force replace" scenario?
Another thread recommended just deleting the ELBs in the console and re-running terraform, which seems like a good workaround here.
Another thread recommended just deleting the ELBs in the console and re-running terraform, which seems like a good workaround here.
That sounds like downtime to me. Given that you can change subnets in console without causing any downtime, this seems like an unacceptable workaround.
Fair enough, my situation was moving the ELB from private to public, I wasn't considering that many are likely just switching the same type of subnet. In any case I'd rather have terraform orchestrate this move.
Most helpful comment
This still happens on the following versions:
terraform 0.11.6
aws-provider 1.20.0