I am trying to programmatically replace VMs in my instance group. This gcloud commandline run within the cloud shell successfully replaces the instances:
gcloud compute instance-groups managed rolling-action start-update INSTANCE_GROUP_NAME --version=template=TEMPLATE_NAME --zone=ZONE --type='proactive' --max-surge=1 --max-unavailable=0 --minimal-action='replace' --most-disruptive-allowed-action='replace' --replacement-method='substitute'
However, the equivalent node code logs as a successful patch operation (just like the gcloud command does) but the VMs never are replaced (ie nothing happens to my VMs):
const { InstanceGroupManagersClient } = require('@google-cloud/compute');
const instanceGroupManagerResource = {
versions: [ {
instanceTemplate: "global/instanceTemplates/TEMPLATE_NAME"
} ],
updatePolicy: {
type: 'PROACTIVE',
minimalAction: 'REPLACE',
mostDisruptiveAllowedAction: 'REPLACE',
maxSurge: {
fixed: 1 // Number of additional instances that can be created during the update
},
maxUnavailable: {
fixed: 0 // Number of instances that can be unavailable during the update
},
replacementMethod: 'SUBSTITUTE' // Method for instance replacement
}
};
// Perform the patch operation
const [operation] = await instanceGroupManagersClient.patch({
project: project,
zone: zone,
instanceGroupManager: instanceGroupManager,
instanceGroupManagerResource: instanceGroupManagerResource,
});
I've tried a ton of different variations here, but nothing has worked. Here's the best resource from google I could find: https://cloud.google.com/compute/docs/instance-groups/rolling-out-updates-to-managed-instance-groups#replacement_method
Can someone help?