How to connect Object Storage buckets to Instances with the Public Gateway feature

Overview

The Public Gateway feature of the Private Network allows Instances in your Private Network to reach resources on the Internet without using a public IP address.

In this documentation, you will learn how to create a Virtual Instance without a public IP address, create a Private Network with a Public Gateway, and a route from your instance to an Object Storage bucket.

Requirements

You have:

Creating an instance without a public IP

1 . Connect to your Scaleway Console and click on Instances in the Compute section of the side menu.

2 . Click on +Create an Instance to launch the instance creation wizard.

In this tutorial we create our Instance in in the Availability Zone (AZ) fr-par-2, but you can select the AZ of your choice.

3 . Enter the Instances’ details:

  • OS Image: Ubuntu 20.04 Focal Fossa
  • Instance type: DEV1-S
  • Advanced options: Untick the Flexible IP option

You can use this link to have your instance automatically configured with the required parameters. Click Create an Instance to launch the instance creation process.

If you have installed the Scaleway CLI tool, you can also create the instance using the following command:

scw instance server create type=DEV1-S zone=fr-par-1 image=ubuntu_bionic root-volume=l:20G name=objectstorage-over-pn ip=none

Creating a Private Network

1 . Click on the Private Networks tab to enter the corresponing section of the Scaleway conosle. A list of your existing private networks displays.

2 . Click Create a Private Network to launch the creation wizard.

3 . Enter the networks’ name, optional tags and the available zone. Make sure to select the same availability zone as for your previously created instance.

4 . The private network is created and you are redirected to the Private Network overview page.

5 . Click on your network name, then on the Instances tab.

6 . Add your Virtual Instance to the private network by typing its name in the search bar. Validate by clicking Add instance

Creating a Public Gateway

1 . Click on VPC in the Network section of the side menu in your Scaleway console.

2 . The VPC overview page displays. Click the Public Gateway tab, then Create a Public Gateway to launch the creation wizard.

3 . Select the availability zone for your public gateway. Make sure to deploy it in the same AZ as your Virtual Instance and the Private Network. Select a public gateway type according to your requirements. In this tutorial we use a VPC-GW-S type gateway. Leave the IP configuration empty to allocate a new IP to your Public Gateway. Then enter a name and tags (optional) for the gateway. Click Create a Public Gateway to launch the gateway creation.

4 . Once created, click on the gateways’ name, then Private Networks.

5 . Click Attach a new Private Network. A pop-up window displays. Select Attach an existing Private Network and choose your Private Network from the drop down list. Enable the DHCP server and set Dynamic NAT to active. Enter an IP-range for your Private Network - in this tutorial we use 192.168.42.0/24 but you are free to use any private IP range.

6 . Click Attach a Private Network.

Setting the Object Storage Route

1 . SSH into your machine using the following command:

ssh root@your_virtual_instance_ip

Note: As your Virtual Instance has no public IP address, you have to connect to it using another instance in your private network or assign a temporary public IP to it.

2 . Configure the following route to the Object Storage platform:

# set this to keep the network on the instance
$> ip route add 10.0.0.0/8 via `ip route | grep default | awk '{print $3} '` dev ens2
# dhcp on pn interface
$> dhclient ens5
# change default route
$> ip route del default via `ip route | grep default | awk '{print $3} '` dev ens2
$> ip route add default via 192.168.42.1 dev ens5 # use the gateway ip in the gateway's description
$> curl https://s3.fr-par.scw.cloud

Conclusion

You have now configured a Virtual Instance with a Private Network to communicate with Scaleway’s Object Storage platform using the Public Gateway feature. The gateway ensures the exchange of data between your Private Network and the public Internet.

Discover the Cloud That Makes Sense