Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2242,7 +2242,11 @@ func hash256(raw string) (string, error) {
}

func serviceAccountDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
o, n := d.GetChange(strings.TrimSuffix(k, ".#"))
if k != "service_account.#" {
return false
}

o, n := d.GetChange("service_account")
var l []interface{}
if old == "0" && new == "1" {
l = n.([]interface{})
Expand Down
70 changes: 70 additions & 0 deletions mmv1/third_party/terraform/tests/resource_compute_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,48 @@ func TestAccComputeInstance_serviceAccount_updated(t *testing.T) {
})
}

func TestAccComputeInstance_serviceAccount_updated0to1to0scopes(t *testing.T) {
t.Parallel()

var instance compute.Instance
var instanceName = fmt.Sprintf("tf-test-%s", randString(t, 10))

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeInstance_serviceAccount_update01(instanceName),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeInstanceExists(
t, "google_compute_instance.foobar", &instance),
testAccCheckComputeInstanceScopes(&instance, 0),
),
},
computeInstanceImportStep("us-central1-a", instanceName, []string{"allow_stopping_for_update"}),
{
Config: testAccComputeInstance_serviceAccount_update4(instanceName),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeInstanceExists(
t, "google_compute_instance.foobar", &instance),
testAccCheckComputeInstanceScopes(&instance, 1),
),
},
computeInstanceImportStep("us-central1-a", instanceName, []string{"allow_stopping_for_update"}),
{
Config: testAccComputeInstance_serviceAccount_update01(instanceName),
Check: resource.ComposeTestCheckFunc(
testAccCheckComputeInstanceExists(
t, "google_compute_instance.foobar", &instance),
testAccCheckComputeInstanceScopes(&instance, 0),
),
},
computeInstanceImportStep("us-central1-a", instanceName, []string{"allow_stopping_for_update"}),
},
})
}

func TestAccComputeInstance_scheduling(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -4009,6 +4051,34 @@ resource "google_compute_instance" "foobar" {
`, instance)
}

func testAccComputeInstance_serviceAccount_update4(instance string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
family = "debian-9"
project = "debian-cloud"
}
resource "google_compute_instance" "foobar" {
name = "%s"
machine_type = "e2-medium"
zone = "us-central1-a"
boot_disk {
initialize_params {
image = data.google_compute_image.my_image.self_link
}
}
network_interface {
network = "default"
}
service_account {
scopes = [
"userinfo-email",
]
}
allow_stopping_for_update = true
}
`, instance)
}

func testAccComputeInstance_scheduling(instance string) string {
return fmt.Sprintf(`
data "google_compute_image" "my_image" {
Expand Down