From 7449094fe612ffcde0b149fc1fa833c97294d2d2 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Thu, 17 Oct 2024 19:57:00 +0000 Subject: [PATCH] Add `creation_timestamp` field to `google_compute_instance` and template resources (#11955) [upstream:dcc3ee085bbe1f19ed72924c8ee4c6c53fc6743f] Signed-off-by: Modular Magician --- .changelog/11955.txt | 3 +++ .../compute/data_source_google_compute_instance.go | 3 +++ google/services/compute/resource_compute_instance.go | 9 +++++++++ .../compute/resource_compute_instance_template.go | 10 ++++++++++ .../compute/resource_compute_instance_template_test.go | 1 + .../services/compute/resource_compute_instance_test.go | 1 + .../resource_compute_region_instance_template.go | 10 ++++++++++ .../resource_compute_region_instance_template_test.go | 1 + website/docs/d/compute_instance.html.markdown | 2 ++ website/docs/d/compute_instance_template.html.markdown | 2 ++ .../d/compute_region_instance_template.html.markdown | 2 ++ website/docs/r/compute_instance.html.markdown | 2 ++ website/docs/r/compute_instance_template.html.markdown | 2 ++ .../r/compute_region_instance_template.html.markdown | 2 ++ 14 files changed, 50 insertions(+) create mode 100644 .changelog/11955.txt diff --git a/.changelog/11955.txt b/.changelog/11955.txt new file mode 100644 index 00000000000..be46c4a0c8e --- /dev/null +++ b/.changelog/11955.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +compute: added `creation_timestamp` field to `google_compute_instance`, `google_compute_instance_template`, `google_compute_region_instance_template` +``` \ No newline at end of file diff --git a/google/services/compute/data_source_google_compute_instance.go b/google/services/compute/data_source_google_compute_instance.go index f1718984366..ee915923fa6 100644 --- a/google/services/compute/data_source_google_compute_instance.go +++ b/google/services/compute/data_source_google_compute_instance.go @@ -204,6 +204,9 @@ func dataSourceGoogleComputeInstanceRead(d *schema.ResourceData, meta interface{ if err := d.Set("name", instance.Name); err != nil { return fmt.Errorf("Error setting name: %s", err) } + if err := d.Set("creation_timestamp", instance.CreationTimestamp); err != nil { + return fmt.Errorf("Error setting creation_timestamp: %s", err) + } d.SetId(fmt.Sprintf("projects/%s/zones/%s/instances/%s", project, tpgresource.GetResourceNameFromSelfLink(instance.Zone), instance.Name)) return nil } diff --git a/google/services/compute/resource_compute_instance.go b/google/services/compute/resource_compute_instance.go index 6d4dd2b684d..92389ea3d0c 100644 --- a/google/services/compute/resource_compute_instance.go +++ b/google/services/compute/resource_compute_instance.go @@ -1113,6 +1113,12 @@ be from 0 to 999,999,999 inclusive.`, Description: `The server-assigned unique identifier of this instance.`, }, + "creation_timestamp": { + Type: schema.TypeString, + Computed: true, + Description: `Creation timestamp in RFC3339 text format.`, + }, + "label_fingerprint": { Type: schema.TypeString, Computed: true, @@ -1699,6 +1705,9 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error if err := d.Set("instance_id", fmt.Sprintf("%d", instance.Id)); err != nil { return fmt.Errorf("Error setting instance_id: %s", err) } + if err := d.Set("creation_timestamp", instance.CreationTimestamp); err != nil { + return fmt.Errorf("Error setting creation_timestamp: %s", err) + } if err := d.Set("project", project); err != nil { return fmt.Errorf("Error setting project: %s", err) } diff --git a/google/services/compute/resource_compute_instance_template.go b/google/services/compute/resource_compute_instance_template.go index 3ec83efb9b2..219fb6fc301 100644 --- a/google/services/compute/resource_compute_instance_template.go +++ b/google/services/compute/resource_compute_instance_template.go @@ -779,6 +779,13 @@ be from 0 to 999,999,999 inclusive.`, Description: `A special URI of the created resource that uniquely identifies this instance template.`, }, + "creation_timestamp": { + Type: schema.TypeString, + ForceNew: true, + Computed: true, + Description: `Creation timestamp in RFC3339 text format.`, + }, + "service_account": { Type: schema.TypeList, MaxItems: 1, @@ -1738,6 +1745,9 @@ func resourceComputeInstanceTemplateRead(d *schema.ResourceData, meta interface{ if err = d.Set("self_link_unique", fmt.Sprintf("%v?uniqueId=%v", instanceTemplate.SelfLink, instanceTemplate.Id)); err != nil { return fmt.Errorf("Error setting self_link_unique: %s", err) } + if err = d.Set("creation_timestamp", instanceTemplate.CreationTimestamp); err != nil { + return fmt.Errorf("Error setting creation_timestamp: %s", err) + } if err = d.Set("name", instanceTemplate.Name); err != nil { return fmt.Errorf("Error setting name: %s", err) } diff --git a/google/services/compute/resource_compute_instance_template_test.go b/google/services/compute/resource_compute_instance_template_test.go index 34b46b38439..f4328af3774 100644 --- a/google/services/compute/resource_compute_instance_template_test.go +++ b/google/services/compute/resource_compute_instance_template_test.go @@ -42,6 +42,7 @@ func TestAccComputeInstanceTemplate_basic(t *testing.T) { testAccCheckComputeInstanceTemplateMetadata(&instanceTemplate, "foo", "bar"), testAccCheckComputeInstanceTemplateContainsLabel(&instanceTemplate, "my_label", "foobar"), testAccCheckComputeInstanceTemplateLacksShieldedVmConfig(&instanceTemplate), + resource.TestCheckResourceAttrSet("google_compute_instance_template.foobar", "creation_timestamp"), ), }, { diff --git a/google/services/compute/resource_compute_instance_test.go b/google/services/compute/resource_compute_instance_test.go index fe3d4a79245..1f2537ca54c 100644 --- a/google/services/compute/resource_compute_instance_test.go +++ b/google/services/compute/resource_compute_instance_test.go @@ -184,6 +184,7 @@ func TestAccComputeInstance_basic1(t *testing.T) { testAccCheckComputeInstanceMetadata(&instance, "baz", "qux"), testAccCheckComputeInstanceDisk(&instance, instanceName, true, true), resource.TestCheckResourceAttr("google_compute_instance.foobar", "current_status", "RUNNING"), + resource.TestCheckResourceAttrSet("google_compute_instance.foobar", "creation_timestamp"), // by default, DeletionProtection is implicitly false. This should be false on any // instance resource without an explicit deletion_protection = true declaration. diff --git a/google/services/compute/resource_compute_region_instance_template.go b/google/services/compute/resource_compute_region_instance_template.go index 81a460adf9f..5abfb106bec 100644 --- a/google/services/compute/resource_compute_region_instance_template.go +++ b/google/services/compute/resource_compute_region_instance_template.go @@ -745,6 +745,13 @@ be from 0 to 999,999,999 inclusive.`, Description: `The URI of the created resource.`, }, + "creation_timestamp": { + Type: schema.TypeString, + Computed: true, + ForceNew: true, + Description: `The time at which the instance was created in RFC 3339 format.`, + }, + "service_account": { Type: schema.TypeList, MaxItems: 1, @@ -1236,6 +1243,9 @@ func resourceComputeRegionInstanceTemplateRead(d *schema.ResourceData, meta inte if err = d.Set("self_link", instanceTemplate["selfLink"]); err != nil { return fmt.Errorf("Error setting self_link: %s", err) } + if err := d.Set("creation_timestamp", instanceTemplate["creationTimestamp"]); err != nil { + return fmt.Errorf("Error setting creation_timestamp: %s", err) + } if err = d.Set("name", instanceTemplate["name"]); err != nil { return fmt.Errorf("Error setting name: %s", err) } diff --git a/google/services/compute/resource_compute_region_instance_template_test.go b/google/services/compute/resource_compute_region_instance_template_test.go index 9bcbc555fd8..db2c1abe09b 100644 --- a/google/services/compute/resource_compute_region_instance_template_test.go +++ b/google/services/compute/resource_compute_region_instance_template_test.go @@ -41,6 +41,7 @@ func TestAccComputeRegionInstanceTemplate_basic(t *testing.T) { testAccCheckComputeRegionInstanceTemplateMetadata(&instanceTemplate, "foo", "bar"), testAccCheckComputeRegionInstanceTemplateContainsLabel(&instanceTemplate, "my_label", "foobar"), testAccCheckComputeRegionInstanceTemplateLacksShieldedVmConfig(&instanceTemplate), + resource.TestCheckResourceAttrSet("google_compute_region_instance_template.foobar", "creation_timestamp"), ), }, { diff --git a/website/docs/d/compute_instance.html.markdown b/website/docs/d/compute_instance.html.markdown index b6c32b263ff..51e910b79fd 100644 --- a/website/docs/d/compute_instance.html.markdown +++ b/website/docs/d/compute_instance.html.markdown @@ -73,6 +73,8 @@ The following arguments are supported: * `instance_id` - The server-assigned unique identifier of this instance. +* `creation_timestamp` - Creation timestamp in RFC3339 text format. + * `metadata_fingerprint` - The unique fingerprint of the metadata. * `self_link` - The URI of the created resource. diff --git a/website/docs/d/compute_instance_template.html.markdown b/website/docs/d/compute_instance_template.html.markdown index 08be6b15f0f..c2fec431762 100644 --- a/website/docs/d/compute_instance_template.html.markdown +++ b/website/docs/d/compute_instance_template.html.markdown @@ -318,6 +318,8 @@ The `disk_encryption_key` block supports: * `id` - an identifier for the resource with format `projects/{{project}}/global/instanceTemplates/{{name}}` +* `creation_timestamp` - Creation timestamp in RFC3339 text format. + * `metadata_fingerprint` - The unique fingerprint of the metadata. * `self_link` - The URI of the created resource. diff --git a/website/docs/d/compute_region_instance_template.html.markdown b/website/docs/d/compute_region_instance_template.html.markdown index e6f4f548ea6..88b464f3ab1 100644 --- a/website/docs/d/compute_region_instance_template.html.markdown +++ b/website/docs/d/compute_region_instance_template.html.markdown @@ -302,6 +302,8 @@ The `disk_encryption_key` block supports: * `id` - an identifier for the resource with format `projects/{{project}}/regions/{{region}}/instanceTemplates/{{name}}` +* `creation_timestamp` - Creation timestamp in RFC3339 text format. + * `metadata_fingerprint` - The unique fingerprint of the metadata. * `self_link` - The URI of the created resource. diff --git a/website/docs/r/compute_instance.html.markdown b/website/docs/r/compute_instance.html.markdown index b18f1594ce0..28588ad7740 100644 --- a/website/docs/r/compute_instance.html.markdown +++ b/website/docs/r/compute_instance.html.markdown @@ -590,6 +590,8 @@ exported: * `id` - an identifier for the resource with format `projects/{{project}}/zones/{{zone}}/instances/{{name}}` +* `creation_timestamp` - Creation timestamp in RFC3339 text format. + * `instance_id` - The server-assigned unique identifier of this instance. * `metadata_fingerprint` - The unique fingerprint of the metadata. diff --git a/website/docs/r/compute_instance_template.html.markdown b/website/docs/r/compute_instance_template.html.markdown index afe75854b4e..31497237c03 100644 --- a/website/docs/r/compute_instance_template.html.markdown +++ b/website/docs/r/compute_instance_template.html.markdown @@ -733,6 +733,8 @@ exported: * `id` - an identifier for the resource with format `projects/{{project}}/global/instanceTemplates/{{name}}` +* `creation_timestamp` - Creation timestamp in RFC3339 text format. + * `metadata_fingerprint` - The unique fingerprint of the metadata. * `self_link` - The URI of the created resource. diff --git a/website/docs/r/compute_region_instance_template.html.markdown b/website/docs/r/compute_region_instance_template.html.markdown index facff74df4b..be8dcbfbe0b 100644 --- a/website/docs/r/compute_region_instance_template.html.markdown +++ b/website/docs/r/compute_region_instance_template.html.markdown @@ -693,6 +693,8 @@ exported: * `id` - an identifier for the resource with format `projects/{{project}}/regions/{{region}}/instanceTemplates/{{name}}` +* `creation_timestamp` - Creation timestamp in RFC3339 text format. + * `metadata_fingerprint` - The unique fingerprint of the metadata. * `self_link` - The URI of the created resource.