Skip to content

Latest commit

 

History

History
76 lines (48 loc) · 3 KB

remote-development.md

File metadata and controls

76 lines (48 loc) · 3 KB

Remote Development

There will be times when a developer needs access to a container or a remote machine to debug a running application, or to change source code without needing to trigger a formal deployment. This document specifically describes how to use the Cloud.gov environments where TDRS is deployed as development environments.

Tools

Visual Studio Code

This guide presumes the use of VS Code with the Remote Development extension pack. You can achieve a similar setup on other IDEs or in the terminal (as this all uses OpenSSH underneath); please save yourself the time and just go download VS Code.

cf-cli

Additionally, install the latest version of the Cloudfoundry CLI if you haven't.

  • Important: There are issues with cf-cli versions below 7.0 so I suggest grabbing the latest version.

To get the latest version as of this writing (on macOS):

brew install cloudfoundry/tap/cf-cli@7

Access Cloudfoundry

Login to CloudFoundry with the CLI:

 cf login -a api.fr.cloud.gov  --sso

Get App GUID

Use curl to get the process GUID of the application on deployed application you want to connect to; replace <app-name> with a string like tdp-backend-raft. You can see a list of currently running app names with cf apps.

cf curl /v3/apps/$(cf app <app-name> --guid)/processes | jq --raw-output '.resources | .[] | select(.type == "web").guid'

This GUID will be used to construct the User name of the SSH connection.

Create an SSH Config

Create a file ~/username/.ssh/config if one doesn't exist, and append the Host setting below:

# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
Host <app-name>
    HostName ssh.fr.cloud.gov
    User cf:<guid>/0
    Port 2222

Where <guid> is the string received in the last step. The User setting should look like this: User cf:38f6a064-4ba7-4693-8732-960dea9f32f8/0. Note the /0 at the end of the string is the ID of the instance.

To connect with ssh from the terminal:

ssh -p 2222 cf:<guid>/[email protected]

Get a One Time Password

In VS Code, open the command menu (ctrl/cmd+shift+p), type "Remote-SSH", and select "Connect Current Window to Host". This should automatically look at the previously created config, and now prompt you for a one time password.

cf ssh-code

Navigate to Application Code

You should now be connected to the remote host, and need only navigate to the directory containing the application code you want to change (likely /home/vcap/app/).

Note that redeploying or restaging will wipe all changes made remotely.

Useful Links

VS Code Remote Overview Jetbrains Remote development