Skip to content
GitHub Discord

Router with WAF

Enable WAF (Web Application Firewall) for a Router to protect against common web exploits and bots.

WAF includes rate limiting per IP, and AWS managed rules for core rule set, known bad inputs, and SQL injection protection.

You can also enable WAF logging to CloudWatch to monitor requests.

sst.config.ts
const api = new sst.aws.Function("MyApi", {
handler: "api.handler",
url: true,
});
const router = new sst.aws.Router("MyRouter", {
routes: {
"/*": api.url,
},
waf: {
rateLimitPerIp: 1000,
managedRules: {
coreRuleSet: true,
knownBadInputs: true,
sqlInjection: true,
},
logging: true,
},
});
api.ts
export const handler = async (event: any) => {
return {
statusCode: 200,
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ message: "Hello from WAF-protected Router!" }),
};
};

View the full example.