Static IP guide

Connecting to Amazon Redshift with a static IP from a Node app on AWS Lambda

Event-driven loads into Redshift — writing aggregates after processing, powering an API over warehouse data — run nicely from Lambda once the address problem is solved. With Fixie Socks the function presents a static IP the cluster's security group can allowlist, using the pg driver on port 5439 and no VPC configuration.

RuntimeNode.js and JavaScript
PlatformAWS Lambda
DestinationAmazon Redshift
Fixie productFixie Socks proxy

Recommended setup

Use Fixie Socks proxy for Amazon Redshift connections that require a stable source IP. Store the proxy value in FIXIE_SOCKS_HOST, then configure Node.js to route outbound traffic through Fixie before connecting to Amazon Redshift.

Set up Fixie on AWS Lambda

Create a Fixie Socks proxy in the Fixie dashboard. Copy the proxy value into AWS Lambda environment variables as FIXIE_SOCKS_HOST, 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_SOCKS_HOST=...}"

Implementation

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

Connect to Amazon Redshift through FIXIE_SOCKS_HOST

const pg = require('pg');
const SocksConnection = require('socksjs');

const fixieValues = process.env.FIXIE_SOCKS_HOST.split(new RegExp('[/(:\\/@)/]+'));

const databaseServer = {
  host: 'redshift-cluster.example.com',
  port: 5439,
};

const fixieConnection = new SocksConnection(databaseServer, {
  user: fixieValues[0],
  pass: fixieValues[1],
  host: fixieValues[2],
  port: fixieValues[3],
});

const client = new pg.Client({
  user: process.env.DB_USER,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
  stream: fixieConnection,
  ssl: true,
});

client.connect()
  .then(() => client.query('select 1 as ok'))
  .then((result) => console.log(result.rows[0]));

Good to know

  • Close the client before the handler returns; a frozen execution environment will not keep the proxied connection alive.
  • Redshift enforces per-cluster connection limits; batch incoming events so concurrency spikes do not exhaust them.

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 Redshift security group.
  3. Deploy the updated Node.js app on AWS Lambda.
  4. Run a small connection test before sending production traffic.

Related guides

Related docs