|
| 1 | +--- |
| 2 | +meta: |
| 3 | + title: How to use Private Networks with your Serverless Functions |
| 4 | + description: This page explains how to use Private Networks for Scaleway Serverless Functions |
| 5 | +content: |
| 6 | + h1: How to use Private Networks with your Serverless Functions |
| 7 | + paragraph: This page explains how to use Private Networks for Scaleway Serverless Functions |
| 8 | +tags: private-networks private networks instance functions vpc |
| 9 | +dates: |
| 10 | + validation: 2025-06-25 |
| 11 | + posted: 2021-06-25 |
| 12 | +categories: |
| 13 | + - serverless |
| 14 | +--- |
| 15 | + |
| 16 | +[Private Networks](/vpc/concepts/#private-networks) allow your Serverless Functions to communicate in an isolated and secure network without needing to be connected to the public internet. Each function can be connected to one or several Private Networks, letting you build your own network topologies. |
| 17 | + |
| 18 | +For full information about Scaleway Private Networks and VPC, see our [dedicated documentation](/vpc/) and [best practice guide](/vpc/reference-content/getting-most-private-networks/). |
| 19 | + |
| 20 | +<Message type="important"> |
| 21 | +The Private Networks feature can only be enabled on newly created namespaces. Existing namespaces that do not have the feature enabled cannot be integrated in a Private Network. |
| 22 | +</Message> |
| 23 | + |
| 24 | +<Macro id="requirements" /> |
| 25 | + |
| 26 | +- A Scaleway account logged into the [console](https://console.scaleway.com) |
| 27 | +- [Owner](/iam/concepts/#owner) status or [IAM permissions](/iam/concepts/#permission) allowing you to perform actions in the intended Organization |
| 28 | +- [Created a Private Network](/vpc/how-to/create-private-network/) |
| 29 | + |
| 30 | + |
| 31 | +## How to create a Private Networks-enabled namespace |
| 32 | + |
| 33 | +Before attaching a Private Network to a Serverless Function, you must create it within a namespace with the Private Networks feature enabled. |
| 34 | + |
| 35 | +1. Click **Functions** in the **Serverless** section of the side menu. The functions page displays. |
| 36 | + |
| 37 | +2. Click **+ Create namespace**. If you have no existing Serverless Functions resources in your current Project, click **Create a function**. The functions namespace creation wizard displays. |
| 38 | + |
| 39 | +3. Complete the following steps in the wizard: |
| 40 | + - Enter a **name** or use the automatically generated one. The name can only contain lowercase alphanumeric characters and dashes. |
| 41 | + - Enter an optional **description** and **tags**. |
| 42 | + - Choose a **region**, which is the geographical location in which your namespace will be deployed. |
| 43 | + - Tick the **Enable VPC support** box. This parameter cannot be edited once the the namespace is created. |
| 44 | + - Click **+ Add advanced options** to define any **environment variables** you want to inject into your function. For each environment variable, click **+ Add variable** and enter the key/value pair. |
| 45 | + - Set optional secret environment variables. **Secrets** are environment variables which are injected into your function and stored securely, but not displayed in the console after initial validation. Add a **key** and a **value**. |
| 46 | +4. Click **Create namespace only** to finish, or click **Create namespace and add a function** if you want to [create a function](/serverless-functions/how-to/create-a-function/) next. |
| 47 | + |
| 48 | +## How to attach a Serverless Function to a Private Network |
| 49 | + |
| 50 | +<Tabs id="private-network-functions"> |
| 51 | + <TabsTab label="Existing function"> |
| 52 | + 1. Click **Functions** in the **Serverless** section of the side menu. The functions page displays. |
| 53 | + 2. Click the relevant functions namespace. |
| 54 | + 3. Click the name of the function you want to manage. |
| 55 | + 4. Open the **Settings** tab, then scroll to the **Advanced options** section. |
| 56 | + 5. In the **VPC** tab, select a Private Network from the dropdown menu. |
| 57 | + 6. Click **Save function settings**. |
| 58 | + |
| 59 | + Your function is redeployed, and is now attached to the selected Private Network. |
| 60 | +</TabsTab> |
| 61 | +<TabsTab label="New function"> |
| 62 | + 1. Click **Functions** in the **Serverless** section of the side menu. The functions page displays. |
| 63 | + 2. Click the **Private Networks-enabled** functions namespace in which you want to create your function. |
| 64 | + 3. Click **+ Create function**. The function creation wizard displays. |
| 65 | + 4. Scroll to the **Advanced options** section. |
| 66 | + 5. In the **VPC** tab, select a Private Network from the dropdown menu. |
| 67 | + 6. Configure the other parameters of your function, then click **Create function**. Refer to the [How to create a function](/serverless-functions/how-to/create-a-function/) for more information. |
| 68 | + |
| 69 | + Your new function is deployed, and is attached to the selected Private Network. |
| 70 | + </TabsTab> |
| 71 | +</Tabs> |
| 72 | + |
| 73 | +## How to detach a function from a Private |
0 commit comments