0

To figure out how deployment manager behaves when we have same resource name in different deployment I did following steps:

  1. I create a deployment named dep-1 with single VM named vm1.
  2. Then I created a a deployment named dep-2 with same VM named vm1.

I was thinking that dep-2 will fail saying a resource already exist with same name but it succeeded without any warning/error.

Later when I deleted dep-2 it deleted the vm resource named vm-1.

Now I want to know how to deal with this behavior. Say I want to deploy my environment for dev, qa and prod. What is the best practice to do it in GCP deployment manager?

Neeraj Kumar
  • 836
  • 1
  • 10
  • 29

2 Answers2

0

I assume you used the same yaml file for both deployments (same instance name and same zone).

  • The first deployment created the instance, as expected without issues.
  • The second deployment didn't create another instance, just assign the same instance to this deployment. This is why you see the instance deleted when removing the deployment dep-2.

To see the errors you can go to Stackdriver Logging page for you project. and filter the log for instances creation.

cryotek
  • 508
  • 2
  • 9
0

This link documents the deployment manager update policy. The above mentioned behavior in question is expected.

https://cloud.google.com/deployment-manager/docs/deployments/updating-deployments#prepare_your_update

https://cloud.google.com/deployment-manager/docs/deployments/updating-deployments#optional_determine_the_policies_to_use_for_the_update

(Optional) Determine the policies to use for the update

  • The default policy for adding resources is CREATE_OR_ACQUIRE.
  • The default policy for removing resources is DELETE.
  • The default policy for updating resources is UPDATE.
Neeraj Kumar
  • 836
  • 1
  • 10
  • 29