Skip to content

Commit 0e17cd0

Browse files
Add advanced_machine_features.enable_uefi_networking field to instance and templates (#12423) (#8805)
[upstream:fe081f8b80ebf09c944e93216474a9a9e6e51e75] Signed-off-by: Modular Magician <[email protected]>
1 parent 66fa1fb commit 0e17cd0

11 files changed

+222
-0
lines changed

.changelog/12423.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: `google_compute_instance`, `google_compute_instance_template`, `google_compute_region_instance_template` now supports `advanced_machine_features.enable_uefi_networking` field
3+
```

google-beta/services/compute/compute_instance_helpers.go

+2
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,7 @@ func expandAdvancedMachineFeatures(d tpgresource.TerraformResourceData) *compute
637637
TurboMode: d.Get(prefix + ".turbo_mode").(string),
638638
VisibleCoreCount: int64(d.Get(prefix + ".visible_core_count").(int)),
639639
PerformanceMonitoringUnit: d.Get(prefix + ".performance_monitoring_unit").(string),
640+
EnableUefiNetworking: d.Get(prefix + ".enable_uefi_networking").(bool),
640641
}
641642
}
642643

@@ -650,6 +651,7 @@ func flattenAdvancedMachineFeatures(AdvancedMachineFeatures *compute.AdvancedMac
650651
"turbo_mode": AdvancedMachineFeatures.TurboMode,
651652
"visible_core_count": AdvancedMachineFeatures.VisibleCoreCount,
652653
"performance_monitoring_unit": AdvancedMachineFeatures.PerformanceMonitoringUnit,
654+
"enable_uefi_networking": AdvancedMachineFeatures.EnableUefiNetworking,
653655
}}
654656
}
655657

google-beta/services/compute/resource_compute_instance.go

+8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var (
5858
"advanced_machine_features.0.turbo_mode",
5959
"advanced_machine_features.0.visible_core_count",
6060
"advanced_machine_features.0.performance_monitoring_unit",
61+
"advanced_machine_features.0.enable_uefi_networking",
6162
}
6263

6364
bootDiskKeys = []string{
@@ -1112,6 +1113,13 @@ be from 0 to 999,999,999 inclusive.`,
11121113
ValidateFunc: validation.StringInSlice([]string{"STANDARD", "ENHANCED", "ARCHITECTURAL"}, false),
11131114
Description: `The PMU is a hardware component within the CPU core that monitors how the processor runs code. Valid values for the level of PMU are "STANDARD", "ENHANCED", and "ARCHITECTURAL".`,
11141115
},
1116+
"enable_uefi_networking": {
1117+
Type: schema.TypeBool,
1118+
Optional: true,
1119+
ForceNew: true,
1120+
AtLeastOneOf: advancedMachineFeaturesKeys,
1121+
Description: `Whether to enable UEFI networking for the instance.`,
1122+
},
11151123
},
11161124
},
11171125
},

google-beta/services/compute/resource_compute_instance_template.go

