Skip to content

Commit 0ee2c00

Browse files
Add creation_timestamp field to google_compute_instance and template resources (#11955) (#8442)
[upstream:dcc3ee085bbe1f19ed72924c8ee4c6c53fc6743f] Signed-off-by: Modular Magician <[email protected]>
1 parent 6814d53 commit 0ee2c00

14 files changed

+50
-0
lines changed

.changelog/11955.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: added `creation_timestamp` field to `google_compute_instance`, `google_compute_instance_template`, `google_compute_region_instance_template`
3+
```

google-beta/services/compute/data_source_google_compute_instance.go

+3
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ func dataSourceGoogleComputeInstanceRead(d *schema.ResourceData, meta interface{
204204
if err := d.Set("name", instance.Name); err != nil {
205205
return fmt.Errorf("Error setting name: %s", err)
206206
}
207+
if err := d.Set("creation_timestamp", instance.CreationTimestamp); err != nil {
208+
return fmt.Errorf("Error setting creation_timestamp: %s", err)
209+
}
207210
d.SetId(fmt.Sprintf("projects/%s/zones/%s/instances/%s", project, tpgresource.GetResourceNameFromSelfLink(instance.Zone), instance.Name))
208211
return nil
209212
}

google-beta/services/compute/resource_compute_instance.go

+9
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,12 @@ be from 0 to 999,999,999 inclusive.`,
11611161
Description: `The server-assigned unique identifier of this instance.`,
11621162
},
11631163

1164+
"creation_timestamp": {
1165+
Type: schema.TypeString,
1166+
Computed: true,
1167+
Description: `Creation timestamp in RFC3339 text format.`,
1168+
},
1169+
11641170
"label_fingerprint": {
11651171
Type: schema.TypeString,
11661172
Computed: true,
@@ -1773,6 +1779,9 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
17731779
if err := d.Set("instance_id", fmt.Sprintf("%d", instance.Id)); err != nil {
17741780
return fmt.Errorf("Error setting instance_id: %s", err)
17751781
}
1782+
if err := d.Set("creation_timestamp", instance.CreationTimestamp); err != nil {
1783+
return fmt.Errorf("Error setting creation_timestamp: %s", err)
1784+
}
17761785
if err := d.Set("project", project); err != nil {
17771786
return fmt.Errorf("Error setting project: %s", err)
17781787
}

google-beta/services/compute/resource_compute_instance_template.go

+10
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,13 @@ be from 0 to 999,999,999 inclusive.`,
818818
Description: `A special URI of the created resource that uniquely identifies this instance template.`,
819819
},
820820

821+
"creation_timestamp": {
822+
Type: schema.TypeString,
823+
ForceNew: true,
824+
Computed: true,
825+
Description: `Creation timestamp in RFC3339 text format.`,
826+
},
827+
821828
"service_account": {
822829
Type: schema.TypeList,
823830
MaxItems: 1,
@@ -1793,6 +1800,9 @@ func resourceComputeInstanceTemplateRead(d *schema.ResourceData, meta interface{
17931800
if err = d.Set("self_link_unique", fmt.Sprintf("%v?uniqueId=%v", instanceTemplate.SelfLink, instanceTemplate.Id)); err != nil {
17941801
return fmt.Errorf("Error setting self_link_unique: %s", err)
17951802
}
1803+
if err = d.Set("creation_timestamp", instanceTemplate.CreationTimestamp); err != nil {
1804+
return fmt.Errorf("Error setting creation_timestamp: %s", err)
1805+
}
17961806
if err = d.Set("name", instanceTemplate.Name); err != nil {
17971807
return fmt.Errorf("Error setting name: %s", err)
17981808
}

google-beta/services/compute/resource_compute_instance_template_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func TestAccComputeInstanceTemplate_basic(t *testing.T) {
4545
testAccCheckComputeInstanceTemplateMetadata(&instanceTemplate, "foo", "bar"),
4646
testAccCheckComputeInstanceTemplateContainsLabel(&instanceTemplate, "my_label", "foobar"),
4747
testAccCheckComputeInstanceTemplateLacksShieldedVmConfig(&instanceTemplate),
48+
resource.TestCheckResourceAttrSet("google_compute_instance_template.foobar", "creation_timestamp"),
4849
),
4950
},
5051
{

google-beta/services/compute/resource_compute_instance_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ func TestAccComputeInstance_basic1(t *testing.T) {
186186
testAccCheckComputeInstanceMetadata(&instance, "baz", "qux"),
187187
testAccCheckComputeInstanceDisk(&instance, instanceName, true, true),
188188
resource.TestCheckResourceAttr("google_compute_instance.foobar", "current_status", "RUNNING"),
189+
resource.TestCheckResourceAttrSet("google_compute_instance.foobar", "creation_timestamp"),
189190

190191
// by default, DeletionProtection is implicitly false. This should be false on any
191192
// instance resource without an explicit deletion_protection = true declaration.

google-beta/services/compute/resource_compute_region_instance_template.go

+10
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,13 @@ be from 0 to 999,999,999 inclusive.`,
774774
Description: `The URI of the created resource.`,
775775
},
776776

