Static IP guide

Making API requests with a static IP from a Python app on AWS Lambda

Python Lambda functions adopt Fixie with the requests proxies dict built from FIXIE_URL — set in the console, template.yaml, serverless.yml, or Terraform, whichever owns your function config. Compared to the NAT Gateway approach, there is nothing to provision and nothing billed hourly.

RuntimePython
PlatformAWS Lambda
DestinationAPI allowlisting
Fixie productFixie HTTP/S proxy

Recommended setup

Use Fixie HTTP/S proxy for HTTP and HTTPS requests to an API, webhook provider, or service that allowlists outbound IP addresses. Store the proxy value in FIXIE_URL, then configure Python to route outbound traffic through Fixie before connecting to API allowlisting.

Set up Fixie on AWS Lambda

Create a Fixie HTTP/S proxy in the Fixie dashboard. Copy the proxy value into AWS Lambda environment variables as FIXIE_URL, and copy the outbound IPs into the destination allowlist.

Set an AWS Lambda environment variable

aws lambda update-function-configuration \
  --function-name YOUR_FUNCTION \
  --environment "Variables={FIXIE_URL=...}"

Implementation

The example below shows the core application-side change. Keep credentials in environment variables and avoid committing proxy, database, or API secrets.

Make an HTTP request through FIXIE_URL

import os
import requests

proxies = {
    "http": os.environ["FIXIE_URL"],
    "https": os.environ["FIXIE_URL"],
}

response = requests.get("https://api.example.com/data", proxies=proxies)
print(response.status_code)

Good to know

  • Define the proxies dict at module level so it is constructed once per cold start rather than per event.
  • boto3 traffic does not need Fixie — AWS APIs do not allowlist your IP — so scope the proxies dict to the external calls that do, rather than exporting process-wide proxy variables.

Allowlist and test the static IPs

  1. Open the Fixie dashboard and copy the outbound IP addresses for this proxy.
  2. Add both IPs to the API provider.
  3. Deploy the updated Python app on AWS Lambda.
  4. Run a small connection test before sending production traffic.

Related guides

Related docs