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.

59 lines (58 loc) • 3.4 kB
import * as cdk from "aws-cdk-lib"; import { Construct } from "constructs"; import * as s3 from "aws-cdk-lib/aws-s3"; import * as dynamodb from "aws-cdk-lib/aws-dynamodb"; import * as sns from "aws-cdk-lib/aws-sns"; import { AppFunction } from "./constructs/app-function"; import { ResolvedSite } from "./network-validation"; import { AuditLogTarget } from "./audit-log"; export interface NetworkStackProps extends cdk.StackProps { /** The hub's SET-ONCE product prefix (hub.resourcePrefix) — every by-name * contract derives from it; never change it after the first deploy. */ readonly resourcePrefix: string; readonly hostedZoneId: string; readonly zoneName: string; /** Sites live at `<site>.<subdomain>.<zoneName>` — the wildcard cert and * DNS record cover them all, so adding a site changes neither. */ readonly subdomain: string; /** From resolveSites, sorted by id. Site ids are permanent — baked into * every enrolled device's and connector's hostname. */ readonly sites: ResolvedSite[]; /** prod=true keeps the device databases (EFS) on stack teardown and turns * on load-balancer deletion protection (disable before a teardown). */ readonly prod: boolean; /** Container Insights on the control-plane cluster (Security Hub ECS.12); * per-metric cost. Default: `prod`. */ readonly containerInsights?: boolean; /** Run the control servers from a copy of the Headscale image in this account's own registry. */ readonly mirrorImages?: boolean; /** The reconciler renders catalog + grants into per-site ACLs: active * grant on R ⇔ may reach R's cidr:ports via R's account's connector. */ /** The hub's shared S3 server-access-log bucket (DataStack.accessLogsBucket); the ALB * access-log bucket logs into it under s3/alb-logs/ (Security Hub S3.9). */ readonly accessLogsBucket?: s3.IBucket; readonly resourcesTable: dynamodb.ITable; readonly accessTable: dynamodb.ITable; readonly groupsTable: dynamodb.ITable; /** Ops alert topic for the reconciler, stale-connector and relay-map alarms. * Optional so the stack can synth standalone. */ readonly alertTopic?: sns.ITopic; /** The activity log the reconciler records VPN sessions, firewall-rule changes and connector events * to. Optional so the stack can synth standalone; absent = no rows. */ readonly auditLog?: AuditLogTarget; } /** Self-hosted Headscale, ONE PER SITE, sharing one cluster/EFS/ALB. Control * planes never carry user traffic; admin ops via ECS Exec — no admin port. */ export declare class NetworkStack extends cdk.Stack { readonly sites: ResolvedSite[]; /** Mints DEVICE keys for any site (siteId argument — its only caller, the * vending API role, binds userName to the verified JWT). */ readonly deviceKeyMinter: AppFunction; /** Per-site CONNECTOR minters; each ignores input and is pinned to its * site's control plane by env. Safe to grant cross-account. */ readonly connectorKeyMinters: Record<string, AppFunction>; constructor(scope: Construct, id: string, props: NetworkStackProps); /** Grant invoke on ONE SITE's connector minter (machine keys only — never * the device minter). Prefer a task-role ARN over a whole-account id. */ grantConnectorAccount(siteId: string, connectorPrincipal: string): void; }