Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Deployment manager Disk DeviceName not working

Hello
I have the following template for deployment manager, as highlighted, I set a custom name for the disk tat will created for the instance called 'the-first-vm', this is how it is done using the dashboard, you edit the 'Device Name' field on disk section

a5cb68cd-f727-417d-89fc-619aae5cc94d.png

 

however after deploying the stack with the following command:

$ gcloud deployment-manager deployments create teststack2 --config gcp-template.yml

the disk name is not testdisk but 'my-first-vm', so it just followed the instance name and did not take into account the name I told it to use in the template, see the picture below

Screenshot from 2024-05-19 11-02-58.png

Has anyone encountered this or knows how to solve it? We have 'enhanced support' gcp support plan, but they refuse to help on this.

1 12 484
12 REPLIES 12

Hello @Developer31  ,Welcome on Google Cloud Community.

resources:
- name: vm-created-by-deployment-manager
  type: compute.v1.instance
  properties:
    zone: us-central1-a
    machineType: zones/us-central1-a/machineTypes/n1-standard-1
    disks:
    - deviceName: my-test
      type: PERSISTENT
      boot: true
      autoDelete: true
      initializeParams:
        sourceImage: projects/debian-cloud/global/images/family/debian-11
    networkInterfaces:
    - network: global/networks/default

 

Code pasted above will work. Additionally I have also code written in JINJA scheme. 

--
cheers,
DamianS
LinkedIn medium.com Cloudskillsboost 

Hi @DamianS 
Can you please tell what's the difference between your template and mine that is showed on the first screenshot ? because i don't see any 

Hello @Developer31 ,

Well, funny thing is that me either xd. I'm shooting that indentations only.
--
cheers,
DamianS
LinkedIn medium.com Cloudskillsboost

Hello Again @DamianS 

Thanks for your reply,
I gave your template a try and still the disk name did not follow what's mentioned on the template, it took the instance's name as the disk name

Screenshot 2024-06-10 163640.png

It works. However, it changing name "device name" 
You can use this name to reference the device for mounting, resizing, and so on, from within the instance. By default, the device name is autogenerated based on the disk name. You can also choose to enter a custom name."

resources:
- name: vm-created-by-deployment-manager
  type: compute.v1.instance
  properties:
    zone: us-central1-a
    machineType: zones/us-central1-a/machineTypes/n1-standard-1
    disks:
    - deviceName: community-disk
      type: PERSISTENT
      boot: true
      autoDelete: true
      initializeParams:
        sourceImage: projects/debian-cloud/global/images/family/debian-11
    networkInterfaces:
    - network: global/networks/default



DamianS_0-1718039985394.png

Screenshot taken from VM settings. 

--
cheers,
DamianS
LinkedIn medium.com Cloudskillsboost

Thank you !
so there is not a way to change 'Name' and not 'Device name' ?

My problem is since the disk 'Name' field always takes the instance's name as its name, I can not recreate an instance with the same name, despite changing the old instance's name first.

example for more clarity:
t1 -> creating instance test1 | disk name will be test1
t2 -> changing name of t1 time instance test1 to test2, then creating new instance test1 | its disk name will also be test1, so stack creation will fail telling that disk named 'test1' already exists.

I don't understand why GCP is over-complicating things.

Okay,
I'm dumb xd. You can :

1. Create disk and name it as you want
2. Create VM with boot-disk named boot ( default ) and attach your newly created disk into this VM.

resources:
- type: compute.v1.disk
  name: attached-this-disk
  properties:
    name: my-data-attached
    sizeGb: 100
    zone: us-central1-a

- type: compute.v1.instance
  name: my-vm-with-disk
  properties:
    name: my-vm-with-disk
    machineType: zones/us-central1-a/machineTypes/n1-standard-1
    zone: us-central1-a
    disks:
      - deviceName: boot
        boot: true
        autoDelete: true
        type: PERSISTENT
        initializeParams:
          sourceImage: projects/debian-cloud/global/images/family/debian-11
      - source: zones/us-central1-a/disks/attached-this-disk
        boot: false
        autoDelete: true
        mode: READ_WRITE
        type: PERSISTENT
    networkInterfaces:
      - network: global/networks/default

DamianS_0-1718097754820.png

--
cheers,
DamianS
LinkedIn medium.com Cloudskillsboost

DamianS, thank you very much for your solution and for the time your took to help me!

Happy to help 😄 

Btw, if problem is solved, please mark best reply as solution 🙂 

--
cheers,
DamianS
LinkedIn medium.com Cloudskillsboost

Unfortunately it does not, you were kind enough to try to help me but the problem is not resolved and it seems it will never be resolved.
You are creating a second disk, but there's still a disk that is named exactly as the instance name, so creating another instance with the same name will still result in 'disk <instance-name> already exists' error.

Well this is how IaaC works 🙂 afair, DM does not have option to import resources like terraform.

If you want to manage VM and disk from one deployment, you must either
1.  add disk resource definition to yaml file which you've used for first deployment
2. modify code and adjust VM configuration to attach new disk
3. use gcloud update DEPLOYMENT_NAME --config UPDATED_CONFIG.YML

or

2. remove entire deployment and create new one, under where you will spawn both VM and disk. 

You can check your deployments by searching for Deployment Manager

Please see output from shell:

damian_sztankowski@cloudshell:~$ gcloud deployment-manager deployments create linux-test --config blank.yml --project webaap-wordpress-load
The fingerprint of the deployment is b'LEfhcKsuEGD08cGT0c4xUw=='
Waiting for create [operation-1718116199451-61a9e19c04ad6-2a5f9da5-bb8b4c4f]...done.                                                                                                   
Create operation operation-1718116199451-61a9e19c04ad6-2a5f9da5-bb8b4c4f completed successfully.
NAME: linux
TYPE: compute.v1.instance
STATE: COMPLETED
ERRORS: []
INTENT: 
damian_sztankowski@cloudshell:~$ gcloud deployment-manager deployments update linux-test --config linux.yml --project webaap-wordpress-load
The fingerprint of the deployment is b'reyOT81sO23lLgUoeDepHg=='
Waiting for update [operation-1718116310989-61a9e20663bec-f0c147d1-010bd728]...done.                                                                                                   
Update operation operation-1718116310989-61a9e20663bec-f0c147d1-010bd728 completed successfully.
NAME: linux
TYPE: compute.v1.instance
STATE: COMPLETED
ERRORS: []
INTENT: 

NAME: linux-data
TYPE: compute.v1.disk
STATE: COMPLETED
ERRORS: []
INTENT: 

Please note, that during this update I was able to operate with VM without any errors

DamianS_0-1718116476157.png

 


--
cheers,
DamianS
LinkedIn medium.com Cloudskillsboost