fix possible error from nil check (#1942)

This commit is contained in:
emily 2018-08-27 16:22:06 -07:00 committed by GitHub
parent 7e82a982e4
commit 83406c3c5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1379,7 +1379,7 @@ func resourceComputeInstanceUpdate(d *schema.ResourceData, meta interface{}) err
if d.HasChange("service_account.0.email") || scopesChange {
sa := d.Get("service_account").([]interface{})
req := &compute.InstancesSetServiceAccountRequest{ForceSendFields: []string{"email"}}
if len(sa) > 0 {
if len(sa) > 0 && sa[0] != nil {
saMap := sa[0].(map[string]interface{})
req.Email = saMap["email"].(string)
req.Scopes = canonicalizeServiceScopes(convertStringSet(saMap["scopes"].(*schema.Set)))