fix: use default service account if unset (#572)

`service_account_email` defaults to None if one
is not set. For gcp_compute_instance_info, this results
in an invalid request as the service account is populated
directly in the path.

Populating `default` when a value is not set fixes the error.

fixes #568
This commit is contained in:
Yusuke Tsutsumi 2023-06-10 11:39:44 -07:00 committed by GitHub
parent 203961b045
commit 30a4e66363
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -251,8 +251,9 @@ class GcpSession(object):
return svc_acct_creds.with_scopes(self.module.params['scopes'])
if cred_type == 'machineaccount':
return google.auth.compute_engine.Credentials(
self.module.params['service_account_email'])
email = self.module.params['service_account_email']
email = email if email is not None else "default"
return google.auth.compute_engine.Credentials(email)
if cred_type == 'accesstoken':
access_token = self.module.params['access_token']