mirror of
https://github.com/letic/terraform-provider-google.git
synced 2024-07-24 02:26:00 +00:00
Add support for min_cpu_platform in google_compute_instance. (#349)
This commit is contained in:
parent
d364addc0e
commit
c2399f76fb
|
@ -19,6 +19,10 @@ var InstanceVersionedFeatures = []Feature{
|
||||||
Version: v0beta,
|
Version: v0beta,
|
||||||
Item: "guest_accelerator",
|
Item: "guest_accelerator",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Version: v0beta,
|
||||||
|
Item: "min_cpu_platform",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func stringScopeHashcode(v interface{}) int {
|
func stringScopeHashcode(v interface{}) int {
|
||||||
|
@ -465,6 +469,17 @@ func resourceComputeInstance() *schema.Resource {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"cpu_platform": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
|
||||||
|
"min_cpu_platform": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
|
|
||||||
"tags": &schema.Schema{
|
"tags": &schema.Schema{
|
||||||
Type: schema.TypeSet,
|
Type: schema.TypeSet,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
|
@ -858,6 +873,7 @@ func resourceComputeInstanceCreate(d *schema.ResourceData, meta interface{}) err
|
||||||
Labels: expandLabels(d),
|
Labels: expandLabels(d),
|
||||||
ServiceAccounts: serviceAccounts,
|
ServiceAccounts: serviceAccounts,
|
||||||
GuestAccelerators: expandGuestAccelerators(zone.Name, d.Get("guest_accelerator").([]interface{})),
|
GuestAccelerators: expandGuestAccelerators(zone.Name, d.Get("guest_accelerator").([]interface{})),
|
||||||
|
MinCpuPlatform: d.Get("min_cpu_platform").(string),
|
||||||
Scheduling: scheduling,
|
Scheduling: scheduling,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1122,6 +1138,8 @@ func resourceComputeInstanceRead(d *schema.ResourceData, meta interface{}) error
|
||||||
d.Set("scratch_disk", scratchDisks)
|
d.Set("scratch_disk", scratchDisks)
|
||||||
d.Set("scheduling", flattenBetaScheduling(instance.Scheduling))
|
d.Set("scheduling", flattenBetaScheduling(instance.Scheduling))
|
||||||
d.Set("guest_accelerator", flattenGuestAccelerators(instance.Zone, instance.GuestAccelerators))
|
d.Set("guest_accelerator", flattenGuestAccelerators(instance.Zone, instance.GuestAccelerators))
|
||||||
|
d.Set("cpu_platform", instance.CpuPlatform)
|
||||||
|
d.Set("min_cpu_platform", instance.MinCpuPlatform)
|
||||||
d.Set("self_link", ConvertSelfLinkToV1(instance.SelfLink))
|
d.Set("self_link", ConvertSelfLinkToV1(instance.SelfLink))
|
||||||
d.SetId(instance.Name)
|
d.SetId(instance.Name)
|
||||||
|
|
||||||
|
|
|
@ -717,6 +717,27 @@ func TestAccComputeInstance_guestAccelerator(t *testing.T) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAccComputeInstance_minCpuPlatform(t *testing.T) {
|
||||||
|
var instance computeBeta.Instance
|
||||||
|
instanceName := fmt.Sprintf("terraform-test-%s", acctest.RandString(10))
|
||||||
|
|
||||||
|
resource.Test(t, resource.TestCase{
|
||||||
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
|
Providers: testAccProviders,
|
||||||
|
CheckDestroy: testAccCheckComputeInstanceDestroy,
|
||||||
|
Steps: []resource.TestStep{
|
||||||
|
resource.TestStep{
|
||||||
|
Config: testAccComputeInstance_minCpuPlatform(instanceName),
|
||||||
|
Check: resource.ComposeTestCheckFunc(
|
||||||
|
testAccCheckComputeBetaInstanceExists("google_compute_instance.foobar", &instance),
|
||||||
|
testAccCheckComputeInstanceHasMinCpuPlatform(&instance, "Intel Haswell"),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func testAccCheckComputeInstanceUpdateMachineType(n string) resource.TestCheckFunc {
|
func testAccCheckComputeInstanceUpdateMachineType(n string) resource.TestCheckFunc {
|
||||||
return func(s *terraform.State) error {
|
return func(s *terraform.State) error {
|
||||||
rs, ok := s.RootModule().Resources[n]
|
rs, ok := s.RootModule().Resources[n]
|
||||||
|
@ -1099,6 +1120,16 @@ func testAccCheckComputeInstanceHasGuestAccelerator(instance *computeBeta.Instan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testAccCheckComputeInstanceHasMinCpuPlatform(instance *computeBeta.Instance, minCpuPlatform string) resource.TestCheckFunc {
|
||||||
|
return func(s *terraform.State) error {
|
||||||
|
if instance.MinCpuPlatform != minCpuPlatform {
|
||||||
|
return fmt.Errorf("Wrong minimum CPU platform: expected %s, got %s", minCpuPlatform, instance.MinCpuPlatform)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testAccComputeInstance_basic_deprecated_network(instance string) string {
|
func testAccComputeInstance_basic_deprecated_network(instance string) string {
|
||||||
return fmt.Sprintf(`
|
return fmt.Sprintf(`
|
||||||
resource "google_compute_instance" "foobar" {
|
resource "google_compute_instance" "foobar" {
|
||||||
|
@ -1950,3 +1981,24 @@ resource "google_compute_instance" "foobar" {
|
||||||
}
|
}
|
||||||
}`, instance)
|
}`, instance)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testAccComputeInstance_minCpuPlatform(instance string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "google_compute_instance" "foobar" {
|
||||||
|
name = "%s"
|
||||||
|
machine_type = "n1-standard-1"
|
||||||
|
zone = "us-east1-d"
|
||||||
|
|
||||||
|
boot_disk {
|
||||||
|
initialize_params {
|
||||||
|
image = "debian-8-jessie-v20160803"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
network_interface {
|
||||||
|
network = "default"
|
||||||
|
}
|
||||||
|
|
||||||
|
min_cpu_platform = "Intel Haswell"
|
||||||
|
}`, instance)
|
||||||
|
}
|
||||||
|
|
|
@ -264,6 +264,9 @@ The `scheduling` block supports:
|
||||||
|
|
||||||
* `guest_accelerator` - (Optional, [Beta](/docs/providers/google/index.html#beta-features)) List of the type and count of accelerator cards attached to the instance. Structure documented below.
|
* `guest_accelerator` - (Optional, [Beta](/docs/providers/google/index.html#beta-features)) List of the type and count of accelerator cards attached to the instance. Structure documented below.
|
||||||
|
|
||||||
|
* `min_cpu_platform` - (Optional, [Beta](/docs/providers/google/index.html#beta-features)) Specifies a minimum CPU platform for the VM instance. Applicable values are the friendly names of CPU platforms, such as
|
||||||
|
`Intel Haswell` or `Intel Skylake`. See the complete list [here](https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform).
|
||||||
|
|
||||||
The `guest_accelerator` block supports:
|
The `guest_accelerator` block supports:
|
||||||
|
|
||||||
* `type` (Required) - The accelerator type resource to expose to this instance. E.g. `nvidia-tesla-k80`.
|
* `type` (Required) - The accelerator type resource to expose to this instance. E.g. `nvidia-tesla-k80`.
|
||||||
|
@ -283,6 +286,8 @@ exported:
|
||||||
|
|
||||||
* `label_fingerprint` - The unique fingerprint of the labels.
|
* `label_fingerprint` - The unique fingerprint of the labels.
|
||||||
|
|
||||||
|
* `cpu_platform` - The CPU platform used by this instance.
|
||||||
|
|
||||||
* `network_interface.0.address` - The internal ip address of the instance, either manually or dynamically assigned.
|
* `network_interface.0.address` - The internal ip address of the instance, either manually or dynamically assigned.
|
||||||
|
|
||||||
* `network_interface.0.access_config.0.assigned_nat_ip` - If the instance has an access config, either the given external ip (in the `nat_ip` field) or the ephemeral (generated) ip (if you didn't provide one).
|
* `network_interface.0.access_config.0.assigned_nat_ip` - If the instance has an access config, either the given external ip (in the `nat_ip` field) or the ephemeral (generated) ip (if you didn't provide one).
|
||||||
|
|
Loading…
Reference in New Issue
Block a user