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.

115 lines (114 loc) • 6 kB
import type { ResolvedDevShares } from "../network-validation"; import type { ResolvedPersonalAccessTokens } from "../personal-access-tokens"; import type { RoleSessionNamePolicy } from "../role-session-name"; import type { DashboardLayoutMode } from "../dashboard-layout"; import { Construct } from "constructs"; import * as cognito from "aws-cdk-lib/aws-cognito"; import * as dynamodb from "aws-cdk-lib/aws-dynamodb"; import * as iam from "aws-cdk-lib/aws-iam"; import * as kms from "aws-cdk-lib/aws-kms"; import * as s3 from "aws-cdk-lib/aws-s3"; import { AppFunction } from "./app-function"; export interface VendingApiProps { /** The data-layer tables (owned by DataStack), all read/write. */ readonly accountsTable: dynamodb.ITable; readonly rolesTable: dynamodb.ITable; readonly requestsTable: dynamodb.ITable; /** Vend-event audit log — never part of an access decision. */ readonly auditTable: dynamodb.ITable; readonly auditRetentionDays: number; readonly groupsTable: dynamodb.ITable; readonly resourcesTable: dynamodb.ITable; readonly accessTable: dynamodb.ITable; /** Revoked-access notices for the activity bell (informational only). */ readonly revocationsTable: dynamodb.ITable; /** Service-user (M2M app client) registry. */ readonly serviceUsersTable: dynamodb.ITable; /** Personal access tokens (rows read on every token request; the secret's hash only). */ readonly tokensTable: dynamodb.ITable; /** Enabled `personalAccessTokens`; absent = tokens are refused and creation answers 501. */ readonly personalAccessTokens?: ResolvedPersonalAccessTokens; /** Session naming policy for vended roles; absent env = userId. */ readonly roleSessionName?: RoleSessionNamePolicy; /** Customer plugins, on: the catalog the API reads (absent env = an empty catalog) + discovery settings. */ readonly plugins?: { readonly discoveryRefreshSeconds: number; readonly catalogTable: dynamodb.ITable; }; /** The OIDC signing key — the app calls kms:Sign to mint tokens. */ readonly signingKey: kms.IKey; /** The public issuer URL, minted into every token's `iss` claim. */ readonly issuerUrl: string; /** The pool whose ID tokens the auth middleware verifies, and whose users * the admin Users routes manage. */ readonly userPool: cognito.IUserPool; /** The app's public origin (https://<web domain>) sign-up links are built on; absent = path-only links. */ readonly appUrl?: string; /** Surfaced by the public discovery endpoint for desktop-app self-config. */ readonly userPoolClientId: string; /** Surfaced by the discovery endpoint to label/brand the desktop tab. */ readonly projectName: string; /** The handler's execution role — created by CredsStack so the issuer's * locked key policy can name it as the sole kms:Sign principal. */ readonly handlerRole: iam.IRole; /** Site bucket (by-name contract, see web-stack webBucketName) — the * branding route writes /branding.json there. */ readonly webBucketName: string; /** Private, short-lived: the access-report job writes CSVs here and the API hands out presigned links. */ readonly reportsBucket: s3.IBucket; /** The report job function's fixed name (derives from `resourcePrefix`); the API invokes it by name. */ readonly reportJobFunctionName: string; /** Whether the deployment sends email from its own domain (EmailConfig * present) — the setup checklist's "custom email" item reads it. */ readonly emailConfigured: boolean; /** Sender address when emailConfigured — the setup checklist shows it. */ readonly emailFrom?: string; /** Accounts named in the deploy config's rolesByAccount — the setup * checklist offers to register the ones not in the Accounts catalog yet. */ readonly configAccounts?: ReadonlyArray<{ readonly accountNumber: string; readonly roles: readonly string[]; }>; /** Enables /network. The key minter is invoked BY NAME so this construct * never references NetworkStack — deploy order stays free. */ readonly network?: { readonly sites: ReadonlyArray<{ readonly id: string; readonly displayName: string; readonly controlUrl: string; readonly accounts: readonly string[]; readonly splitDns?: Record<string, readonly string[]>; readonly connectorVpcs?: Record<string, ReadonlyArray<{ readonly vpcId: string; readonly routes: readonly string[]; readonly region?: string; readonly name?: string; }>>; }>; /** Device key-minter function name (derives from `resourcePrefix`). */ readonly keyMinterFnName: string; /** ACL reconciler function name — invoked async by POST /admin/network/sync. */ readonly reconcilerFnName: string; /** Enabled `network.devShares`; absent = creating shares answers 501. */ readonly devShares?: ResolvedDevShares; }; /** Enabled `accountDimensions`; absent = registrations store no dims and lists carry none. */ readonly accountDimensions?: { readonly enabled: boolean; readonly labels: { readonly tenant: string; readonly project: string; readonly stage: string; }; readonly stages: Readonly<Record<string, string>>; }; /** Deployment-wide dashboard layout; absent = auto. */ readonly dashboardLayout?: DashboardLayoutMode; } /** The Express vending app (lambdacode/api) in Lambda. Express owns routing * AND auth, so no authorizer is needed at the gateway. */ export declare class VendingApi extends Construct { /** The Express app's Lambda — front it with API Gateway. */ readonly handler: AppFunction; constructor(scope: Construct, id: string, props: VendingApiProps); }