777+
"creation_timestamp": {
778+
Type: schema.TypeString,
779+
Computed: true,
780+
ForceNew: true,
781+
Description: `The time at which the instance was created in RFC 3339 format.`,
782+
},
783+
777784
"service_account": {
778785
Type: schema.TypeList,
779786
MaxItems: 1,
@@ -1287,6 +1294,9 @@ func resourceComputeRegionInstanceTemplateRead(d *schema.ResourceData, meta inte
12871294
if err = d.Set("self_link", instanceTemplate["selfLink"]); err != nil {
12881295
return fmt.Errorf("Error setting self_link: %s", err)
12891296
}
1297+
if err := d.Set("creation_timestamp", instanceTemplate["creationTimestamp"]); err != nil {
1298+
return fmt.Errorf("Error setting creation_timestamp: %s", err)
1299+
}
12901300
if err = d.Set("name", instanceTemplate["name"]); err != nil {
12911301
return fmt.Errorf("Error setting name: %s", err)
12921302
}

google-beta/services/compute/resource_compute_region_instance_template_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ func TestAccComputeRegionInstanceTemplate_basic(t *testing.T) {
4242
testAccCheckComputeRegionInstanceTemplateMetadata(&instanceTemplate, "foo", "bar"),
4343
testAccCheckComputeRegionInstanceTemplateContainsLabel(&instanceTemplate, "my_label", "foobar"),
4444
testAccCheckComputeRegionInstanceTemplateLacksShieldedVmConfig(&instanceTemplate),
45+
resource.TestCheckResourceAttrSet("google_compute_region_instance_template.foobar", "creation_timestamp"),
4546
),
4647
},
4748
{

website/docs/d/compute_instance.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ The following arguments are supported:
7373

7474
* `instance_id` - The server-assigned unique identifier of this instance.
7575

76+
* `creation_timestamp` - Creation timestamp in RFC3339 text format.
77+
7678
* `metadata_fingerprint` - The unique fingerprint of the metadata.
7779

7880
* `self_link` - The URI of the created resource.

website/docs/d/compute_instance_template.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ The `disk_encryption_key` block supports:
318318

319319
* `id` - an identifier for the resource with format `projects/{{project}}/global/instanceTemplates/{{name}}`
320320

321+
* `creation_timestamp` - Creation timestamp in RFC3339 text format.
322+
321323
* `metadata_fingerprint` - The unique fingerprint of the metadata.
322324

323325
* `self_link` - The URI of the created resource.

website/docs/d/compute_region_instance_template.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ The `disk_encryption_key` block supports:
302302

303303
* `id` - an identifier for the resource with format `projects/{{project}}/regions/{{region}}/instanceTemplates/{{name}}`
304304

305+
* `creation_timestamp` - Creation timestamp in RFC3339 text format.
306+
305307
* `metadata_fingerprint` - The unique fingerprint of the metadata.
306308

307309
* `self_link` - The URI of the created resource.

website/docs/r/compute_instance.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,8 @@ exported:
590590

591591
* `id` - an identifier for the resource with format `projects/{{project}}/zones/{{zone}}/instances/{{name}}`
592592

593+
* `creation_timestamp` - Creation timestamp in RFC3339 text format.
594+
593595
* `instance_id` - The server-assigned unique identifier of this instance.
594596

595597
* `metadata_fingerprint` - The unique fingerprint of the metadata.

website/docs/r/compute_instance_template.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,8 @@ exported:
733733

734734
* `id` - an identifier for the resource with format `projects/{{project}}/global/instanceTemplates/{{name}}`
735735

736+
* `creation_timestamp` - Creation timestamp in RFC3339 text format.
737+
736738
* `metadata_fingerprint` - The unique fingerprint of the metadata.
737739

738740
* `self_link` - The URI of the created resource.

website/docs/r/compute_region_instance_template.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ exported:
693693

694694
* `id` - an identifier for the resource with format `projects/{{project}}/regions/{{region}}/instanceTemplates/{{name}}`
695695

696+
* `creation_timestamp` - Creation timestamp in RFC3339 text format.
697+
696698
* `metadata_fingerprint` - The unique fingerprint of the metadata.
697699

698700
* `self_link` - The URI of the created resource.

0 commit comments

Comments
 (0)