Connect to services

Now that you have a local copy of your application code, you can make changes to the project without pushing to each time to test them. Instead you can locally build your application using the CLI, even when its functionality depends on a number of services.

  1. Open an SSH tunnel to connect to your services

    Open local SSH tunnels to your environment’s services.

    platform tunnel:open
  2. Export environment variables utilizes environment variables called Relationships within the application container. These store the credentials needed to connect to individual services. In order to connect with them remotely using the SSH tunnel you will need to mimic the same environment variables locally.

    export PLATFORM_RELATIONSHIPS="$(platform tunnel:info --encode)"

    In order to use these credentials to connect to your services, it may also be necessary to install the clients for those services are locally.

    Additionally, if your application also needs access to the PORT environment variable, you can mock the variable used in a environment with

    export PORT=8888

    If you are using a Config Reader library with the application, it will also be necessary to mock two additional variables

    export PLATFORM_APPLICATION_NAME=< name, i.e. app>
    export PLATFORM_BRANCH=<branch being built, i.e. dev>
  3. Verify

    You can visualize the open tunnels for your application with the command

    platform tunnel:list

    The tunnel will close itself after a timeout period of inactivity, but you can also do so with the command

    platform tunnel:close

Now that you have created an SSH tunnel to your services, build your application locally.