+6
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,12 @@ be from 0 to 999,999,999 inclusive.`,
970970
ValidateFunc: validation.StringInSlice([]string{"STANDARD", "ENHANCED", "ARCHITECTURAL"}, false),
971971
Description: `The PMU is a hardware component within the CPU core that monitors how the processor runs code. Valid values for the level of PMU are "STANDARD", "ENHANCED", and "ARCHITECTURAL".`,
972972
},
973+
"enable_uefi_networking": {
974+
Type: schema.TypeBool,
975+
Optional: true,
976+
ForceNew: true,
977+
Description: `Whether to enable UEFI networking or not.`,
978+
},
973979
},
974980
},
975981
},

google-beta/services/compute/resource_compute_instance_template_test.go

+67
Original file line numberDiff line numberDiff line change
@@ -952,6 +952,47 @@ func TestAccComputeInstanceTemplate_performanceMonitoringUnit(t *testing.T) {
952952
})
953953
}
954954

955+
func TestAccComputeInstanceTemplate_enableUefiNetworking(t *testing.T) {
956+
t.Parallel()
957+
958+
var instanceTemplate compute.InstanceTemplate
959+
context_1 := map[string]interface{}{
960+
"instance_name": fmt.Sprintf("tf-test-instance-template-%s", acctest.RandString(t, 10)),
961+
"enable_uefi_networking": "false",
962+
}
963+
context_2 := map[string]interface{}{
964+
"instance_name": context_1["instance_name"].(string),
965+
"enable_uefi_networking": "true",
966+
}
967+
968+
acctest.VcrTest(t, resource.TestCase{
969+
PreCheck: func() { acctest.AccTestPreCheck(t) },
970+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
971+
CheckDestroy: testAccCheckComputeInstanceTemplateDestroyProducer(t),
972+
Steps: []resource.TestStep{
973+
{
974+
Config: testAccComputeInstanceTemplate_enableUefiNetworking(context_1),
975+
Check: resource.ComposeTestCheckFunc(
976+
testAccCheckComputeInstanceTemplateExists(t, "google_compute_instance_template.foobar", &instanceTemplate),
977+
resource.TestCheckResourceAttr("google_compute_instance_template.foobar", "advanced_machine_features.0.enable_uefi_networking", "false"),
978+
),
979+
},
980+
{
981+
Config: testAccComputeInstanceTemplate_enableUefiNetworking(context_2),
982+
Check: resource.ComposeTestCheckFunc(
983+
testAccCheckComputeInstanceTemplateExists(t, "google_compute_instance_template.foobar", &instanceTemplate),
984+
resource.TestCheckResourceAttr("google_compute_instance_template.foobar", "advanced_machine_features.0.enable_uefi_networking", "true"),
985+
),
986+
},
987+
{
988+
ResourceName: "google_compute_instance_template.foobar",
989+
ImportState: true,
990+
ImportStateVerify: true,
991+
},
992+
},
993+
})
994+
}
995+
955996
func TestAccComputeInstanceTemplate_enableDisplay(t *testing.T) {
956997
t.Parallel()
957998

@@ -3836,6 +3877,32 @@ resource "google_compute_instance_template" "foobar" {
38363877
`, context)
38373878
}
38383879

3880+
func testAccComputeInstanceTemplate_enableUefiNetworking(context map[string]interface{}) string {
3881+
return acctest.Nprintf(`
3882+
data "google_compute_image" "my_image" {
3883+
family = "ubuntu-2004-lts"
3884+
project = "ubuntu-os-cloud"
3885+
}
3886+
3887+
resource "google_compute_instance_template" "foobar" {
3888+
name = "%{instance_name}"
3889+
machine_type = "n2-standard-2"
3890+
3891+
disk {
3892+
source_image = data.google_compute_image.my_image.self_link
3893+
}
3894+
3895+
network_interface {
3896+
network = "default"
3897+
}
3898+
3899+
advanced_machine_features {
3900+
enable_uefi_networking = "%{enable_uefi_networking}"
3901+
}
3902+
}
3903+
`, context)
3904+
}
3905+
38393906
func testAccComputeInstanceTemplate_enableDisplay(suffix string) string {
38403907
return fmt.Sprintf(`
38413908
data "google_compute_image" "my_image" {

google-beta/services/compute/resource_compute_instance_test.go

+56
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,33 @@ func TestAccComputeInstance_performanceMonitoringUnit(t *testing.T) {
15141514
})
15151515
}
15161516

1517+
func TestAccComputeInstance_enableUefiNetworking(t *testing.T) {
1518+
t.Parallel()
1519+
1520+
var instance compute.Instance
1521+
context_1 := map[string]interface{}{
1522+
"instance_name": fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)),
1523+
"enable_uefi_networking": "true",
1524+
}
1525+
1526+
acctest.VcrTest(t, resource.TestCase{
1527+
PreCheck: func() { acctest.AccTestPreCheck(t) },
1528+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
1529+
CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
1530+
Steps: []resource.TestStep{
1531+
{
1532+
Config: testAccComputeInstance_enableUefiNetworking(context_1),
1533+
Check: resource.ComposeTestCheckFunc(
1534+
testAccCheckComputeInstanceExists(
1535+
t, "google_compute_instance.foobar", &instance),
1536+
resource.TestCheckResourceAttr("google_compute_instance.foobar", "advanced_machine_features.0.enable_uefi_networking", "true"),
1537+
),
1538+
},
1539+
computeInstanceImportStep("us-central1-a", context_1["instance_name"].(string), []string{}),
1540+
},
1541+
})
1542+
}
1543+
15171544
func TestAccComputeInstance_soleTenantNodeAffinities(t *testing.T) {
15181545
t.Parallel()
15191546

@@ -7226,6 +7253,35 @@ resource "google_compute_instance" "foobar" {
72267253
`, context)
72277254
}
72287255

