Firewalls

Allow rules that say who may connect to a resource.

Overview

A firewall says who may connect to a resource. Once a firewall names a resource, only what its rules allow gets in. Rules read like sentences: allow TCP 5432 from app/api.

When to use it

  • Only the API may reach the database.
  • SSH to a VM from one address.
  • Nothing may leave for the internet.

How it works

nftables
Rules are applied inside each target’s own network namespace.
Live addresses
A rule naming a resource follows the current addresses of all its containers.

For each target, every firewall naming it is combined into one policy. Some traffic is always allowed: replies, the edge proxy, health probes, and load balancers on their target ports.

Architecture

Firewalls architectureThe firewall lets the API in and keeps everything else out.tcp 5432droppedallowedapp/apiAny other appnftablesin the database’s namespacedatabase/orders
The firewall lets the API in and keeps everything else out.
  • app/api to nftables: tcp 5432
  • Any other app to nftables: dropped
  • nftables to database/orders: allowed

Flows

Applying a rule

  1. You create or change a firewall.
  2. EnclaveStack resolves names to addresses.
  3. The rules are written into each target’s namespace.

Set it up

In the console

  1. Open Firewalls and choose New firewall.
  2. Choose what it protects.
  3. Add rules: protocol, ports and sources.

With the CLI

enclave firewall create db-access --target database/orders --allow "tcp 5432 from app/api" --wait

With OpenTofu

OpenTofu configuration
resource "enclave_firewall" "db_access" {
  name    = "db-access"
  targets = ["database/orders"]
  ingress = [
    { protocol = "tcp", ports = ["5432"], from = ["app/api"] },
  ]
}

Settings reference

Every setting and output of the OpenTofu resource; the console and the CLI use the same names in their own words. Generated from platform 4d30582.

enclave_firewall
NameTypeUseWhat it does
nametextrequiredName of the firewall: 3–40 lowercase letters, digits or hyphens, starting with a letter. Changing it replaces the firewall.
targetslist of textrequiredResources to protect, e.g. ["database/orders", "app/api"].
egresslist of objectsoptionalOutgoing rules (with egress_default = "deny").
egress_defaulttextoptionalOutgoing traffic no rule names: allow (default) or deny.
ingresslist of objectsoptionalIncoming rules.
projecttextoptionalThe project to create it in. Defaults to the provider's project (ENCLAVE_PROJECT, else default). Changing it replaces the resource.
applied_containersnumberoutputHow many containers carry these rules.
idtextoutputResource ID.

Limits and security

Good to know

  • Ports published on this computer stay reachable through the machine.

Security

  • Default deny once named; outgoing traffic can be denied too.