|
42 | 42 | "boot_disk.0.initialize_params.0.type",
|
43 | 43 | "boot_disk.0.initialize_params.0.image",
|
44 | 44 | "boot_disk.0.initialize_params.0.labels",
|
| 45 | + "boot_disk.0.initialize_params.0.resource_manager_tags", |
45 | 46 | }
|
46 | 47 |
|
47 | 48 | schedulingKeys = []string{
|
@@ -216,6 +217,14 @@ func ResourceComputeInstance() *schema.Resource {
|
216 | 217 | ForceNew: true,
|
217 | 218 | Description: `A set of key/value label pairs assigned to the disk.`,
|
218 | 219 | },
|
| 220 | + |
| 221 | + "resource_manager_tags": { |
| 222 | + Type: schema.TypeMap, |
| 223 | + Optional: true, |
| 224 | + AtLeastOneOf: initializeParamsKeys, |
| 225 | + ForceNew: true, |
| 226 | + Description: `A map of resource manager tags. Resource manager tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456. The field is ignored (both PUT & PATCH) when empty.`, |
| 227 | + }, |
219 | 228 | },
|
220 | 229 | },
|
221 | 230 | },
|
@@ -538,6 +547,25 @@ func ResourceComputeInstance() *schema.Resource {
|
538 | 547 | },
|
539 | 548 | },
|
540 | 549 |
|
| 550 | + "params": { |
| 551 | + Type: schema.TypeList, |
| 552 | + MaxItems: 1, |
| 553 | + Optional: true, |
| 554 | + ForceNew: true, |
| 555 | + Description: `Stores additional params passed with the request, but not persisted as part of resource payload.`, |
| 556 | + Elem: &schema.Resource{ |
| 557 | + Schema: map[string]*schema.Schema{ |
| 558 | + "resource_manager_tags": { |
| 559 | + Type: schema.TypeMap, |
| 560 | + Optional: true, |
| 561 | + // This field is intentionally not updatable. The API overrides all existing tags on the field when updated. See go/gce-tags-terraform-support for details. |
| 562 | + ForceNew: true, |
| 563 | + Description: `A map of resource manager tags. Resource manager tag keys and values have the same definition as resource manager tags. Keys must be in the format tagKeys/{tag_key_id}, and values are in the format tagValues/456. The field is ignored (both PUT & PATCH) when empty.`, |
| 564 | + }, |
| 565 | + }, |
| 566 | + }, |
| 567 | + }, |
| 568 | + |
541 | 569 | "labels": {
|
542 | 570 | Type: schema.TypeMap,
|
543 | 571 | Optional: true,
|
@@ -1013,6 +1041,11 @@ func expandComputeInstance(project string, d *schema.ResourceData, config *trans
|
1013 | 1041 | return nil, fmt.Errorf("Error creating scheduling: %s", err)
|
1014 | 1042 | }
|
1015 | 1043 |
|
| 1044 | + params, err := expandParams(d) |
| 1045 | + if err != nil { |
| 1046 | + return nil, fmt.Errorf("Error creating params: %s", err) |
| 1047 | + } |
| 1048 | + |
1016 | 1049 | metadata, err := resourceInstanceMetadata(d)
|
1017 | 1050 | if err != nil {
|
1018 | 1051 | return nil, fmt.Errorf("Error creating metadata: %s", err)
|
@@ -1047,6 +1080,7 @@ func expandComputeInstance(project string, d *schema.ResourceData, config *trans
|
1047 | 1080 | NetworkInterfaces: networkInterfaces,
|
1048 | 1081 | NetworkPerformanceConfig: networkPerformanceConfig,
|
1049 | 1082 | Tags: resourceInstanceTags(d),
|
| 1083 | + Params: params, |
1050 | 1084 | Labels: tpgresource.ExpandLabels(d),
|
1051 | 1085 | ServiceAccounts: expandServiceAccounts(d.Get("service_account").([]interface{})),
|
1052 | 1086 | GuestAccelerators: accels,
|
@@ -2361,6 +2395,16 @@ func resourceComputeInstanceImportState(d *schema.ResourceData, meta interface{}
|
2361 | 2395 | return []*schema.ResourceData{d}, nil
|
2362 | 2396 | }
|
2363 | 2397 |
|
| 2398 | +func expandParams(d *schema.ResourceData) (*compute.InstanceParams, error) { |
| 2399 | + params := &compute.InstanceParams{} |
| 2400 | + |
| 2401 | + if _, ok := d.GetOk("params.0.resource_manager_tags"); ok { |
| 2402 | + params.ResourceManagerTags = tpgresource.ExpandStringMap(d, "params.0.resource_manager_tags") |
| 2403 | + } |
| 2404 | + |
| 2405 | + return params, nil |
| 2406 | +} |
| 2407 | + |
2364 | 2408 | func expandBootDisk(d *schema.ResourceData, config *transport_tpg.Config, project string) (*compute.AttachedDisk, error) {
|
2365 | 2409 | userAgent, err := tpgresource.GenerateUserAgentString(d, config.UserAgent)
|
2366 | 2410 | if err != nil {
|
@@ -2429,6 +2473,10 @@ func expandBootDisk(d *schema.ResourceData, config *transport_tpg.Config, projec
|
2429 | 2473 | if _, ok := d.GetOk("boot_disk.0.initialize_params.0.labels"); ok {
|
2430 | 2474 | disk.InitializeParams.Labels = tpgresource.ExpandStringMap(d, "boot_disk.0.initialize_params.0.labels")
|
2431 | 2475 | }
|
| 2476 | + |
| 2477 | + if _, ok := d.GetOk("boot_disk.0.initialize_params.0.resource_manager_tags"); ok { |
| 2478 | + disk.InitializeParams.ResourceManagerTags = tpgresource.ExpandStringMap(d, "boot_disk.0.initialize_params.0.resource_manager_tags") |
| 2479 | + } |
2432 | 2480 | }
|
2433 | 2481 |
|
2434 | 2482 | if v, ok := d.GetOk("boot_disk.0.mode"); ok {
|
@@ -2464,9 +2512,10 @@ func flattenBootDisk(d *schema.ResourceData, disk *compute.AttachedDisk, config
|
2464 | 2512 | "type": tpgresource.GetResourceNameFromSelfLink(diskDetails.Type),
|
2465 | 2513 | // If the config specifies a family name that doesn't match the image name, then
|
2466 | 2514 | // the diff won't be properly suppressed. See DiffSuppressFunc for this field.
|
2467 |
| - "image": diskDetails.SourceImage, |
2468 |
| - "size": diskDetails.SizeGb, |
2469 |
| - "labels": diskDetails.Labels, |
| 2515 | + "image": diskDetails.SourceImage, |
| 2516 | + "size": diskDetails.SizeGb, |
| 2517 | + "labels": diskDetails.Labels, |
| 2518 | + "resource_manager_tags": d.Get("boot_disk.0.initialize_params.0.resource_manager_tags"), |
2470 | 2519 | }}
|
2471 | 2520 | }
|
2472 | 2521 |
|
|
0 commit comments