7256+
func testAccComputeInstance_enableUefiNetworking(context map[string]interface{}) string {
7257+
return acctest.Nprintf(`
7258+
data "google_compute_image" "my_image" {
7259+
family = "debian-12"
7260+
project = "debian-cloud"
7261+
}
7262+
7263+
resource "google_compute_instance" "foobar" {
7264+
name = "%{instance_name}"
7265+
machine_type = "n2-standard-2"
7266+
zone = "us-central1-a"
7267+
7268+
boot_disk {
7269+
initialize_params {
7270+
image = data.google_compute_image.my_image.self_link
7271+
}
7272+
}
7273+
7274+
network_interface {
7275+
network = "default"
7276+
}
7277+
7278+
advanced_machine_features {
7279+
enable_uefi_networking = "%{enable_uefi_networking}"
7280+
}
7281+
}
7282+
`, context)
7283+
}
7284+
72297285
func testAccComputeInstance_advancedMachineFeaturesUpdated(instance string) string {
72307286
return fmt.Sprintf(`
72317287
data "google_compute_image" "my_image" {

google-beta/services/compute/resource_compute_region_instance_template.go

+6
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,12 @@ be from 0 to 999,999,999 inclusive.`,
926926
ValidateFunc: validation.StringInSlice([]string{"STANDARD", "ENHANCED", "ARCHITECTURAL"}, false),
927927
Description: `The PMU is a hardware component within the CPU core that monitors how the processor runs code. Valid values for the level of PMU are "STANDARD", "ENHANCED", and "ARCHITECTURAL".`,
928928
},
929+
"enable_uefi_networking": {
930+
Type: schema.TypeBool,
931+
Optional: true,
932+
ForceNew: true,
933+
Description: `Whether to enable UEFI networking or not.`,
934+
},
929935
},
930936
},
931937
},

google-beta/services/compute/resource_compute_region_instance_template_test.go

+68
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,47 @@ func TestAccComputeRegionInstanceTemplate_performanceMonitoringUnit(t *testing.T
830830
})
831831
}
832832

