Skip to content

Commit 8d6f803

Browse files
authored
Add support for Google Cloud metadata (labels) (#190)
1 parent 6b00382 commit 8d6f803

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

iterative/gcp/provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
3333
instanceHddSize := int64(d.Get("instance_hdd_size").(int))
3434
instancePublicSshKey := fmt.Sprintf("%s:%s %s\n", "ubuntu", strings.TrimSpace(d.Get("ssh_public").(string)), "ubuntu")
3535

36+
instanceMetadata := map[string]string{}
37+
for key, value := range d.Get("metadata").(map[string]interface{}) {
38+
instanceMetadata[key] = value.(string)
39+
}
40+
3641
instanceIsPreemptible := d.Get("spot").(bool)
3742
if d.Get("spot_price").(float64) != -1 {
3843
return errors.New("Google Cloud preemptible instances don't have a bidding price!")
@@ -220,6 +225,7 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
220225
OnHostMaintenance: instanceHostMaintenanceBehavior,
221226
Preemptible: instanceIsPreemptible,
222227
},
228+
Labels: instanceMetadata,
223229
Metadata: &gcp_compute.Metadata{
224230
Items: []*gcp_compute.MetadataItems{
225231
{

0 commit comments

Comments
 (0)