Skip to content

Commit 29b9ef9

Browse files
fix(rdb): ssh bastion connection (#4874)
1 parent 1a09064 commit 29b9ef9

File tree

7 files changed

+76
-13
lines changed

7 files changed

+76
-13
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
macro: ssh-bastion-mdb
3+
---
4+
5+
<Message type="note">
6+
Managed MongoDB® is currently not compatible with the [Static NAT](/public-gateways/concepts/#nat) feature of [Scaleway Public Gateways](/public-gateways/concepts/#public-gateway). Instead, you can use Public Gateways' [SSH bastion](/public-gateways/how-to/use-ssh-bastion/) feature and perform port forwarding. Follow the steps below to connect using SSH bastion.
7+
</Message>
8+
9+
If you want to connect locally to a Database Instance that is not accessible via the public internet, you can use SSH Bastion and connect it to the same Private Network the Database Instance is connected to.
10+
11+
1. Open an SSH tunnel with port forwarding:
12+
13+
```
14+
ssh -L local_port:instance_id.network_id.internal:27017 bastion@gatewayIP -p 61000 -N
15+
```
16+
17+
2. Connect using `mongosh`:
18+
19+
```
20+
mongosh --host localhost --port local_port --username "username"
21+
```

macros/databases/ssh-bastion.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
macro: ssh-bastion
3+
---
4+
5+
<Message type="important">
6+
Managed Databases for PostgreSQL and MySQL are currently not compatible with the [Static NAT](/public-gateways/concepts/#nat) feature of [Scaleway Public Gateways](/public-gateways/concepts/#public-gateway). Instead, you can use Public Gateways' [SSH bastion](/public-gateways/how-to/use-ssh-bastion/) feature and perform port forwarding. Follow the steps below to connect using SSH bastion.
7+
</Message>
8+
9+
If you want to connect locally to a Database Instance that is not accessible via the public internet, you can use SSH bastion and connect it to the same Private Network the Database Instance is connected to.
10+
11+
1. Open an SSH tunnel with port forwarding:
12+
13+
```
14+
ssh -L <local_port>:<database_private_ip>:<database_port> bastion@<bastion_ip> -p<bastion_port> -N
15+
```
16+
17+
2. Connect using `psql`:
18+
19+
```
20+
psql -h localhost --port <local_port> -d <database> -U <user>
21+
```

menu/navigation.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,6 +2209,10 @@
22092209
"label": "Connect to a Database Instance",
22102210
"slug": "connect-database-instance"
22112211
},
2212+
{
2213+
"label": "Connect a Database Instance to a Private Network",
2214+
"slug": "connect-database-private-network"
2215+
},
22122216
{
22132217
"label": "Create a database",
22142218
"slug": "add-a-database"
@@ -2281,10 +2285,6 @@
22812285
"label": "Apply scheduled maintenance",
22822286
"slug": "apply-maintenance"
22832287
},
2284-
{
2285-
"label": "Connect a Database Instance to a Private Network",
2286-
"slug": "connect-database-private-network"
2287-
},
22882288
{
22892289
"label": "Remove a public endpoint",
22902290
"slug": "remove-public-endpoint"
@@ -2475,6 +2475,10 @@
24752475
"label": "Quickstart",
24762476
"slug": "quickstart"
24772477
},
2478+
{
2479+
"label": "FAQ",
2480+
"slug": "faq"
2481+
},
24782482
{
24792483
"items": [
24802484
{

pages/managed-databases-for-postgresql-and-mysql/faq.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,8 @@ Quotas exist to protect Scaleway from abuse, and to protect your Scaleway resour
143143

144144
When it comes to automatic data preservation, however, Scaleway prioritizes the resilience of your data. Therefore, if a Database Instance has autobackup set up, even if the quota is exceeded, the backup or snapshot will still be automatically created.
145145

146-
You can monitor your [quotas](https://console.scaleway.com/organization/quotas), backups and snapshots via the Scaleway console or the API.
146+
You can monitor your [quotas](https://console.scaleway.com/organization/quotas), backups and snapshots via the Scaleway console or the API.
147+
148+
## How can I connect to a Database Instance in a Private Network using Public Gateways?
149+
150+
<Macro id="ssh-bastion" />

pages/managed-databases-for-postgresql-and-mysql/how-to/connect-database-private-network.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@ You can create new Database Instances to attach to your Private Network, or atta
5757
</Message>
5858
6. Click **Attach to Private Network** to conclude.
5959

60-
<Message type="important">
61-
Managed Databases for PostgreSQL and MySQL are currently not compatible with the [Static NAT](/public-gateways/concepts/#nat) feature of [Scaleway Public Gateways](/public-gateways/concepts/#public-gateway).
60+
## How to connect to a Database Instance through a Public Gateway
6261

63-
You can use Public Gateways in [SSH bastion](/public-gateways/how-to/use-ssh-bastion/) mode and perform port forwarding.
64-
</Message>
62+
<Macro id="ssh-bastion" />
6563

6664
## How to detach a Database Instance from a Private Network
6765

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
meta:
3+
title: Managed MongoDB® FAQ
4+
description: Learn about Managed MongoDB® and how to get started with your MongoDB® Database Instances.
5+
content:
6+
h1: Managed MongoDB® FAQ
7+
dates:
8+
validation: 2025-01-29
9+
category: managed-databases
10+
productIcon: MongoDBProductIcon
11+
---
12+
13+
## How can I connect to a Database Instance in a Private Network using Public Gateways?
14+
15+
<Macro id="ssh-bastion-mdb" />

pages/managed-mongodb-databases/how-to/connect-database-private-network.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ You can [create new Database Instances](/managed-mongodb-databases/how-to/create
4848
</Message>
4949
6. Click **Attach to Private Network** to conclude.
5050

51-
<Message type="note">
52-
Managed MongoDB® is currently not compatible with the [Static NAT](/public-gateways/concepts/#nat) feature of [Scaleway Public Gateways](/public-gateways/concepts/#public-gateway). You can use Public Gateways in [SSH bastion](/public-gateways/how-to/use-ssh-bastion/) mode and perform port forwarding.
53-
</Message>
54-
5551
<Message type="tip">
5652
Once you have attached your Database Instance to a Private Network, you can [connect to the Database Instance](/managed-mongodb-databases/how-to/connect-database-instance) using the private endpoint connection string.
5753
</Message>
5854

55+
## How to connect to a Database Instance through a Public Gateway
56+
57+
<Macro id="ssh-bastion-mdb" />
58+
5959
## How to detach a Database Instance from a Private Network
6060

6161
1. Click **MongoDB®** under **Managed Databases** on the side menu. A list of your Database Instances displays.

0 commit comments

Comments
 (0)