How to Manage VPC Networks for Vultr Managed Databases for PostgreSQL

Updated on November 27, 2024

Vultr Virtual Private Cloud (VPC 2.0) networks offer the flexibility of choosing your own IP range and subnets to secure internal network communications. Attaching a virtual isolated VPC 2.0 network to a managed database allows you to create hybrid connections that enforce traffic rules to your applications. VPCs protect database resources from the public internet.

Follow this guide to manage Vultr VPC 2.0 Networks for Vultr Managed Databases for PostgreSQL with Vultr Customer Portal, API, and CLI.

  • Vultr Customer Portal
  • Vultr API
  • Vultr CLI
  1. Navigate to Products and select Databases.

  2. Click the target database instance.

    Select Managed Database

  3. Navigate to VPC Network under Overview. Select a network from the list and click Update.

    Edit VPC Network

  1. List all the database instances by sending a GET request to the List Managed Databases endpoint and note the database ID. For example, 43b4c774-5dff-4ac0-a01f-78a23c2205b5.

    console
    $ curl "https://api.vultr.com/v2/databases" \
        -X GET \
        -H "Authorization: Bearer ${VULTR_API_KEY}"
    
  2. List all the VPC 2.0 networks by sending a GET request to the List VPC 2.0 Networks endpoint and note the ID. For example, 778dd77c-a581-43a8-94e6-75b6ceb4354a.

    console
    $ curl "https://api.vultr.com/v2/vpc2" \
        -X GET \
        -H "Authorization: Bearer ${VULTR_API_KEY}"
    
  3. Send a PUT request to the Update Managed Database endpoint to attach the VPC 2.0 network to the database by specifying the database ID and the VPC 2.0 network ID.

    console
    $ curl "https://api.vultr.com/v2/databases/database_id" \
        -X PUT \
        -H "Authorization: Bearer ${VULTR_API_KEY}" \
        -H "Content-Type: application/json" \
        --data '{
            "vpc_id" : "vpc2_network_id"
        }'
    
  4. Detach a VPC 2.0 network from the database by sending a PUT request to the Update Managed Database endpoint and specify a database ID and an empty VPC 2.0 ID.

    console
    $ curl "https://api.vultr.com/v2/databases/database_id" \
        -X PUT \
        -H "Authorization: Bearer ${VULTR_API_KEY}" \
        -H "Content-Type: application/json" \
        --data '{
            "vpc_id" : ""
        }'
    

    Visit the Update Managed Database endpoint to view additional attributes to add to your request.

  1. List all database instances and note the database ID. For instance, d6ac2a3c-92ea-43ef-8185-71a23e58ad8c.

    console
    $ vultr-cli database list --summarize
    
  2. List all VPC 2.0 networks and note the VPC 2.0 ID. For instance, 778dd77c-a581-43a8-94e6-75b6ceb4354a.

    console
    $ vultr-cli vpc2 list
    
  3. Attach the VPC 2.0 network by specifying the database ID and the VPC 2.0 ID.

    console
    $ vultr-cli database update database_id \
    --vpc-id vpc2_id
    

    Run vultr-cli database update --help to view all options.