Skip to content

Latest commit

 

History

History
282 lines (224 loc) · 10 KB

File metadata and controls

282 lines (224 loc) · 10 KB

Secure Azure Database Deployment Architecture

Overview

This document describes the architecture for secure deployment of PostgreSQL database in Azure using Cosmos DB for PostgreSQL. The solution is designed with Zero Trust and Defense in Depth principles, following Azure security best practices.

Architecture Diagram

┌─────────────────────────────────────────────────────────────────┐
│                    Azure Subscription                           │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │                Resource Group                              │  │
│  │                                                           │  │
│  │  ┌─────────────────────────────────────────────────────┐  │  │
│  │  │              Virtual Network                        │  │  │
│  │  │              10.0.0.0/16                           │  │  │
│  │  │                                                     │  │  │
│  │  │  ┌─────────────────┐  ┌────────────────────────┐   │  │  │
│  │  │  │ Database Subnet │  │ Private Endpoint       │   │  │  │
│  │  │  │ 10.0.1.0/24     │  │ Subnet                 │   │  │  │
│  │  │  │                 │  │ 10.0.2.0/24           │   │  │  │
│  │  │  │                 │  │                        │   │  │  │
│  │  │  │                 │  │  ┌─────────────────┐   │   │  │  │
│  │  │  │                 │  │  │ Private         │   │   │  │  │
│  │  │  │                 │  │  │ Endpoint        │   │   │  │  │
│  │  │  │                 │  │  └─────────────────┘   │   │  │  │
│  │  │  └─────────────────┘  └────────────────────────┘   │  │  │
│  │  └─────────────────────────────────────────────────────┘  │  │
│  │                                                           │  │
│  │  ┌─────────────────────────────────────────────────────┐  │  │
│  │  │          Cosmos DB for PostgreSQL                  │  │  │
│  │  │          (Public Access Disabled)                  │  │  │
│  │  └─────────────────────────────────────────────────────┘  │  │
│  │                                                           │  │
│  │  ┌─────────────┐  ┌─────────────┐  ┌─────────────────┐   │  │
│  │  │ Key Vault   │  │ Managed     │  │ Log Analytics   │   │  │
│  │  │             │  │ Identity    │  │ Workspace       │   │  │
│  │  └─────────────┘  └─────────────┘  └─────────────────┘   │  │
│  └───────────────────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────────────┘

Network Architecture

IMPORTANT: PostgreSQL Cosmos DB Features

PostgreSQL Cosmos DB does NOT support subnet delegation (Microsoft.DocumentDB/databaseAccounts) ✅ Only Cassandra clusters support delegation (Microsoft.DocumentDB/cassandraClusters) ✅ PostgreSQL uses Private Endpoints instead of subnet delegation

Network Components

Virtual Network (VNet)

  • CIDR: 10.0.0.0/16
  • Purpose: Isolated network environment for all resources
  • Security: Complete isolation from internet by default

Subnets

Database Subnet (10.0.1.0/24)
  • Purpose: Hosting Cosmos DB for PostgreSQL
  • Delegation: None (not supported for PostgreSQL)
  • NSG: Strict security rules
  • Routing: Internet access blocked
Private Endpoint Subnet (10.0.2.0/24)
  • Purpose: Hosting private endpoints
  • Policies: Network policies disabled for private endpoints
  • NSG: Only necessary traffic allowed

Network Security Groups (NSG)

Database NSG

Inbound Traffic Rules:
- Allow PostgreSQL (5432) from Private Endpoint Subnet
- Allow HTTPS (443) from Private Endpoint Subnet
- Deny All Other Inbound

Outbound Traffic Rules:
- Allow All (can be restricted based on requirements)

Private Endpoint NSG

Outbound Traffic Rules:
- Allow PostgreSQL (5432) to Database Subnet
- Allow HTTPS (443) to Database Subnet
- Allow DNS (53) to Any
- Deny All Other Outbound

Architecture Components

1. Network Infrastructure

Virtual Network (VNet)

  • CIDR: 10.0.0.0/16
  • Purpose: Isolated network environment for all resources
  • Security: Complete isolation from internet by default

Subnets

Database Subnet (10.0.1.0/24)
  • Purpose: Hosting Cosmos DB for PostgreSQL
  • Delegation: None (PostgreSQL does not support subnet delegation)
  • NSG: Strict security rules
  • Routing: Internet access blocked
