cf-service-connect
cf-service-connect copied to clipboard
Cloud Foundry CLI Service Connection Plugin
Cloud Foundry CLI Service Connection Plugin 
This plugin makes it easy to connect to your databases or other Cloud Foundry service instances from your local machine. This condenses the steps listed in Accessing Services with SSH to a single command.

Requires Diego architecture with SSH enabled.
Support
Currently supports (most) service brokers for the following:
- MongoDB (requires
mongoshell) - MySQL (requires
mysqlCLI) - PostgreSQL (requires
psqlCLI) - Redis (requires
redis-cli)
Local installation
-
Install the Cloud Foundry CLI v6.15.0 or later.
-
Install this plugin, using the appropriate binary URL from the Releases page.
cf install-plugin <binary_url> # will be of the format # https://github.com/cloud-gov/cf-service-connect/releases/download/<version>/cf-service-connect_<os>-<arch> # For non-M1 Macs, use `cf-service-connect_darwin_amd64` # For M1 Macs, use `cf-service-connect_darwin_arm64` -
Install the CLI corresponding to your service type (see above).
Usage
Note If you are using this tool to connect to a service on cloud.gov, your space must be configured with the
trusted_local_networks_egresssecurity group. Do this by runningcf bind-security-group trusted_local_networks_egress ORG --space SPACEwith your organization and space. Skipping this step will result in aconnection refusederror. For more, see cloud.gov: Controlling egress traffic.
app_nameis the name of the app in your space you want to tunnel through.service_instance_nameis the service instance you wish to connect to.
$ cf target --organization <org> --space <space>
$ cf connect-to-service <app_name> <service_instance_name>
Finding the service instance details...
Setting up SSH tunnel...
...
mysql>
If you get an error such as "connection refused", "error opening SSH connection", or "psql: could not connect to server: Connection refused" this is usually caused by being on a network that blocks the SSH port that this tool is trying to use. Try using a different network, or consider asking your network administrator to unblock the port (typically 22 and/or 2222).
Optional: overriding cf CLI binary name
If you are in Windows or another environment where the Cloud Foundry CLI was installed as cf7 or cf8, you can set an environment to tell the plugin what binary name to use for the Cloud Foundry CLI:
CF_BINARY_NAME=cf7 cf connect-to-service <app_name> <service_instance_name>
Or in PowerShell:
$env:CF_BINARY_NAME = "cf7";
cf7 connect-to-service <app_name> <service_instance_name>
Manual client connection
If you're using a non-default client (such as a GUI), run with the -no-client option to set up your client connection on your own.
Contributing
See CONTRIBUTING.md