5

Is there a way to automatically apply Labels to instances that are launched by a GCE Managed Instance Group (aka. Instance Group Manager)? I see that you can add Network Tags in the Instance Template (properties.tags), but I don’t see a way to add Labels for use in searching for labeled instances using instances/list.

A workaround would be to manually call setLabels on instances from the Instance Template’s startup-script.

In AWS EC2, the equivalent would be to add Tags to an AutoScalingGroup with PropagateAtLaunch: true.

yonran
  • 817
  • 2
  • 13
  • 22

2 Answers2

1

Automatically assigning Labels is available in the UI now: when editing an instance template, directly under the template's Name field you can expand "Manage Tags and Labels" and then add your labels in there.

(I know this question is several years old, but I've posted this for anyone arriving here from search, like I did)

cometfish
  • 113
1

Labels are currently a beta feature. You can use the following command to create Compute Engine instance template with labels for your managed instance groups:

gcloud beta compute instance-templates create NAME --labels=[KEY=VALUE,…]

Kamran
  • 1,425
  • 7
  • 17