Skip to content

Commit 6ba2313

Browse files
karolgorcniharika-98
authored andcommitted
Add advanced_machine_features.enable_uefi_networking field to instance and templates (GoogleCloudPlatform#12423)
1 parent 90341f4 commit 6ba2313

10 files changed

+220
-0
lines changed

mmv1/third_party/terraform/services/compute/compute_instance_helpers.go.tmpl

+2
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,7 @@ func expandAdvancedMachineFeatures(d tpgresource.TerraformResourceData) *compute
665665
TurboMode: d.Get(prefix + ".turbo_mode").(string),
666666
VisibleCoreCount: int64(d.Get(prefix + ".visible_core_count").(int)),
667667
PerformanceMonitoringUnit: d.Get(prefix + ".performance_monitoring_unit").(string),
668+
EnableUefiNetworking: d.Get(prefix + ".enable_uefi_networking").(bool),
668669
}
669670
}
670671

@@ -678,6 +679,7 @@ func flattenAdvancedMachineFeatures(AdvancedMachineFeatures *compute.AdvancedMac
678679
"turbo_mode": AdvancedMachineFeatures.TurboMode,
679680
"visible_core_count": AdvancedMachineFeatures.VisibleCoreCount,
680681
"performance_monitoring_unit": AdvancedMachineFeatures.PerformanceMonitoringUnit,
682+
"enable_uefi_networking": AdvancedMachineFeatures.EnableUefiNetworking,
681683
{{"}}"}}
682684
}
683685

mmv1/third_party/terraform/services/compute/resource_compute_instance.go.tmpl

+8
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ var (
6060
"advanced_machine_features.0.turbo_mode",
6161
"advanced_machine_features.0.visible_core_count",
6262
"advanced_machine_features.0.performance_monitoring_unit",
63+
"advanced_machine_features.0.enable_uefi_networking",
6364
}
6465

6566
bootDiskKeys = []string{
@@ -1133,6 +1134,13 @@ be from 0 to 999,999,999 inclusive.`,
11331134
ValidateFunc: validation.StringInSlice([]string{"STANDARD", "ENHANCED", "ARCHITECTURAL"}, false),
11341135
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".`,
11351136
},
1137+
"enable_uefi_networking": {
1138+
Type: schema.TypeBool,
1139+
Optional: true,
1140+
ForceNew: true,
1141+
AtLeastOneOf: advancedMachineFeaturesKeys,
1142+
Description: `Whether to enable UEFI networking for the instance.`,
1143+
},
11361144
},
11371145
},
11381146
},

mmv1/third_party/terraform/services/compute/resource_compute_instance_template.go.tmpl

+6
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,12 @@ be from 0 to 999,999,999 inclusive.`,
988988
ValidateFunc: validation.StringInSlice([]string{"STANDARD", "ENHANCED", "ARCHITECTURAL"}, false),
989989
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".`,
990990
},
991+
"enable_uefi_networking": {
992+
Type: schema.TypeBool,
993+
Optional: true,
994+
ForceNew: true,
995+
Description: `Whether to enable UEFI networking or not.`,
996+
},
991997
},
992998
},
993999
},

mmv1/third_party/terraform/services/compute/resource_compute_instance_template_test.go.tmpl

+67
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,47 @@ func TestAccComputeInstanceTemplate_performanceMonitoringUnit(t *testing.T) {
963963
})
964964
}
965965

966+
func TestAccComputeInstanceTemplate_enableUefiNetworking(t *testing.T) {
967+
t.Parallel()
968+
969+
var instanceTemplate compute.InstanceTemplate
970+
context_1 := map[string]interface{}{
971+
"instance_name": fmt.Sprintf("tf-test-instance-template-%s", acctest.RandString(t, 10)),
972+
"enable_uefi_networking": "false",
973+
}
974+
context_2 := map[string]interface{}{
975+
"instance_name": context_1["instance_name"].(string),
976+
"enable_uefi_networking": "true",
977+
}
978+
979+
acctest.VcrTest(t, resource.TestCase{
980+
PreCheck: func() { acctest.AccTestPreCheck(t) },
981+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
982+
CheckDestroy: testAccCheckComputeInstanceTemplateDestroyProducer(t),
983+
Steps: []resource.TestStep{
984+
{
985+
Config: testAccComputeInstanceTemplate_enableUefiNetworking(context_1),
986+
Check: resource.ComposeTestCheckFunc(
987+
testAccCheckComputeInstanceTemplateExists(t, "google_compute_instance_template.foobar", &instanceTemplate),
988+
resource.TestCheckResourceAttr("google_compute_instance_template.foobar", "advanced_machine_features.0.enable_uefi_networking", "false"),
989+
),
990+
},
991+
{
992+
Config: testAccComputeInstanceTemplate_enableUefiNetworking(context_2),
993+
Check: resource.ComposeTestCheckFunc(
994+
testAccCheckComputeInstanceTemplateExists(t, "google_compute_instance_template.foobar", &instanceTemplate),
995+
resource.TestCheckResourceAttr("google_compute_instance_template.foobar", "advanced_machine_features.0.enable_uefi_networking", "true"),
996+
),
997+
},
998+
{
999+
ResourceName: "google_compute_instance_template.foobar",
1000+
ImportState: true,
1001+
ImportStateVerify: true,
1002+
},
1003+
},
1004+
})
1005+
}
1006+
9661007
{{ if ne $.TargetVersionName `ga` -}}
9671008
func TestAccComputeInstanceTemplate_enableDisplay(t *testing.T) {
9681009
t.Parallel()
@@ -3872,6 +3913,32 @@ resource "google_compute_instance_template" "foobar" {
38723913
`, context)
38733914
}
38743915

3916+
func testAccComputeInstanceTemplate_enableUefiNetworking(context map[string]interface{}) string {
3917+
return acctest.Nprintf(`
3918+
data "google_compute_image" "my_image" {
3919+
family = "ubuntu-2004-lts"
3920+
project = "ubuntu-os-cloud"
3921+
}
3922+
3923+
resource "google_compute_instance_template" "foobar" {
3924+
name = "%{instance_name}"
3925+
machine_type = "n2-standard-2"
3926+
3927+
disk {
3928+
source_image = data.google_compute_image.my_image.self_link
3929+
}
3930+
3931+
network_interface {
3932+
network = "default"
3933+
}
3934+
3935+
advanced_machine_features {
3936+
enable_uefi_networking = "%{enable_uefi_networking}"
3937+
}
3938+
}
3939+
`, context)
3940+
}
3941+
38753942
{{ if ne $.TargetVersionName `ga` -}}
38763943
func testAccComputeInstanceTemplate_enableDisplay(suffix string) string {
38773944
return fmt.Sprintf(`

mmv1/third_party/terraform/services/compute/resource_compute_instance_test.go.tmpl

+56
Original file line numberDiff line numberDiff line change
@@ -1520,6 +1520,33 @@ func TestAccComputeInstance_performanceMonitoringUnit(t *testing.T) {
15201520
})
15211521
}
15221522

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

