---
title: "How to connect to the JSU Cloud PROD database (internal)"
canonical: "https://support.appfire.com/space/JSUCLOUD/3963748353/How+to+connect+to+the+JSU+Cloud+PROD+database+(internal)"
format: markdown
---
> 🔒 **Internal — engineering only.** This page lives in a public docs space and is restricted. Do not remove the restrictions. Source: JSUCLOUD-4903 (restoring DB client access after the key-rotation incident).

The prod database is private. You reach it through a tunnel on the **Bastion** EC2 using AWS SSO + Session Manager, then connect pgAdmin to `localhost`.

> ⚠️ This is **production**. Stick to read-only queries unless you really mean to change data.

---

## One-time setup

### Step 1 — Install the tools

```shell
brew install awscli
brew install --cask session-manager-plugin

```

### Step 2 — Add the AWS SSO profile

Open `~/.aws/config` and paste at the end:

```ini
[sso-session appfire]
sso_start_url = https://appfire.awsapps.com/start
sso_region = us-east-1
sso_registration_scopes = sso:account:access

[profile beecom-prod]
sso_session = appfire
sso_account_id = 949069865269
sso_role_name = AdministratorAccess
region = us-east-2
output = json

```

> On Netskope? Also add `ca_bundle = <path to your Netskope .pem>` under `[profile beecom-prod]`.

### Step 3 — Log in and check

```shell
aws sso login --sso-session appfire
aws sts get-caller-identity --profile beecom-prod

```

A browser opens — approve it. The second command should show account `949069865269`.

### Step 4 — Create the tunnel script

```shell
mkdir -p ~/.local/bin
cat > ~/.local/bin/db-tunnel <<'EOF'
#!/usr/bin/env bash
set -euo pipefail
PROFILE="beecom-prod"
aws sts get-caller-identity --profile "$PROFILE" >/dev/null 2>&1 || aws sso login --sso-session appfire
echo "Tunnel open on localhost:15432 — leave this running. Ctrl+C to close."
exec aws ssm start-session --profile "$PROFILE" --region us-east-2 \
  --target i-09b9d9141b03eb01f \
  --document-name AWS-StartPortForwardingSessionToRemoteHost \
  --parameters '{"host":["jsu-cloud-db-prod.cv6yqwafu9qo.us-east-2.rds.amazonaws.com"],"portNumber":["5432"],"localPortNumber":["15432"]}'
EOF
chmod +x ~/.local/bin/db-tunnel

```

> Make sure `~/.local/bin` is on your `PATH` (`echo $PATH`). If not, add `export PATH="$HOME/.local/bin:$PATH"` to `~/.zshrc` and open a new terminal.

### Step 5 — Add the server in pgAdmin 4

**Object → Register → Server…** and fill in:

| Tab | Field | Value |
| --- | --- | --- |
| General | Name | `production JSU cloud (SSM tunnel)` |
| Connection | Host name/address | `localhost` |
| Connection | Port | `15432` |
| Connection | Maintenance database | `jsucloud` |
| Connection | Username | `jsucloud` |
| Connection | Password | *(ask the team)* — tick **Save password** |
| Parameters | SSL mode | `require` |

Click **Save**.

---

## Every time you connect

### Step 1 — Open the tunnel

```shell
db-tunnel

```

Wait for `Waiting for connections...` and **leave the terminal open**. If your SSO login expired, a browser opens first — approve it.

### Step 2 — Connect in pgAdmin

Click **production JSU cloud (SSM tunnel)**. Done.

### Step 3 — Close when finished

Press `Ctrl+C` in the tunnel terminal.

---

## If something goes wrong

| Problem | Fix |
| --- | --- |
| pgAdmin: *connection refused* | The tunnel isn't running — run `db-tunnel` |
| pgAdmin suddenly disconnects | Tunnel closes after ~20 min idle — run `db-tunnel` again |
| `Token has expired` | `aws sso login --sso-session appfire` |
| `Address already in use` | A tunnel is already open — use it, or close the other terminal |
| `SessionManagerPlugin is not found` | `brew reinstall --cask session-manager-plugin`, open a new terminal |
| SSL error | SSL mode must be `require` (not `verify-full`) |

---

## Reference

| Item | Value |
| --- | --- |
| AWS account | Appfire Beecom (Prod) — `949069865269` |
| SSO portal | [https://appfire.awsapps.com/start](https://appfire.awsapps.com/start) |
| Region | `us-east-2` |
| Bastion EC2 | `i-09b9d9141b03eb01f` (`Bastion`) |
| RDS endpoint | `jsu-cloud-db-prod.cv6yqwafu9qo.us-east-2.rds.amazonaws.com:5432` |
| Database / user | `jsucloud` / `jsucloud` |
| psql (with tunnel open) | `psql "postgresql://jsucloud@localhost:15432/jsucloud?sslmode=require"` |