Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Deployment Manager: add instances to instance group via yaml configuration

I'm trying to create an unmanaged instanceGroup with several VM's in it via Deployment Manager Configuration (YAML file).

I can easily find docs about addInstances via Google API, but couldn't find docs about how to do this in a YAML file:

instances

instanceGroups

What properties should be included in instances/instanceGroup resource to make it work?

like image 765
KrHubert Avatar asked Mar 11 '23 14:03

KrHubert


1 Answers

The YAML below will create a compute engine instance, create an unmanaged instance group, and add the instance to the group.

resources:
- name: instance-1
  type: compute.v1.instance
  properties:
    zone: australia-southeast1-a
    machineType: zones/australia-southeast1-a/machineTypes/n1-standard-1
    disks:
    - deviceName: boot
      type: PERSISTENT
      diskType: zones/australia-southeast1-a/diskTypes/pd-ssd
      boot: true
      autoDelete: true
      initializeParams:
        sourceImage: projects/debian-cloud/global/images/debian-9-stretch-v20180716
    networkInterfaces:
    - network: global/networks/default
      accessConfigs:
      - name: External NAT
        type: ONE_TO_ONE_NAT

- name: ig-1
  type: compute.v1.instanceGroup
  properties:
    zone: australia-southeast1-a
    network: global/networks/default

- name: ig-1-members
  action: gcp-types/compute-v1:compute.instanceGroups.addInstances
  properties:
    project: YOUR_PROJECT_ID
    zone: australia-southeast1-a
    instanceGroup: ig-1
    instances: [ instance: $(ref.instance-1.selfLink) ]
like image 60
mcourtney Avatar answered Apr 27 '23 06:04

mcourtney