@fntio/infra-client
Version:
Self-hosted AWS access portal: credential vending, target-account trust, and grant-driven private networking as CDK stacks and constructs.
82 lines (81 loc) • 3.66 kB
JavaScript
;
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.ConnectorStack = void 0;
const cdk = __importStar(require("aws-cdk-lib"));
const ec2 = __importStar(require("aws-cdk-lib/aws-ec2"));
const tailnet_connector_1 = require("./constructs/tailnet-connector");
const sg_manager_1 = require("./constructs/sg-manager");
const tailnet_resolver_1 = require("./constructs/tailnet-resolver");
const naming_1 = require("../lambdacode/network/naming");
/** One per connector VPC, deployed with that account's credentials; the
* flexible path uses TailnetConnector + SgManager directly instead. */
class ConnectorStack extends cdk.Stack {
constructor(scope, id, props) {
super(scope, id, props);
if (props.name !== undefined)
(0, naming_1.assertConnectorName)(props.name, "ConnectorStack");
const vpc = ec2.Vpc.fromLookup(this, "Vpc", { vpcId: props.vpcId });
const connector = new tailnet_connector_1.TailnetConnector(this, "Connector", {
vpc,
controlUrl: props.hub.controlUrl(props.site),
routes: props.routes,
minter: props.hub.connectorKeyMinter(this, props.site),
containerInsights: props.containerInsights,
mirrorImages: props.mirrorImages,
hostname: (0, naming_1.connectorHostname)(this.account, props.name), // the reconciler's contract (naming.ts)
});
// The reconciler reaches this account itself only from the hub's region; elsewhere only
// its relay can (see `connectorVpcs.<account>.region`).
const trustedInvoker = this.region === props.hub.region
? props.hub.aclReconcilerPrincipal()
: props.hub.aclReconcilerRelayPrincipal();
new sg_manager_1.SgManager(this, "SgManager", {
resourcePrefix: props.hub.resourcePrefix,
vpc,
connectorSecurityGroup: connector.securityGroup,
trustedInvoker,
name: props.name,
});
new tailnet_resolver_1.TailnetResolver(this, "TailnetResolver", {
resourcePrefix: props.hub.resourcePrefix,
site: props.site,
vpc,
trustedInvoker,
name: props.name,
});
}
}
exports.ConnectorStack = ConnectorStack;