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.

72 lines (71 loc) • 3.21 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.TailnetResolver = void 0; const cdk = __importStar(require("aws-cdk-lib")); const constructs_1 = require("constructs"); const ec2 = __importStar(require("aws-cdk-lib/aws-ec2")); const app_function_1 = require("./app-function"); const naming_1 = require("../../lambdacode/network/naming"); /** In-VPC DNS for the hub's ACL reconciler: a Fargate task's IP moves on every * restart and only this VPC's resolver knows the current one — cross-account, * the reconciler can't see private zones at all, so drift-healing asks this fn * (names in, IPs out; DNS needs no internet path, so public subnets suffice — * same placement as the connector). */ class TailnetResolver extends constructs_1.Construct { fn; constructor(scope, id, props) { super(scope, id); this.fn = new app_function_1.AppFunction(this, "Fn", { functionName: (0, naming_1.tailnetResolverFnName)(props.resourcePrefix, props.site, props.name), description: "Resolves private DNS names from inside this VPC for the VPN reconciler.", asset: "tailnet-resolver", handler: "handler", timeout: cdk.Duration.seconds(15), vpc: props.vpc, vpcSubnets: { subnetType: ec2.SubnetType.PUBLIC }, allowPublicSubnet: true, // needs VPC DNS, not internet }); if (props.trustedInvoker) { // Lambda validates the principal exists — NetworkStack deploys first, // and redeploy here if the reconciler role is ever recreated. this.fn.addPermission("ReconcilerInvoke", { principal: props.trustedInvoker, action: "lambda:InvokeFunction", }); } } } exports.TailnetResolver = TailnetResolver;