Skip to main content
Version: Next

Connecting to Managed Services

Once your managed service is deployed, you can connect to it from your Codesphere workspaces. Each service lists non-sensitive connection details in their respective settings page, in the overview tab (or in the details property in the public API payload). This guide provides examples for connecting to common services.

Prerequisites

Ensure your workspace and the managed service are in the same team to allow for network access.

PostgreSQL

Codesphere provides a standard PostgreSQL service. You can connect to it using any PostgreSQL compatible client, such as psql or Node.js libraries like pg.

Connection Details

You can find these in the service details page:

  • Host/DSN: The internal hostname or full connection string with redacted password.
  • Port: 5432 (Standard PostgreSQL port).
  • Username: Defined during setup (for root user postgres or your custom username that you provided).
  • Password: The secret you provided during setup for the specified username.

You can use the psql command-line tool directly from your workspace terminal.

# Install psql
nix-env -iA nixpkgs.postgresql

# General syntax
psql "postgres://<username>:<password>@<hostname>:5432/<database>"

# Example
psql "postgres://admin:secure-password@10.0.0.5:5432/mydb"

Babelfish (SQL Server Compatible)

Babelfish for PostgreSQL allows it to understand the T-SQL protocol, making it compatible with SQL Server clients.

Connection Details

  • Host/DSN: The internal hostname or full connection string with redacted password.
  • Port: 1433 (Standard SQL Server port).
  • Username: postgres (you can create additional users after provisioning).
  • Password: As configured.

You can use tsql (part of the FreeTDS package) to connect. Note that tsql might need to be installed in your workspace.

# Install FreeTDS
nix-env -iA nixpkgs.freetds

# Syntax
tsql -H <hostname> -p 1433 -U <username> -P <password> -D <database>

# Example
tsql -H 10.0.0.12 -p 1433 -U admin -P superSecret -D myDatabase

S3 (Object Storage)

The S3 Managed Service provides an S3-compatible object storage API.

Connection Details

  • Endpoint: The URL of the service (e.g., http://10.0.0.20:9000).
  • Access Key: Generated during setup.
  • Secret Key: Generated during setup.

The MinIO Client (mc) is a robust tool for interacting with S3-compatible APIs.

# 1. install
nix-env -iA nixpkgs.minio-client

# 2. Configure alias
mc alias set my-storage http://10.0.0.20:9000 <ACCESS_KEY> <SECRET_KEY>

# 3. List buckets
mc ls my-storage

# 4. Copy file
mc cp myfile.txt my-storage/my-bucket/