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.

  • extra__google_cloud_platform__instance_name - The name of the Compute Engine instance.

  • extra__google_cloud_platform__zone - The zone of the Compute Engine instance.

  • extra__google_cloud_platform__use_internal_ip - Whether to connect using internal IP.

  • extra__google_cloud_platform__use_iap_tunnel - Whether to connect through IAP tunnel.

  • extra__google_cloud_platform__use_oslogin - Whether to manage keys using OsLogin API. If false,

    keys are managed using instance metadata.

  • extra__google_cloud_platform__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?\
extra__google_cloud_platform__instance_name=conn-instance-name&\
extra__google_cloud_platform__zone=zone&\
extra__google_cloud_platform__use_internal_ip=True&\
extra__google_cloud_platform__use_iap_tunnel=True&\
extra__google_cloud_platform__use_oslogin=False&\
extra__google_cloud_platform__expire_time=4242"

Was this entry helpful?