How to update dependent resources with terraform in one step?

  Kiến thức lập trình

I am currently using terraform to create and manage resources in aws. In my application there are two environments dev and prod. First I test whatever changes are required in dev and if everything is fine then I deploy to prod. The delivery is release based.

One scenario I found difficult to manage at the time of prod deployment with terraform. Imagine there is an aws resource A which has a reference of B. Now if I need to update any property of B and for that if terraform needs to delete the B resource and re-create that then I need to do the deployment in multiple steps. First I need to remove the B reference from A then update the property of B and then add the B reference to A again.

This is not a problem at the time of deployment in dev because I can deploy multiple times in dev but on the release day at the time of prod deployment I need to do the deployment in one step.

How to do the deployment in this case in one step in prod with terraform?

LEAVE A COMMENT