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.

26 lines (25 loc) • 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DEFAULT_AUDIT_RETENTION_DAYS = void 0; exports.resolveAuditRetentionDays = resolveAuditRetentionDays; exports.auditLogEnv = auditLogEnv; exports.grantAuditLogWrite = grantAuditLogWrite; exports.DEFAULT_AUDIT_RETENTION_DAYS = 400; /** Validated at synth: an out-of-range retention would silently become the default in the Lambda. */ function resolveAuditRetentionDays(config) { const days = config?.retentionDays ?? exports.DEFAULT_AUDIT_RETENTION_DAYS; if (!Number.isInteger(days) || days < 30 || days > 3650) { throw new Error(`audit.retentionDays (${String(config?.retentionDays)}) must be a whole number of days between 30 and 3650.`); } return days; } /** Env + grant for any Lambda that records activity (services/auditService.ts reads both names). */ function auditLogEnv(target) { return { AUDIT_TABLE_NAME: target.table.tableName, AUDIT_RETENTION_DAYS: String(target.retentionDays), }; } function grantAuditLogWrite(grantee, target) { target.table.grantWriteData(grantee); }