mik-laj commented on code in PR #22910:
URL: https://github.com/apache/airflow/pull/22910#discussion_r847523711
##########
airflow/providers/google/cloud/hooks/compute_ssh.py:
##########
@@ -215,7 +226,22 @@ def get_conn(self) -> paramiko.SSHClient:
self._authorize_compute_engine_instance_metadata(pubkey)
proxy_command = None
- if self.use_iap_tunnel:
+ if self.use_iap_tunnel and self.impersonation_chain:
+ proxy_command_args = [
+ 'gcloud',
+ 'compute',
+ 'start-iap-tunnel',
+ str(self.instance_name),
+ '22',
+ '--listen-on-stdin',
+ f'--project={self.project_id}',
+ f'--zone={self.zone}',
+ '--verbosity=warning',
+ f'--impersonate-service-account={self.impersonation_chain}',
+ ]
+ proxy_command = " ".join(shlex.quote(arg) for arg in
proxy_command_args)
+
+ elif self.use_iap_tunnel:
Review Comment:
Can you add a new item to `proxy_command_args` variables instead of
duplicating so much code?
```python
if self.impersonation_chain:
proxy_command_args.append(f'--impersonate-service-account={self.impersonation_chain}')
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]