GCP Deployment Manager: where to find a reference guide to properly create YAML config and template files?

I started working with Google Cloud Deployment Manager upon request of a client, using YAML config files, but I can't find anywhere how to map the reference shown in https://cloud.google.com/deployment-manager/docs/configuration/supported-resource-types to what I'm actually using.

Particularly, I need to attach an existent external elastic IP to an instance at creation time, but I can't find anywhere what is the config file schema to do so (i.e. like with eksctl config file schema documentation found at https://eksctl.io/usage/schema/):

resources:
- type: compute.v1.instance
  name: nextcloud-vm
  properties:
    natIP: nextcloud-vm
    # The properties of the resource depend on the type of resource. For a list
    # of properties, see the API reference for the resource.
    zone: us-west1-a
    # Replace martin-dev-391362 with your project ID
    machineType: https://www.googleapis.com/compute/v1/projects/martin-dev-391362/zones/us-west1-a/machineTypes/n2-standard-4
    disks:
    - deviceName: boot
      type: PERSISTENT
      boot: true
      autoDelete: true
      initializeParams:
        # See a full list of image families at https://cloud.google.com/compute/docs/images#os-compute-support
        # The format of the sourceImage URL is: https://www.googleapis.com/compute/v1/projects/[IMAGE_PROJECT]/global/images/family/[FAMILY_NAME]
        sourceImage: https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/family/ubuntu-2004-lts
        diskSizeGb: 20
    # Replace martin-dev-391362 with your project ID
    networkInterfaces:
    - network: https://www.googleapis.com/compute/v1/projects/martin-dev-391362/global/networks/default
      # Access Config required to give the instance a public IP address
      accessConfigs:
      - name: nextcloud-vm
        type: ONE_TO_ONE_NAT

The above code doesn't work because it tries to create a new IP address with that name instead of using the already existing elastic IP address. Thing is I can't find anywhere what is the correct notation :)

I'd really appreciate if anybody can point me to the right direction because solving this very little issue is just the tip of the iceberg, as I will be working a lot with Deployment Manager and thus I need to get the complete picture on how to work with it.


Solution 1:

You can follow the yaml below as reference and just replace mystatic with the name of your reserved External IP on VPC Network. But when you delete your deployment, it will also delete your Static IP as part of the deployment.

resources:
- name: mystatic
  type: compute.v1.address
  properties:
    region: us-central1
  
- 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: boot
      type: PERSISTENT
      boot: true
      autoDelete: true
      initializeParams:
        sourceImage: projects/debian-cloud/global/images/family/debian-10
    networkInterfaces:
    - network: global/networks/default
      accessConfigs:
      - name: External NAT
        type: ONE_TO_ONE_NAT
        natIP: $(ref.mystatic.address)

You'd want to check out the Compute API Reference for a list of properties you can use on your use case.