You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/04/11 16:31:37 UTC

[GitHub] [airflow] mik-laj commented on a diff in pull request #22910: Add impersonation_chain parameter for ComputeEngineSSHHook

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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org