@@ -851,6 +851,48 @@ func TestAccComputeInstance_serviceAccount_updated(t *testing.T) {
851851 })
852852}
853853
854+ func TestAccComputeInstance_serviceAccount_updated0to1to0scopes (t * testing.T ) {
855+ t .Parallel ()
856+
857+ var instance compute.Instance
858+ var instanceName = fmt .Sprintf ("tf-test-%s" , randString (t , 10 ))
859+
860+ vcrTest (t , resource.TestCase {
861+ PreCheck : func () { testAccPreCheck (t ) },
862+ Providers : testAccProviders ,
863+ CheckDestroy : testAccCheckComputeInstanceDestroyProducer (t ),
864+ Steps : []resource.TestStep {
865+ {
866+ Config : testAccComputeInstance_serviceAccount_update01 (instanceName ),
867+ Check : resource .ComposeTestCheckFunc (
868+ testAccCheckComputeInstanceExists (
869+ t , "google_compute_instance.foobar" , & instance ),
870+ testAccCheckComputeInstanceScopes (& instance , 0 ),
871+ ),
872+ },
873+ computeInstanceImportStep ("us-central1-a" , instanceName , []string {"allow_stopping_for_update" }),
874+ {
875+ Config : testAccComputeInstance_serviceAccount_update4 (instanceName ),
876+ Check : resource .ComposeTestCheckFunc (
877+ testAccCheckComputeInstanceExists (
878+ t , "google_compute_instance.foobar" , & instance ),
879+ testAccCheckComputeInstanceScopes (& instance , 1 ),
880+ ),
881+ },
882+ computeInstanceImportStep ("us-central1-a" , instanceName , []string {"allow_stopping_for_update" }),
883+ {
884+ Config : testAccComputeInstance_serviceAccount_update01 (instanceName ),
885+ Check : resource .ComposeTestCheckFunc (
886+ testAccCheckComputeInstanceExists (
887+ t , "google_compute_instance.foobar" , & instance ),
888+ testAccCheckComputeInstanceScopes (& instance , 0 ),
889+ ),
890+ },
891+ computeInstanceImportStep ("us-central1-a" , instanceName , []string {"allow_stopping_for_update" }),
892+ },
893+ })
894+ }
895+
854896func TestAccComputeInstance_scheduling (t * testing.T ) {
855897 t .Parallel ()
856898
@@ -4009,6 +4051,34 @@ resource "google_compute_instance" "foobar" {
40094051` , instance )
40104052}
40114053
4054+ func testAccComputeInstance_serviceAccount_update4 (instance string ) string {
4055+ return fmt .Sprintf (`
4056+ data "google_compute_image" "my_image" {
4057+ family = "debian-9"
4058+ project = "debian-cloud"
4059+ }
4060+ resource "google_compute_instance" "foobar" {
4061+ name = "%s"
4062+ machine_type = "e2-medium"
4063+ zone = "us-central1-a"
4064+ boot_disk {
4065+ initialize_params {
4066+ image = data.google_compute_image.my_image.self_link
4067+ }
4068+ }
4069+ network_interface {
4070+ network = "default"
4071+ }
4072+ service_account {
4073+ scopes = [
4074+ "userinfo-email",
4075+ ]
4076+ }
4077+ allow_stopping_for_update = true
4078+ }
4079+ ` , instance )
4080+ }
4081+
40124082func testAccComputeInstance_scheduling (instance string ) string {
40134083 return fmt .Sprintf (`
40144084data "google_compute_image" "my_image" {
0 commit comments