- Secure zone that consists of virtual machine (VMs) created in Nebius AI Cloud
- Demilitarized zone (DMZ) that consists of machines outside Nebius AI Cloud
- You can use one public IP address to access all VMs.
- You can keep the number of public addresses within a quota.
- You can limit access to the secure zone and allow only authorized machines to connect to the secure zone.
Costs
The tutorial includes the following chargeable resources:Prerequisites
- Install Terraform.
-
Install and configure CLI for Nebius AI Cloud. The Terraform-based solution uses the CLI to get credentials.
For enhanced security, use a service account to configure the CLI. Make sure that this account is in a group that has at least the
editorrole within your tenant; for example, the defaulteditorsgroup. You can check this in the Administration → IAM section of the web console. -
Install
jq: -
Clone the nebius-solution-library repository from where the WireGuard solution is going to be deployed:
-
Create an SSH key pair for the virtual machine:
-
Run the following command:
- Enter the file name where to store the key pair.
- (Optionally) Enter a passphrase.
-
Run the following command:
Steps
Deploy infrastructure
-
In your terminal, go to the
wireguarddirectory in the cloned repository: -
In the
environment.shfile in this directory, uncomment the following variables and specify values for them:NEBIUS_TENANT_ID: The tenant ID. To copy it, go to the web console and expand the top-left tenants list. Next to the tenant’s name, click→ Copy tenant ID.
NEBIUS_PROJECT_ID: The project ID. To copy it, go to the web console and expand a top-left list of projects. Next to the project’s name, click→ Copy project ID.
NEBIUS_REGION: Specify the region where your project is located. You can find the region in the web console, in the list of projects.
-
Run the script that creates an access token for Terraform, saves the token to environment variables and configures Terraform state to be saved in Object Storage:
-
Initialize Terraform in the
wireguarddirectory: -
In the
terraform.tfvarsfile in this directory, uncomment the following variables and specify values for them:-
ssh_user_name: The user required for an SSH connection to the VM, for exampleuser1. -
ssh_public_key: The public SSH key that you created earlier. Specify either the key body or the path to this key. -
public_ip_allocation_id: An ID of an allocation with a public IP address. The WireGuard UI will be available at this address. To preserve the address even in case of the VM deletion, create the allocation:The command returns the allocation ID. Specify it in thepublic_ip_allocation_idvariable.
-
-
Preview the configuration that you are going to deploy:
-
Apply the changes:
When the command is finished, it returns the VM public address:Copy the address: It is required to connect to the deployed VM.
Access WireGuard
-
Connect to the VM:
The command contains:
- Path to the private SSH key that you created earlier
- Username specified in the
terraform.tfvarsfile - Public IP address of the deployed VM
-
Get the WireGuard UI password:
-
In the browser, open the WireGuard UI at
http://<public_IP_address>:5000. -
In the window that opens, sign in with the
adminusername and the password retrieved from the VM. The working space of the WireGuard UI opens.
Configure WireGuard
Set up a VPN and grant access to the VMs in the secure zone. To do this, add the DMZ machines as WireGuard clients:-
Click
New client.
- In the window that opens, specify details of the machines that require access. In the Allowed IPs field, enter CIDRs of these machines.
- Click Submit.
- After the window is closed, click Apply config. Click this button every time after you create, change or delete WireGuard clients.