-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* shielded instance config for Workbench instances * Add test to double apply [upstream:25d06fee267f69dfaf8dc323a95997fbf869b1c1] Signed-off-by: Modular Magician <magic-modules@google.com>
- Loading branch information
1 parent
dc38398
commit 8e13e8d
Showing
6 changed files
with
383 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
workbench: added `shielded_instance_config` field to `google_workbench_instance` resource | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
190 changes: 190 additions & 0 deletions
190
google/services/workbench/resource_workbench_instance_shielded_config_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
package workbench_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
"github.com/hashicorp/terraform-provider-google/google/acctest" | ||
) | ||
|
||
func TestAccWorkbenchInstance_shielded_config_update(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccWorkbenchInstance_shielded_config_false(context), | ||
}, | ||
{ | ||
ResourceName: "google_workbench_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "labels", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccWorkbenchInstance_shielded_config_true(context), | ||
}, | ||
{ | ||
ResourceName: "google_workbench_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "labels", "terraform_labels"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccWorkbenchInstance_shielded_config_remove(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccWorkbenchInstance_shielded_config_true(context), | ||
}, | ||
{ | ||
ResourceName: "google_workbench_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "labels", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccWorkbenchInstance_shielded_config_none(context), | ||
}, | ||
{ | ||
ResourceName: "google_workbench_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "labels", "terraform_labels"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccWorkbenchInstance_shielded_config_double_apply(t *testing.T) { | ||
t.Parallel() | ||
|
||
context := map[string]interface{}{ | ||
"random_suffix": acctest.RandString(t, 10), | ||
} | ||
|
||
acctest.VcrTest(t, resource.TestCase{ | ||
PreCheck: func() { acctest.AccTestPreCheck(t) }, | ||
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccWorkbenchInstance_shielded_config_none(context), | ||
}, | ||
{ | ||
ResourceName: "google_workbench_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "labels", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccWorkbenchInstance_shielded_config_none(context), | ||
}, | ||
{ | ||
ResourceName: "google_workbench_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "labels", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccWorkbenchInstance_shielded_config_false(context), | ||
}, | ||
{ | ||
ResourceName: "google_workbench_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "labels", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccWorkbenchInstance_shielded_config_false(context), | ||
}, | ||
{ | ||
ResourceName: "google_workbench_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "labels", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccWorkbenchInstance_shielded_config_true(context), | ||
}, | ||
{ | ||
ResourceName: "google_workbench_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "labels", "terraform_labels"}, | ||
}, | ||
{ | ||
Config: testAccWorkbenchInstance_shielded_config_true(context), | ||
}, | ||
{ | ||
ResourceName: "google_workbench_instance.instance", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{"name", "instance_owners", "location", "instance_id", "request_id", "labels", "terraform_labels"}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccWorkbenchInstance_shielded_config_true(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_workbench_instance" "instance" { | ||
name = "tf-test-workbench-instance%{random_suffix}" | ||
location = "us-central1-a" | ||
gce_setup { | ||
shielded_instance_config { | ||
enable_secure_boot = true | ||
enable_vtpm = true | ||
enable_integrity_monitoring = true | ||
} | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccWorkbenchInstance_shielded_config_false(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_workbench_instance" "instance" { | ||
name = "tf-test-workbench-instance%{random_suffix}" | ||
location = "us-central1-a" | ||
gce_setup { | ||
shielded_instance_config { | ||
enable_secure_boot = false | ||
enable_vtpm = false | ||
enable_integrity_monitoring = false | ||
} | ||
} | ||
} | ||
`, context) | ||
} | ||
|
||
func testAccWorkbenchInstance_shielded_config_none(context map[string]interface{}) string { | ||
return acctest.Nprintf(` | ||
resource "google_workbench_instance" "instance" { | ||
name = "tf-test-workbench-instance%{random_suffix}" | ||
location = "us-central1-a" | ||
} | ||
`, context) | ||
} |
Oops, something went wrong.