833+
func TestAccComputeRegionInstanceTemplate_enableUefiNetworking(t *testing.T) {
834+
t.Parallel()
835+
836+
var instanceTemplate compute.InstanceTemplate
837+
context_1 := map[string]interface{}{
838+
"instance_name": fmt.Sprintf("tf-test-instance-template-%s", acctest.RandString(t, 10)),
839+
"enable_uefi_networking": "false",
840+
}
841+
context_2 := map[string]interface{}{
842+
"instance_name": context_1["instance_name"].(string),
843+
"enable_uefi_networking": "true",
844+
}
845+
846+
acctest.VcrTest(t, resource.TestCase{
847+
PreCheck: func() { acctest.AccTestPreCheck(t) },
848+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
849+
CheckDestroy: testAccCheckComputeInstanceTemplateDestroyProducer(t),
850+
Steps: []resource.TestStep{
851+
{
852+
Config: testAccComputeRegionInstanceTemplate_enableUefiNetworking(context_1),
853+
Check: resource.ComposeTestCheckFunc(
854+
testAccCheckComputeRegionInstanceTemplateExists(t, "google_compute_region_instance_template.foobar", &instanceTemplate),
855+
resource.TestCheckResourceAttr("google_compute_region_instance_template.foobar", "advanced_machine_features.0.enable_uefi_networking", "false"),
856+
),
857+
},
858+
{
859+
Config: testAccComputeRegionInstanceTemplate_enableUefiNetworking(context_2),
860+
Check: resource.ComposeTestCheckFunc(
861+
testAccCheckComputeRegionInstanceTemplateExists(t, "google_compute_region_instance_template.foobar", &instanceTemplate),
862+
resource.TestCheckResourceAttr("google_compute_region_instance_template.foobar", "advanced_machine_features.0.enable_uefi_networking", "true"),
863+
),
864+
},
865+
{
866+
ResourceName: "google_compute_region_instance_template.foobar",
867+
ImportState: true,
868+
ImportStateVerify: true,
869+
},
870+
},
871+
})
872+
}
873+
833874
func TestAccComputeRegionInstanceTemplate_enableDisplay(t *testing.T) {
834875
t.Parallel()
835876

@@ -3237,6 +3278,33 @@ resource "google_compute_region_instance_template" "foobar" {
32373278
`, context)
32383279
}
32393280

3281+
func testAccComputeRegionInstanceTemplate_enableUefiNetworking(context map[string]interface{}) string {
3282+
return acctest.Nprintf(`
3283+
data "google_compute_image" "my_image" {
3284+
family = "ubuntu-2004-lts"
3285+
project = "ubuntu-os-cloud"
3286+
}
3287+
3288+
resource "google_compute_region_instance_template" "foobar" {
3289+
name = "%{instance_name}"
3290+
region = "us-central1"
3291+
machine_type = "n2-standard-2"
3292+
3293+
disk {
3294+
source_image = data.google_compute_image.my_image.self_link
3295+
}
3296+
3297+
network_interface {
3298+
network = "default"
3299+
}
3300+
3301+
advanced_machine_features {
3302+
enable_uefi_networking = "%{enable_uefi_networking}"
3303+
}
3304+
}
3305+
`, context)
3306+
}
3307+
32403308
func testAccComputeRegionInstanceTemplate_enableDisplay(suffix string) string {
32413309
return fmt.Sprintf(`
32423310
data "google_compute_image" "my_image" {

website/docs/r/compute_instance.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,8 @@ specified, then this instance will have no external IPv6 Internet access. Struct
577577

578578
* `performance_monitoring_unit` - (Optional) [The PMU](https://cloud.google.com/compute/docs/pmu-overview) is a hardware component within the CPU core that monitors how the processor runs code. Valid values for the level of PMU are `STANDARD`, `ENHANCED`, and `ARCHITECTURAL`.
579579

580+
* `enable_uefi_networking` - (Optional) Whether to enable UEFI networking for instance creation.
581+
580582
<a name="nested_reservation_affinity"></a>The `reservation_affinity` block supports:
581583

582584
* `type` - (Required) The type of reservation from which this instance can consume resources.

website/docs/r/compute_instance_template.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,8 @@ The `specific_reservation` block supports:
732732

733733
* `performance_monitoring_unit` - (Optional) [The PMU](https://cloud.google.com/compute/docs/pmu-overview) is a hardware component within the CPU core that monitors how the processor runs code. Valid values for the level of PMU are `STANDARD`, `ENHANCED`, and `ARCHITECTURAL`.
734734

735+
* `enable_uefi_networking` - (Optional) Whether to enable UEFI networking for instance creation.
736+
735737
## Attributes Reference
736738

737739
In addition to the arguments listed above, the following computed attributes are

website/docs/r/compute_region_instance_template.html.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,8 @@ The `specific_reservation` block supports:
692692

693693
* `performance_monitoring_unit` - (Optional) [The PMU](https://cloud.google.com/compute/docs/pmu-overview) is a hardware component within the CPU core that monitors how the processor runs code. Valid values for the level of PMU are `STANDARD`, `ENHANCED`, and `ARCHITECTURAL`.
694694

695+
* `enable_uefi_networking` - (Optional) Whether to enable UEFI networking for instance creation.
696+
695697
## Attributes Reference
696698

697699
In addition to the arguments listed above, the following computed attributes are

0 commit comments

Comments
 (0)