UNPKG

@fntio/infra-client

Version:

Self-hosted AWS access portal: credential vending, target-account trust, and grant-driven private networking as CDK stacks and constructs.

62 lines (61 loc) • 3.2 kB
import { Construct } from "constructs"; /** AWS WAF in front of the web app (CloudFront) and the API (API Gateway * stage). ON by default — Security Hub CSPM fails APIGateway.4 and * CloudFront.6 without it. Rules, cost, opt-out: the Security * Posture wiki page. */ export interface WafConfig { /** false = no web ACLs at all. Default true. */ readonly enabled?: boolean; /** `/api/*` requests per client IP per 5 minutes before CloudFront answers * 429. One office NAT is one IP — size for the office. Default 5000. */ readonly rateLimit?: number; /** API requests per bearer token per 5 minutes before the API's WAF answers * 429. Per TOKEN, not per user: a browser session keeps one token for up to * an hour (each refresh starts a new bucket) and a service user can mint a * fresh token any time — a ceiling on a runaway or leaked token, sized * above the product's own bursts (import CLI, bulk UI actions, the e2e * suite). Default 2000. */ readonly perTokenRateLimit?: number; } /** The resolved limits — undefined when WAF is off. */ export interface WafLimits { readonly rateLimit: number; readonly perTokenRateLimit: number; } export declare function resolveWaf(config?: WafConfig): WafLimits | undefined; export interface WebAclProps { /** CLOUDFRONT-scope ACLs only exist in us-east-1 (WAF rule). */ readonly scope: "REGIONAL" | "CLOUDFRONT"; /** Web ACL, metric and log-group name — unique per account + region + scope. */ readonly name: string; /** Per-source-IP limit on requests under `pathPrefix`, per 5 minutes. Only * where WAF sees the viewer IP, i.e. on CloudFront — behind it the only * key is the client-writable X-Forwarded-For. */ readonly rateLimit?: { readonly limit: number; readonly pathPrefix: string; }; /** Per-bearer-token limit (the `authorization` header value is the key) on * requests under `pathPrefix` (omit = every request), per 5 minutes. Sound * behind CloudFront too: tokens are signed, so nobody lands in another * caller's bucket; junk tokens get their own and die 401 at the API. */ readonly tokenRateLimit?: { readonly limit: number; readonly pathPrefix?: string; }; /** Every managed rule runs in COUNT: the ACL logs what it would have * blocked and never blocks. For the issuer distribution — STS is its * only client, and a false positive there fails every vend silently. */ readonly observeOnly?: boolean; } /** CommonRuleSet rules that only COUNT here: the API is JSON with free * text, URLs, bulk-import batches and SVG data-URI logos, all shape-checked * server-side, and M2M clients may send no User-Agent. */ export declare const COMMON_RULES_COUNT_ONLY: string[]; /** One WAFv2 web ACL: optional per-IP and per-token rate limits + the AWS managed baseline * (IP reputation, known bad inputs, common rule set), logging blocks and * counts to CloudWatch with credentials redacted. */ export declare class WebAcl extends Construct { readonly arn: string; constructor(scope: Construct, id: string, props: WebAclProps); }