@@ -7260,6 +7287,35 @@ resource "google_compute_instance" "foobar" {
72607287
`, context)
72617288
}
72627289

7290+
func testAccComputeInstance_enableUefiNetworking(context map[string]interface{}) string {
7291+
return acctest.Nprintf(`
7292+
data "google_compute_image" "my_image" {
7293+
family = "debian-12"
7294+
project = "debian-cloud"
7295+
}
7296+
7297+
resource "google_compute_instance" "foobar" {
7298+
name = "%{instance_name}"
7299+
machine_type = "n2-standard-2"
7300+
zone = "us-central1-a"
7301+
7302+
boot_disk {
7303+
initialize_params {
7304+
image = data.google_compute_image.my_image.self_link
7305+
}
7306+
}
7307+
7308+
network_interface {
7309+
network = "default"
7310+
}
7311+
7312+
advanced_machine_features {
7313+
enable_uefi_networking = "%{enable_uefi_networking}"
7314+
}
7315+
}
7316+
`, context)
7317+
}
7318+
72637319
func testAccComputeInstance_advancedMachineFeaturesUpdated(instance string) string {
72647320
return fmt.Sprintf(`
72657321
data "google_compute_image" "my_image" {

mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template.go.tmpl

+6
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,12 @@ be from 0 to 999,999,999 inclusive.`,
940940
ValidateFunc: validation.StringInSlice([]string{"STANDARD", "ENHANCED", "ARCHITECTURAL"}, false),
941941
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".`,
942942
},
943+
"enable_uefi_networking": {
944+
Type: schema.TypeBool,
945+
Optional: true,
946+
ForceNew: true,
947+
Description: `Whether to enable UEFI networking or not.`,
948+
},
943949
},
944950
},
945951
},

mmv1/third_party/terraform/services/compute/resource_compute_region_instance_template_test.go.tmpl

+69
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,47 @@ func TestAccComputeRegionInstanceTemplate_performanceMonitoringUnit(t *testing.T
835835
})
836836
}
837837

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

839880
{{ if ne $.TargetVersionName `ga` -}}
840881
func TestAccComputeRegionInstanceTemplate_enableDisplay(t *testing.T) {
@@ -3260,6 +3301,34 @@ resource "google_compute_region_instance_template" "foobar" {
32603301
`, context)
32613302
}
32623303

3304+
func testAccComputeRegionInstanceTemplate_enableUefiNetworking(context map[string]interface{}) string {
3305+
return acctest.Nprintf(`
3306+
data "google_compute_image" "my_image" {
3307+
family = "ubuntu-2004-lts"
3308+
project = "ubuntu-os-cloud"
3309+
}
3310+
3311+
resource "google_compute_region_instance_template" "foobar" {
3312+
name = "%{instance_name}"
3313+
region = "us-central1"
3314+
machine_type = "n2-standard-2"
3315+
3316+
disk {
3317+
source_image = data.google_compute_image.my_image.self_link
3318+
}
3319+
3320+
network_interface {
3321+
network = "default"
3322+
}
3323+
3324+
advanced_machine_features {
3325+
enable_uefi_networking = "%{enable_uefi_networking}"
3326+
}
3327+
}
3328+
`, context)
3329+
}
3330+
3331+
32633332
{{ if ne $.TargetVersionName `ga` -}}
32643333
func testAccComputeRegionInstanceTemplate_enableDisplay(suffix string) string {
32653334
return fmt.Sprintf(`

mmv1/third_party/terraform/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.

mmv1/third_party/terraform/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

mmv1/third_party/terraform/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)