Private Endpoint Subnet (10.0.2.0/24)
  • Purpose: Hosting private endpoints
  • Policies: Network policies disabled for private endpoints
  • NSG: Only necessary traffic allowed

2. Network Security Groups (NSG)

Database NSG

Inbound Traffic Rules:
- Allow PostgreSQL (5432) from Private Endpoint Subnet
- Allow HTTPS (443) from Private Endpoint Subnet
- Deny All Other Inbound

Outbound Traffic Rules:
- Allow All (can be restricted based on requirements)

Private Endpoint NSG

Outbound Traffic Rules:
- Allow PostgreSQL (5432) to Database Subnet
- Allow HTTPS (443) to Database Subnet
- Allow DNS (53) to Any
- Deny All Other Outbound

3. Database

Cosmos DB for PostgreSQL

  • Type: Fully managed PostgreSQL service
  • Configuration: Single coordinator node (1 vCore, 128GB storage)
  • Public Access: Disabled
  • Connection: Only through private endpoint
  • Backup: Automatic, configurable retention period

4. Security

Azure Key Vault

  • Purpose: Storage for secrets, keys and certificates
  • Access: Restricted through Azure services
  • Encryption: Customer Managed Keys for Cosmos DB
  • Audit: Complete logging of all operations

Managed Identity

  • Type: User Assigned Managed Identity
  • Purpose: Secure authentication without passwords
  • Access: To Key Vault and Cosmos DB
  • RBAC: Minimum necessary permissions

Private DNS Zone

  • Zone: privatelink.postgres.cosmos.azure.com
  • Purpose: Name resolution for private endpoints
  • Link: To virtual network

5. Monitoring and Audit

Log Analytics Workspace

  • Purpose: Centralized logging
  • Retention: 30 days
  • Logs: Diagnostic logs from all resources

Azure Monitor

  • Metrics: Database performance
  • Alerts: Configurable notifications
  • Dashboards: Real-time monitoring

Security Principles

Zero Trust

  • All connections are verified and authorized
  • No trust by default
  • Principle of least privilege

Defense in Depth

  1. Network Level: NSG, routing, private endpoints
  2. Identity Level: Managed Identity, RBAC
  3. Data Level: Encryption at rest and in transit
  4. Application Level: Secure connection strings
  5. Monitoring Level: Logging and alerts

Network Segmentation

  • Component isolation in separate subnets
  • Traffic control through NSG
  • Internet access blocked by default

Compliance

GDPR

  • Personal data encryption
  • Data location control
  • Audit trails
  • Right to be forgotten

SOC 2

  • Access controls
  • Security monitoring
  • Change management
  • Incident response

PCI DSS

  • Payment data protection
  • Secure network architecture
  • Regular security testing
  • Access monitoring

Deployment Flow

Phase 1: Infrastructure

  1. Resource Group creation
  2. Virtual Network setup
  3. Subnet configuration
  4. NSG rules application

Phase 2: Security

  1. Key Vault deployment
  2. Managed Identity creation
  3. RBAC assignments
  4. Secret generation

Phase 3: Database

  1. Cosmos DB for PostgreSQL deployment
  2. Private endpoint creation
  3. DNS configuration
  4. Connection testing

Phase 4: Monitoring

  1. Log Analytics workspace
  2. Diagnostic settings
  3. Alert rules
  4. Dashboard setup

Cost Optimization

Resource Sizing

  • Cosmos DB: Start with 1 vCore coordinator
  • Storage: 128GB with auto-scaling
  • Log Analytics: 30-day retention

Reserved Instances

  • Consider reservations for production
  • Cost savings up to 65%
  • 1-year or 3-year terms

Monitoring

  • Cost alerts and budgets
  • Resource utilization tracking
  • Right-sizing recommendations

Disaster Recovery

Backup Strategy

  • Automatic backups every 24 hours
  • Point-in-time recovery
  • Configurable retention (7-35 days)

High Availability

  • Built-in redundancy
  • Automatic failover
  • 99.9% SLA

Performance Considerations

Scaling

  • Vertical scaling (vCores)
  • Storage auto-scaling
  • Read replicas for read workloads

Optimization

  • Connection pooling
  • Query optimization
  • Index strategies