Skip to main content

Overview

The Formal Endpoint runs as a sidecar in each ECS task. It intercepts the outbound traffic your network rules select, applies your Formal policies, and logs each request. The ecs-endpoint Terraform module takes your container definitions and returns them with the sidecar added. It creates no AWS resources of its own.

Choose a launch type

Fargate does not allow NET_ADMIN, so the Endpoint runs there as a local proxy. A client that ignores the proxy settings connects directly. Use EC2 or Managed Instances when Formal must enforce all egress.

Sign in with the task role

The Endpoint signs in to Formal with OIDC. It exchanges a short-lived token from the task role for Formal credentials, so you have no API key to store or rotate.
1

Turn on outbound identity federation

Run this once per AWS account:
The second command prints your account’s issuer URL. Keep it for the next step.
2

Create the OIDC integration

Go to OIDC Integrations and click Create Integration. Set Issuer to the URL from the previous step and select the machine user the Endpoint signs in as.Restrict the claim condition to your task role:
Copy the generated integrationoidc_... ID.
3

Let the task role request tokens

Create an API key for a machine user and store it in Secrets Manager:
Pass its ARN as api_key_secret_arn instead of oidc_integration_id. The task execution role must be able to read it.

Add the Endpoint to your task

Pass your application containers to the module. Use its output as the task’s container definitions:
Use launch_type = "EC2" for ECS Managed Instances too. The task must use the awsvpc network mode, so all its containers share one network namespace. The Endpoint reserves 1 vCPU and 2 GiB by default. Change this with cpu and memory_reservation. On Fargate, size the task for your application plus the Endpoint. Your application containers start only once the Endpoint is healthy and has loaded your policies. Their first request is already inspected. Verify:
Requests from your application then appear in Logs.

TLS trust

The Endpoint decrypts TLS for the hosts your policies inspect, with its own CA. The module mounts a bundle of the system CAs plus that CA at /formal-ca/ca-bundle.pem. It points SSL_CERT_FILE, REQUESTS_CA_BUNDLE, NODE_EXTRA_CA_CERTS, AWS_CA_BUNDLE, CURL_CA_BUNDLE, and similar variables at it. Python, Node.js, Go, curl, and the AWS SDKs need no change.

Proxy settings on Fargate

With FARGATE, the module points each application container at the Endpoint on 127.0.0.1:3128. It sets HTTPS_PROXY, HTTP_PROXY, and NO_PROXY for most clients, NODE_USE_ENV_PROXY=1 for Node.js, and the proxy properties in JAVA_TOOL_OPTIONS for Java.

Troubleshooting

They wait for formal-endpoint to be healthy. Check its logs:
  • Sign-in errors with OIDC: the claim condition does not match the task role, or the task role lacks sts:GetWebIdentityToken.
  • Sign-in errors with an API key: the task execution role cannot read the secret, or the key was revoked.
The Endpoint only intercepts hosts that a network rule selects. Other traffic passes through untouched and is not logged. Add a rule for the hosts you want to inspect.