How to first update dependency and then delete an old object

I am not sure I can think of an elegant solution to this, other than a procedural one which would involve two runs. This Blue/Green approach is actually how we manage our internal infra.

  • You first add the new resource to your config, updating any references but leaving the resource which is going to be replaced in the config and run Terraform apply
  • You can then test that the new setup works and is running correctly
  • If all is OK, then you remove the old resource from your configuration and again run Terraform apply

First run:
Create C
Update A

Second Run:
Destroy B