Google Cloud Platform SSH Connection

The SSH connection type provides connection to Compute Engine Instance. The ComputeEngineSSHHook use it to run commands on a remote server using SSHOperator or transfer file from/to the remote server using SFTPOperator.

Configuring the Connection

For authorization to Google Cloud services, this connection should contain a configuration identical to the Google Cloud Connection. All parameters for a Google Cloud connection are also valid configuration parameters for this connection.

In addition, additional connection parameters to the instance are supported. It is also possible to pass them as the parameter of hook constructor, but the connection configuration takes precedence over the parameters of the hook constructor.

Host (required)

The Remote host to connect. If it is not passed, it will be detected automatically.

Username (optional)

The Username to connect to the remote_host.

Extra (optional)

Specify the extra parameters (as json dictionary) that can be used in ssh connection. The following parameters are supported in addition to those describing the Google Cloud connection.

  • instance_name - The name of the Compute Engine instance.

  • zone - The zone of the Compute Engine instance.

  • use_internal_ip - Whether to connect using internal IP.

  • use_iap_tunnel - Whether to connect through IAP tunnel.

  • use_oslogin - Whether to manage keys using OsLogin API. If false, keys are managed using instance metadata.

  • expire_time - The maximum amount of time in seconds before the private key expires.

Environment variable

You can also create a connection using an AIRFLOW_CONN_{CONN_ID} environment variable.

For example:

export AIRFLOW_CONN_GOOGLE_CLOUD_SQL_DEFAULT="gcpssh://conn-user@conn-host?\
instance_name=conn-instance-name&\
zone=zone&\
use_internal_ip=True&\
use_iap_tunnel=True&\
use_oslogin=False&\
expire_time=4242"

Was this entry helpful?