@intentius/behold 0.29.51 → 0.29.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +186 -25
- package/example-three-cloud/README.md +1 -1
- package/example-three-cloud/aws/src/site.ts +15 -8
- package/example-three-cloud/azure/src/site.ts +38 -5
- package/example-three-cloud/dns/src/route53.ts +13 -5
- package/example-three-cloud/gcp/src/site.ts +99 -9
- package/example-three-cloud/package-lock.json +19 -19
- package/example-three-cloud/package.json +4 -4
- package/example-three-cloud/scripts/emulators-up.sh +3 -3
- package/example-three-cloud/scripts/front-door.ts +21 -22
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -17640,6 +17640,7 @@ var AZURE_HEADLINE_KINDS = /* @__PURE__ */ new Set([
|
|
|
17640
17640
|
var AZURE_FABRIC_KINDS = /* @__PURE__ */ new Set([
|
|
17641
17641
|
"Microsoft.Network/virtualNetworks",
|
|
17642
17642
|
"Microsoft.Network/virtualNetworks_subnets",
|
|
17643
|
+
"Microsoft.Network/virtualNetworks/subnets",
|
|
17643
17644
|
"Microsoft.Network/networkSecurityGroups",
|
|
17644
17645
|
"Microsoft.Network/routeTables",
|
|
17645
17646
|
"Microsoft.Network/networkInterfaces",
|
|
@@ -17651,7 +17652,7 @@ var AZURE_FABRIC_KINDS = /* @__PURE__ */ new Set([
|
|
|
17651
17652
|
"Microsoft.KeyVault/vaults"
|
|
17652
17653
|
]);
|
|
17653
17654
|
var VNET_KIND = "Microsoft.Network/virtualNetworks";
|
|
17654
|
-
var
|
|
17655
|
+
var SUBNET_KINDS = /* @__PURE__ */ new Set(["Microsoft.Network/virtualNetworks_subnets", "Microsoft.Network/virtualNetworks/subnets"]);
|
|
17655
17656
|
var NSG_KIND = "Microsoft.Network/networkSecurityGroups";
|
|
17656
17657
|
var RESOURCE_ID_RE = /resourceId\(\s*([^)]*)\)/g;
|
|
17657
17658
|
var QUOTED_RE = /'([^']*)'/g;
|
|
@@ -17689,6 +17690,28 @@ function subnetShortName(node) {
|
|
|
17689
17690
|
const name = resourceName(node);
|
|
17690
17691
|
return name?.includes("/") ? name.split("/").slice(1).join("/") : name;
|
|
17691
17692
|
}
|
|
17693
|
+
var CONCAT_SUBNET_RE = /resourceId\(\s*'Microsoft\.Network\/virtualNetworks'\s*,\s*'([^']+)'\s*\)\s*,\s*'\/subnets\/([^']+)'/gi;
|
|
17694
|
+
function subnetRefs(value, out = /* @__PURE__ */ new Set()) {
|
|
17695
|
+
if (typeof value === "string") {
|
|
17696
|
+
for (const call of value.matchAll(RESOURCE_ID_RE)) {
|
|
17697
|
+
const args = [...call[1].matchAll(QUOTED_RE)].map((m) => m[1]);
|
|
17698
|
+
if (args.length === 3 && /^Microsoft\.Network\/virtualNetworks[/_]subnets$/i.test(args[0])) out.add(`${args[1]}/${args[2]}`);
|
|
17699
|
+
}
|
|
17700
|
+
for (const m of value.matchAll(CONCAT_SUBNET_RE)) out.add(`${m[1]}/${m[2]}`);
|
|
17701
|
+
} else if (value && typeof value === "object") {
|
|
17702
|
+
for (const v of Object.values(value)) subnetRefs(v, out);
|
|
17703
|
+
}
|
|
17704
|
+
return out;
|
|
17705
|
+
}
|
|
17706
|
+
function inlineSubnets(vnet) {
|
|
17707
|
+
const list4 = vnet.attrs?.subnets;
|
|
17708
|
+
if (!Array.isArray(list4)) return [];
|
|
17709
|
+
return list4.flatMap((s) => {
|
|
17710
|
+
const name = s?.name;
|
|
17711
|
+
const prefix = s?.properties?.addressPrefix;
|
|
17712
|
+
return typeof name === "string" ? [[name, typeof prefix === "string" ? prefix : void 0]] : [];
|
|
17713
|
+
});
|
|
17714
|
+
}
|
|
17692
17715
|
function vnetCidr(node) {
|
|
17693
17716
|
const space = node.attrs?.addressSpace;
|
|
17694
17717
|
const prefixes = space?.addressPrefixes;
|
|
@@ -17705,7 +17728,7 @@ function projectAzureLogical(ir, env) {
|
|
|
17705
17728
|
if (name && !byName.has(name)) byName.set(name, n);
|
|
17706
17729
|
}
|
|
17707
17730
|
const vnets = azure.filter((n) => n.kind === VNET_KIND);
|
|
17708
|
-
const subnets = azure.filter((n) => n.kind
|
|
17731
|
+
const subnets = azure.filter((n) => SUBNET_KINDS.has(n.kind));
|
|
17709
17732
|
const vnetByName = new Map(vnets.map((v) => [resourceName(v) ?? v.id, v]));
|
|
17710
17733
|
const refOut = /* @__PURE__ */ new Map();
|
|
17711
17734
|
for (const n of azure) {
|
|
@@ -17723,6 +17746,8 @@ function projectAzureLogical(ir, env) {
|
|
|
17723
17746
|
(refOut.get(e.from) ?? refOut.set(e.from, /* @__PURE__ */ new Set()).get(e.from)).add(e.to);
|
|
17724
17747
|
}
|
|
17725
17748
|
const RG_TITLE = env ? `resource group ${env}` : "resource group";
|
|
17749
|
+
const subscription = azure.map((n) => JSON.stringify(n).match(/\/subscriptions\/([0-9a-f-]{36})\//i)?.[1]).find(Boolean);
|
|
17750
|
+
const SUBSCRIPTION_TITLE = subscription ? `Azure subscription ${subscription}` : "Azure subscription";
|
|
17726
17751
|
const vnetTitle = (v) => `VNet ${vnetCidr(v) ?? resourceName(v) ?? v.id}`;
|
|
17727
17752
|
const subnetTitle = (s) => `subnet ${strAttr(s, "addressPrefix") ?? subnetShortName(s) ?? s.id}`;
|
|
17728
17753
|
const guardedBy = /* @__PURE__ */ new Map();
|
|
@@ -17762,8 +17787,38 @@ function projectAzureLogical(ir, env) {
|
|
|
17762
17787
|
const v = parentVnet ? vnetByName.get(parentVnet) : void 0;
|
|
17763
17788
|
child(v ? vnetTitle(v) : RG_TITLE, subnetTitle(s));
|
|
17764
17789
|
}
|
|
17790
|
+
const inlineBox = /* @__PURE__ */ new Map();
|
|
17791
|
+
for (const v of vnets) {
|
|
17792
|
+
for (const [name, prefix] of inlineSubnets(v)) {
|
|
17793
|
+
const key3 = `${resourceName(v) ?? v.id}/${name}`;
|
|
17794
|
+
if (subnets.some((s) => resourceName(s) === key3)) continue;
|
|
17795
|
+
const title = `subnet ${prefix ?? name}`;
|
|
17796
|
+
inlineBox.set(key3, title);
|
|
17797
|
+
child(vnetTitle(v), title);
|
|
17798
|
+
}
|
|
17799
|
+
}
|
|
17800
|
+
const inlinePlace = (start) => {
|
|
17801
|
+
const seen = /* @__PURE__ */ new Set();
|
|
17802
|
+
let frontier = [start];
|
|
17803
|
+
for (let depth = 0; depth < 6 && frontier.length; depth++) {
|
|
17804
|
+
const next = [];
|
|
17805
|
+
for (const id of frontier) {
|
|
17806
|
+
if (seen.has(id)) continue;
|
|
17807
|
+
seen.add(id);
|
|
17808
|
+
for (const key3 of subnetRefs(byId.get(id)?.attrs)) if (inlineBox.has(key3)) return inlineBox.get(key3);
|
|
17809
|
+
for (const r of refOut.get(id) ?? []) if (!seen.has(r)) next.push(r);
|
|
17810
|
+
}
|
|
17811
|
+
frontier = next;
|
|
17812
|
+
}
|
|
17813
|
+
return void 0;
|
|
17814
|
+
};
|
|
17765
17815
|
const placeOf = /* @__PURE__ */ new Map();
|
|
17766
17816
|
for (const n of headline) {
|
|
17817
|
+
const inline = inlinePlace(n.id);
|
|
17818
|
+
if (inline) {
|
|
17819
|
+
placeOf.set(n.id, inline);
|
|
17820
|
+
continue;
|
|
17821
|
+
}
|
|
17767
17822
|
const subnetId = nearest(n.id, subnetIds);
|
|
17768
17823
|
if (subnetId) {
|
|
17769
17824
|
placeOf.set(n.id, subnetTitle(byId.get(subnetId)));
|
|
@@ -17824,6 +17879,7 @@ function projectAzureLogical(ir, env) {
|
|
|
17824
17879
|
const nsg = guardedSubnet ? guardedBy.get(guardedSubnet.id) : void 0;
|
|
17825
17880
|
return nsg ? { ...n, attrs: { ...n.attrs, _nsg: nsg } } : n;
|
|
17826
17881
|
});
|
|
17882
|
+
if (byContainer[RG_TITLE]) child(SUBSCRIPTION_TITLE, RG_TITLE);
|
|
17827
17883
|
return { ir: { nodes, edges, groups: {} }, byContainer };
|
|
17828
17884
|
}
|
|
17829
17885
|
|
|
@@ -17834,7 +17890,11 @@ var GCP_HEADLINE_KINDS = /* @__PURE__ */ new Set([
|
|
|
17834
17890
|
"GCP::Sql::Instance",
|
|
17835
17891
|
"GCP::Storage::Bucket",
|
|
17836
17892
|
"GCP::Compute::Instance",
|
|
17837
|
-
"GCP::Dns::ManagedZone"
|
|
17893
|
+
"GCP::Dns::ManagedZone",
|
|
17894
|
+
// A load balancer's front end, the card the AWS lens draws for an ALB
|
|
17895
|
+
// (behold#824); its proxy, URL map, backend service and NEG are contracted
|
|
17896
|
+
// through, so the card joins the service they route to.
|
|
17897
|
+
"GCP::Compute::ForwardingRule"
|
|
17838
17898
|
]);
|
|
17839
17899
|
var GCP_FABRIC_KINDS = /* @__PURE__ */ new Set([
|
|
17840
17900
|
// networking — declared, not emulated
|
|
@@ -17852,6 +17912,22 @@ var GCP_FABRIC_KINDS = /* @__PURE__ */ new Set([
|
|
|
17852
17912
|
// chant's own annotation carrier
|
|
17853
17913
|
"chant:gcp:defaultAnnotations"
|
|
17854
17914
|
]);
|
|
17915
|
+
var SUBNETWORK_KIND = "GCP::Compute::Subnetwork";
|
|
17916
|
+
function metadataName(node) {
|
|
17917
|
+
const name = node.attrs?.metadata?.name;
|
|
17918
|
+
return typeof name === "string" && name.length > 0 ? name : void 0;
|
|
17919
|
+
}
|
|
17920
|
+
function subnetsNamed(value, out = []) {
|
|
17921
|
+
if (!value || typeof value !== "object") return out;
|
|
17922
|
+
for (const [k, v] of Object.entries(value)) {
|
|
17923
|
+
if (k === "subnetworkRef" && v && typeof v === "object") {
|
|
17924
|
+
const name = v.name ?? v.external;
|
|
17925
|
+
if (typeof name === "string") out.push(name.split("/").pop());
|
|
17926
|
+
} else if (k === "subnetwork" && typeof v === "string") out.push(v.split("/").pop());
|
|
17927
|
+
else subnetsNamed(v, out);
|
|
17928
|
+
}
|
|
17929
|
+
return out;
|
|
17930
|
+
}
|
|
17855
17931
|
var PROJECT_ID_ANNOTATION = "cnrm.cloud.google.com/project-id";
|
|
17856
17932
|
function strAttr2(node, key3) {
|
|
17857
17933
|
const v = node.attrs?.[key3];
|
|
@@ -17863,6 +17939,10 @@ function declaredProject(nodes) {
|
|
|
17863
17939
|
const value = annotations?.[PROJECT_ID_ANNOTATION];
|
|
17864
17940
|
if (typeof value === "string" && value.length > 0) return value;
|
|
17865
17941
|
}
|
|
17942
|
+
for (const n of nodes) {
|
|
17943
|
+
const ref2 = n.attrs?.projectRef ?? n.attrs?.spec?.projectRef;
|
|
17944
|
+
if (typeof ref2?.external === "string" && ref2.external.length > 0) return ref2.external.replace(/^projects\//, "");
|
|
17945
|
+
}
|
|
17866
17946
|
return void 0;
|
|
17867
17947
|
}
|
|
17868
17948
|
function collectRefs(v, out) {
|
|
@@ -17877,7 +17957,7 @@ function projectGcpLogical(ir, env) {
|
|
|
17877
17957
|
const componentOf = componentNamer(gcp, ir.groups);
|
|
17878
17958
|
const byId = new Map(gcp.map((n) => [n.id, n]));
|
|
17879
17959
|
const project = declaredProject(gcp) ?? env;
|
|
17880
|
-
const PROJECT_TITLE = project ? `project ${project}` : "project";
|
|
17960
|
+
const PROJECT_TITLE = project ? `GCP project ${project}` : "GCP project";
|
|
17881
17961
|
const GLOBAL = "global";
|
|
17882
17962
|
const locationTitle = (loc) => `location ${loc}`;
|
|
17883
17963
|
const refOut = /* @__PURE__ */ new Map();
|
|
@@ -17900,14 +17980,28 @@ function projectGcpLogical(ir, env) {
|
|
|
17900
17980
|
};
|
|
17901
17981
|
const locations = /* @__PURE__ */ new Set();
|
|
17902
17982
|
for (const n of gcp) {
|
|
17903
|
-
const loc = strAttr2(n, "location");
|
|
17983
|
+
const loc = strAttr2(n, "location") ?? (n.kind === SUBNETWORK_KIND ? strAttr2(n, "region") : void 0);
|
|
17904
17984
|
if (loc) locations.add(loc);
|
|
17905
17985
|
}
|
|
17906
17986
|
for (const loc of [...locations].sort()) child(PROJECT_TITLE, locationTitle(loc));
|
|
17987
|
+
const subnetBox = /* @__PURE__ */ new Map();
|
|
17988
|
+
const regionOfBox = /* @__PURE__ */ new Map();
|
|
17989
|
+
for (const n of gcp) {
|
|
17990
|
+
if (n.kind !== SUBNETWORK_KIND) continue;
|
|
17991
|
+
const name = metadataName(n) ?? n.id;
|
|
17992
|
+
const cidr = strAttr2(n, "ipCidrRange");
|
|
17993
|
+
const network = n.attrs?.networkRef?.name;
|
|
17994
|
+
const title = `subnet ${cidr ?? name}${typeof network === "string" ? ` \xB7 ${network}` : ""}`;
|
|
17995
|
+
const region = strAttr2(n, "region") ?? strAttr2(n, "location");
|
|
17996
|
+
child(region ? locationTitle(region) : PROJECT_TITLE, title);
|
|
17997
|
+
subnetBox.set(name, title);
|
|
17998
|
+
if (region) regionOfBox.set(title, region);
|
|
17999
|
+
}
|
|
17907
18000
|
const placeOf = /* @__PURE__ */ new Map();
|
|
17908
18001
|
for (const n of headline) {
|
|
18002
|
+
const subnet = subnetsNamed(n.attrs).map((name) => subnetBox.get(name)).find(Boolean);
|
|
17909
18003
|
const loc = strAttr2(n, "location");
|
|
17910
|
-
placeOf.set(n.id, loc ? locationTitle(loc) : GLOBAL);
|
|
18004
|
+
placeOf.set(n.id, subnet ?? (loc ? locationTitle(loc) : GLOBAL));
|
|
17911
18005
|
}
|
|
17912
18006
|
const byComponent = /* @__PURE__ */ new Map();
|
|
17913
18007
|
for (const n of headline) {
|
|
@@ -17916,10 +18010,25 @@ function projectGcpLogical(ir, env) {
|
|
|
17916
18010
|
}
|
|
17917
18011
|
for (const [component, members] of byComponent) {
|
|
17918
18012
|
const places = new Set(members.map((m) => placeOf.get(m.id)));
|
|
17919
|
-
const
|
|
17920
|
-
if (
|
|
17921
|
-
|
|
17922
|
-
|
|
18013
|
+
const regional = [...places].filter((p) => p !== "location global");
|
|
18014
|
+
if (places.size > 1 && regional.length > 1) {
|
|
18015
|
+
child(PROJECT_TITLE, component);
|
|
18016
|
+
for (const m of members) child(component, m.id);
|
|
18017
|
+
continue;
|
|
18018
|
+
}
|
|
18019
|
+
if (places.size === 1) {
|
|
18020
|
+
const parent = [...places][0];
|
|
18021
|
+
if (parent === GLOBAL) child(PROJECT_TITLE, GLOBAL);
|
|
18022
|
+
child(parent, component);
|
|
18023
|
+
for (const m of members) child(component, m.id);
|
|
18024
|
+
continue;
|
|
18025
|
+
}
|
|
18026
|
+
for (const place of places) {
|
|
18027
|
+
if (place === GLOBAL) child(PROJECT_TITLE, GLOBAL);
|
|
18028
|
+
const part = `${component} \xB7 ${regionOfBox.get(place) ?? place.replace(/^location /, "")}`;
|
|
18029
|
+
child(place, part);
|
|
18030
|
+
for (const m of members) if (placeOf.get(m.id) === place) child(part, m.id);
|
|
18031
|
+
}
|
|
17923
18032
|
}
|
|
17924
18033
|
const kept = new Set(headline.map((n) => n.id));
|
|
17925
18034
|
const adj = /* @__PURE__ */ new Map();
|
|
@@ -18334,6 +18443,7 @@ var NO_CONTRACT_KINDS = /* @__PURE__ */ new Set([
|
|
|
18334
18443
|
"AWS::EC2::SecurityGroupIngress"
|
|
18335
18444
|
]);
|
|
18336
18445
|
var REGION_RE = /\b([a-z]{2}-[a-z]+-\d)\b/;
|
|
18446
|
+
var ACCOUNT_RE = /arn:aws[a-z-]*:[a-z0-9-]*:[a-z0-9-]*:(\d{12}):/;
|
|
18337
18447
|
var WORD_RE = /[A-Za-z][A-Za-z0-9]*/g;
|
|
18338
18448
|
function isExample(node) {
|
|
18339
18449
|
return (node.sourceLoc?.file ?? "").includes("examples/");
|
|
@@ -18358,10 +18468,19 @@ function componentNamer(nodes, groups) {
|
|
|
18358
18468
|
}
|
|
18359
18469
|
}
|
|
18360
18470
|
}
|
|
18361
|
-
|
|
18471
|
+
const component = (node) => {
|
|
18362
18472
|
const dirs = segments(node);
|
|
18363
18473
|
return dirs[shared2] ?? dirs[dirs.length - 1] ?? "other";
|
|
18364
18474
|
};
|
|
18475
|
+
const seen = /* @__PURE__ */ new Map();
|
|
18476
|
+
for (const n of nodes) {
|
|
18477
|
+
const m = memberOf(n);
|
|
18478
|
+
if (m) (seen.get(m) ?? seen.set(m, /* @__PURE__ */ new Set()).get(m)).add(component(n));
|
|
18479
|
+
}
|
|
18480
|
+
return (node) => {
|
|
18481
|
+
const m = memberOf(node);
|
|
18482
|
+
return m && seen.get(m)?.size === 1 ? m : component(node);
|
|
18483
|
+
};
|
|
18365
18484
|
}
|
|
18366
18485
|
function memberNamer(groups) {
|
|
18367
18486
|
const byStack = groups?.byStack;
|
|
@@ -18612,13 +18731,36 @@ function projectLogical(ir) {
|
|
|
18612
18731
|
};
|
|
18613
18732
|
const subnetTitle = (subnetId) => `${subnetScope(subnetId)} subnet ${strAttr3(byId.get(subnetId), "CidrBlock") ?? subnetId}`;
|
|
18614
18733
|
const GLOBAL = "regional & global";
|
|
18734
|
+
const memberOf = memberNamer(ir.groups);
|
|
18735
|
+
const ownRefs = /* @__PURE__ */ new Map();
|
|
18736
|
+
for (const [from, tos] of refOut) {
|
|
18737
|
+
const m = memberOf(byId.get(from));
|
|
18738
|
+
ownRefs.set(from, new Set([...tos].filter((t2) => memberOf(byId.get(t2)) === m)));
|
|
18739
|
+
}
|
|
18740
|
+
const subnetsOf = (start) => {
|
|
18741
|
+
const seen = /* @__PURE__ */ new Set([start]);
|
|
18742
|
+
let frontier = [...ownRefs.get(start) ?? []];
|
|
18743
|
+
for (let depth = 0; depth < 8 && frontier.length; depth++) {
|
|
18744
|
+
const hit = [...new Set(frontier.filter((id) => subnetIds.has(id)))];
|
|
18745
|
+
if (hit.length) return hit.sort();
|
|
18746
|
+
const next = [];
|
|
18747
|
+
for (const id of frontier) {
|
|
18748
|
+
if (seen.has(id)) continue;
|
|
18749
|
+
seen.add(id);
|
|
18750
|
+
for (const r of ownRefs.get(id) ?? []) if (!seen.has(r)) next.push(r);
|
|
18751
|
+
}
|
|
18752
|
+
frontier = next;
|
|
18753
|
+
}
|
|
18754
|
+
return [];
|
|
18755
|
+
};
|
|
18615
18756
|
const headline = aws.filter((n) => HEADLINE_KINDS.has(n.kind));
|
|
18616
18757
|
const placeOf = /* @__PURE__ */ new Map();
|
|
18617
18758
|
for (const n of headline) {
|
|
18618
|
-
const
|
|
18619
|
-
|
|
18759
|
+
const subnets = subnetsOf(n.id);
|
|
18760
|
+
const scopes = new Set(subnets.map(subnetScope));
|
|
18761
|
+
if (subnets.length && scopes.size === 1) placeOf.set(n.id, { kind: "subnet", subnets, vpc: nearestByRef(subnets[0], vpcIds, ownRefs) });
|
|
18620
18762
|
else {
|
|
18621
|
-
const vpc = nearestByRef(n.id, vpcIds,
|
|
18763
|
+
const vpc = (subnets.length ? nearestByRef(subnets[0], vpcIds, ownRefs) : void 0) ?? nearestByRef(n.id, vpcIds, ownRefs) ?? igwToVpc.get(n.id);
|
|
18622
18764
|
placeOf.set(n.id, vpc ? { kind: "vpc", vpc } : { kind: "global" });
|
|
18623
18765
|
}
|
|
18624
18766
|
}
|
|
@@ -18627,26 +18769,41 @@ function projectLogical(ir) {
|
|
|
18627
18769
|
const arr6 = byContainer[parent] ?? (byContainer[parent] = []);
|
|
18628
18770
|
if (!arr6.includes(c)) arr6.push(c);
|
|
18629
18771
|
};
|
|
18630
|
-
const
|
|
18631
|
-
|
|
18772
|
+
const subnetVpc = new Map([...subnetIds].map((id) => [id, nearestByRef(id, vpcIds, ownRefs)]));
|
|
18773
|
+
const tierOf = (id) => [...subnetIds].filter((s) => subnetVpc.get(s) === subnetVpc.get(id) && subnetScope(s) === subnetScope(id)).sort();
|
|
18774
|
+
const tierTitle = (ids) => {
|
|
18775
|
+
const tier = tierOf(ids[0]);
|
|
18776
|
+
return tier.length === 1 ? subnetTitle(tier[0]) : `${subnetScope(tier[0])} subnets ${tier.map((id) => strAttr3(byId.get(id), "CidrBlock") ?? id).join(", ")}`;
|
|
18777
|
+
};
|
|
18778
|
+
const ensureSubnet = (ids, vpcId) => {
|
|
18779
|
+
const t2 = tierTitle(ids);
|
|
18632
18780
|
if (vpcId) child(vpcTitle(vpcId), t2);
|
|
18633
18781
|
return t2;
|
|
18634
18782
|
};
|
|
18783
|
+
const placeTitle = (p) => p.kind === "subnet" ? ensureSubnet(p.subnets, p.vpc) : p.kind === "vpc" ? vpcTitle(p.vpc) : GLOBAL;
|
|
18784
|
+
const placeKey = (p) => p.kind === "subnet" ? `s:${tierOf(p.subnets[0]).join(",")}` : p.kind === "vpc" ? `v:${p.vpc}` : "g";
|
|
18635
18785
|
const byComponent = /* @__PURE__ */ new Map();
|
|
18636
18786
|
for (const n of headline) (byComponent.get(componentOf(n)) ?? byComponent.set(componentOf(n), []).get(componentOf(n))).push(n);
|
|
18637
18787
|
for (const [component, members] of byComponent) {
|
|
18638
18788
|
const places = members.map((m) => placeOf.get(m.id));
|
|
18639
|
-
const
|
|
18789
|
+
const keys = new Set(places.map(placeKey));
|
|
18640
18790
|
const vpcs = new Set(places.map((p) => p.kind === "subnet" ? p.vpc : p.kind === "vpc" ? p.vpc : void 0).filter((v) => !!v));
|
|
18641
|
-
|
|
18642
|
-
|
|
18643
|
-
const
|
|
18644
|
-
|
|
18645
|
-
}
|
|
18646
|
-
|
|
18647
|
-
|
|
18648
|
-
|
|
18791
|
+
if (keys.size === 1) {
|
|
18792
|
+
child(placeTitle(places[0]), component);
|
|
18793
|
+
for (const m of members) child(component, m.id);
|
|
18794
|
+
continue;
|
|
18795
|
+
}
|
|
18796
|
+
if (vpcs.size === 1 && places.every((p) => p.kind !== "global")) {
|
|
18797
|
+
for (const [i, m] of members.entries()) {
|
|
18798
|
+
const p = places[i];
|
|
18799
|
+
const title = placeTitle(p);
|
|
18800
|
+
const part = p.kind === "subnet" ? `${component} \xB7 ${subnetScope(p.subnets[0])}` : component;
|
|
18801
|
+
child(title, part);
|
|
18802
|
+
child(part, m.id);
|
|
18803
|
+
}
|
|
18804
|
+
continue;
|
|
18649
18805
|
}
|
|
18806
|
+
const parent = vpcs.size >= 1 ? vpcTitle([...vpcs][0]) : GLOBAL;
|
|
18650
18807
|
child(parent, component);
|
|
18651
18808
|
for (const m of members) child(component, m.id);
|
|
18652
18809
|
}
|
|
@@ -18744,6 +18901,10 @@ function projectLogical(ir) {
|
|
|
18744
18901
|
frontier = next;
|
|
18745
18902
|
}
|
|
18746
18903
|
}
|
|
18904
|
+
const accountId = aws.map((n) => JSON.stringify(n).match(ACCOUNT_RE)?.[1]).find(Boolean);
|
|
18905
|
+
const ACCOUNT = accountId ? `AWS account ${accountId}` : "AWS account";
|
|
18906
|
+
const nested = new Set(Object.values(byContainer).flat());
|
|
18907
|
+
for (const key3 of Object.keys(byContainer)) if (!nested.has(key3)) child(ACCOUNT, key3);
|
|
18747
18908
|
return { ir: { nodes: headline, edges, groups: {} }, byContainer };
|
|
18748
18909
|
}
|
|
18749
18910
|
|
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
import { FargateAlb,
|
|
1
|
+
import { FargateAlb, VpcDefault, output } from "@intentius/chant-lexicon-aws";
|
|
2
2
|
|
|
3
3
|
// The website on ECS Fargate in us-east-1, behind its own load balancer: the
|
|
4
|
-
// ALB's DNS name is the stable hostname Route 53 points at. The
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
// ALB's DNS name is the stable hostname Route 53 points at. The network is
|
|
5
|
+
// declared here as production has it: a VPC across two zones, public subnets
|
|
6
|
+
// for the load balancer and private ones for the tasks, which reach out
|
|
7
|
+
// through a NAT gateway.
|
|
8
|
+
export const network = VpcDefault({
|
|
9
|
+
cidr: "10.20.0.0/16",
|
|
10
|
+
publicSubnet1Cidr: "10.20.0.0/24",
|
|
11
|
+
publicSubnet2Cidr: "10.20.1.0/24",
|
|
12
|
+
privateSubnet1Cidr: "10.20.10.0/24",
|
|
13
|
+
privateSubnet2Cidr: "10.20.11.0/24",
|
|
14
|
+
});
|
|
8
15
|
|
|
9
16
|
export const web = FargateAlb({
|
|
10
17
|
image: "traefik/whoami:v1.10",
|
|
11
18
|
containerPort: 80,
|
|
12
19
|
desiredCount: 1,
|
|
13
|
-
vpcId:
|
|
14
|
-
publicSubnetIds:
|
|
15
|
-
privateSubnetIds:
|
|
20
|
+
vpcId: network.vpc.VpcId,
|
|
21
|
+
publicSubnetIds: [network.publicSubnet1.SubnetId, network.publicSubnet2.SubnetId],
|
|
22
|
+
privateSubnetIds: [network.privateSubnet1.SubnetId, network.privateSubnet2.SubnetId],
|
|
16
23
|
logRetentionDays: 7,
|
|
17
24
|
});
|
|
18
25
|
|
|
@@ -1,13 +1,46 @@
|
|
|
1
|
-
import { managedEnvironments, containerApps, output } from "@intentius/chant-lexicon-azure";
|
|
1
|
+
import { LogAnalyticsWorkspace, ManagedIdentity, VirtualNetwork, managedEnvironments, containerApps, output } from "@intentius/chant-lexicon-azure";
|
|
2
2
|
|
|
3
|
-
// The website on Azure Container Apps in West Europe
|
|
4
|
-
//
|
|
5
|
-
|
|
3
|
+
// The website on Azure Container Apps in West Europe, set up the way a
|
|
4
|
+
// production environment is: the environment sits in its own VNet subnet and
|
|
5
|
+
// ships its logs to a Log Analytics workspace, and the app runs as a
|
|
6
|
+
// user-assigned identity. Container Apps brings its own ingress and load
|
|
7
|
+
// balancing, so there is no load balancer to declare.
|
|
8
|
+
const location = "westeurope";
|
|
9
|
+
|
|
10
|
+
export const logs = new LogAnalyticsWorkspace({ name: "three-cloud-logs", location, sku: { name: "PerGB2018" }, retentionInDays: 30 });
|
|
11
|
+
|
|
12
|
+
// A Container Apps environment on workload profiles takes a /23 or larger,
|
|
13
|
+
// delegated to it. The subnet is declared inside the VNet: chant's own Subnet
|
|
14
|
+
// resource writes the ARM type as virtualNetworks_subnets (reported to chant).
|
|
15
|
+
export const vnet = new VirtualNetwork({
|
|
16
|
+
name: "three-cloud-vnet",
|
|
17
|
+
location,
|
|
18
|
+
addressSpace: { addressPrefixes: ["10.40.0.0/16"] },
|
|
19
|
+
subnets: [{ name: "apps", properties: { addressPrefix: "10.40.0.0/23", delegations: [{ name: "apps", properties: { serviceName: "Microsoft.App/environments" } }] } }],
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export const identity = new ManagedIdentity({ name: "three-cloud-web", location });
|
|
23
|
+
|
|
24
|
+
export const env = new managedEnvironments({
|
|
25
|
+
name: "three-cloud",
|
|
26
|
+
location,
|
|
27
|
+
vnetConfiguration: { infrastructureSubnetId: "[resourceId('Microsoft.Network/virtualNetworks/subnets', 'three-cloud-vnet', 'apps')]", internal: false },
|
|
28
|
+
appLogsConfiguration: {
|
|
29
|
+
destination: "log-analytics",
|
|
30
|
+
logAnalyticsConfiguration: {
|
|
31
|
+
customerId: "[reference(resourceId('Microsoft.OperationalInsights/workspaces', 'three-cloud-logs')).customerId]",
|
|
32
|
+
sharedKey: "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces', 'three-cloud-logs'), '2023-09-01').primarySharedKey]",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
workloadProfiles: [{ name: "Consumption", workloadProfileType: "Consumption" }],
|
|
36
|
+
});
|
|
6
37
|
|
|
7
38
|
export const app = new containerApps({
|
|
8
39
|
name: "web",
|
|
9
|
-
location
|
|
40
|
+
location,
|
|
41
|
+
identity: { type: "UserAssigned", userAssignedIdentities: { "[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', 'three-cloud-web')]": {} } },
|
|
10
42
|
managedEnvironmentId: env.id,
|
|
43
|
+
workloadProfileName: "Consumption",
|
|
11
44
|
configuration: { ingress: { external: true, targetPort: 80, transport: "auto" } },
|
|
12
45
|
template: {
|
|
13
46
|
containers: [{ name: "web", image: "traefik/whoami:v1.10", resources: { cpu: 0.25, memory: "0.5Gi" } }],
|
|
@@ -7,7 +7,9 @@ import { HostedZone, HealthCheck, RecordSet, Parameter } from "@intentius/chant-
|
|
|
7
7
|
// Latency records name an AWS region, so Azure (West Europe) answers as
|
|
8
8
|
// eu-west-1 and GCP (Tokyo) as ap-northeast-1. All three are CNAMEs, since an
|
|
9
9
|
// alias can only point at an AWS target and records sharing a name must share
|
|
10
|
-
// a type.
|
|
10
|
+
// a type. GCP's load balancer has an IP address rather than a hostname, so
|
|
11
|
+
// it gets a name of its own (an A record) and the latency record points at
|
|
12
|
+
// that, as a GCP load balancer is usually published.
|
|
11
13
|
//
|
|
12
14
|
// Each endpoint arrives as a parameter named like the output the cloud's
|
|
13
15
|
// member publishes, which is the join behold draws the cross-member edge on.
|
|
@@ -18,7 +20,7 @@ export const zone = new HostedZone({ Name: "three-cloud.example." });
|
|
|
18
20
|
|
|
19
21
|
export const awsEndpoint = new Parameter("String", { description: "The aws member's load balancer hostname" });
|
|
20
22
|
export const azureEndpoint = new Parameter("String", { description: "The azure member's Container App hostname" });
|
|
21
|
-
export const gcpEndpoint = new Parameter("String", { description: "The gcp member's
|
|
23
|
+
export const gcpEndpoint = new Parameter("String", { description: "The gcp member's load balancer IP address" });
|
|
22
24
|
|
|
23
25
|
function healthCheck(endpoint: Parameter) {
|
|
24
26
|
return new HealthCheck({
|
|
@@ -32,7 +34,7 @@ function healthCheck(endpoint: Parameter) {
|
|
|
32
34
|
});
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
function latencyRecord(id: string, region: string, endpoint: Parameter, check: HealthCheck) {
|
|
37
|
+
function latencyRecord(id: string, region: string, endpoint: Parameter | string, check: HealthCheck) {
|
|
36
38
|
return new RecordSet({
|
|
37
39
|
HostedZoneId: zone.Id,
|
|
38
40
|
Name: NAME,
|
|
@@ -47,8 +49,14 @@ function latencyRecord(id: string, region: string, endpoint: Parameter, check: H
|
|
|
47
49
|
|
|
48
50
|
export const awsCheck = healthCheck(awsEndpoint);
|
|
49
51
|
export const azureCheck = healthCheck(azureEndpoint);
|
|
50
|
-
|
|
52
|
+
// The check on GCP probes the load balancer's address directly.
|
|
53
|
+
export const gcpCheck = new HealthCheck({
|
|
54
|
+
HealthCheckConfig: { Type: "HTTP", IPAddress: gcpEndpoint, Port: 80, ResourcePath: "/", RequestInterval: 10, FailureThreshold: 1 },
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const GCP_ORIGIN = "gcp.three-cloud.example.";
|
|
58
|
+
export const gcpOrigin = new RecordSet({ HostedZoneId: zone.Id, Name: GCP_ORIGIN, Type: "A", TTL: "60", ResourceRecords: [gcpEndpoint as unknown as string] });
|
|
51
59
|
|
|
52
60
|
export const awsRecord = latencyRecord("aws", "us-east-1", awsEndpoint, awsCheck);
|
|
53
61
|
export const azureRecord = latencyRecord("azure", "eu-west-1", azureEndpoint, azureCheck);
|
|
54
|
-
export const gcpRecord = latencyRecord("gcp", "ap-northeast-1",
|
|
62
|
+
export const gcpRecord = latencyRecord("gcp", "ap-northeast-1", GCP_ORIGIN, gcpCheck);
|
|
@@ -1,19 +1,109 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
BackendService,
|
|
3
|
+
CloudRunServiceComposite,
|
|
4
|
+
ComputeAddress,
|
|
5
|
+
ForwardingRule,
|
|
6
|
+
GCPServiceAccount,
|
|
7
|
+
RegionNetworkEndpointGroup,
|
|
8
|
+
Subnetwork,
|
|
9
|
+
TargetHTTPProxy,
|
|
10
|
+
URLMap,
|
|
11
|
+
VPCNetwork,
|
|
12
|
+
output,
|
|
13
|
+
} from "@intentius/chant-lexicon-gcp";
|
|
14
|
+
|
|
15
|
+
// The website on Cloud Run in Tokyo, running as its own service account with
|
|
16
|
+
// its egress in a VPC subnet, behind a global external Application Load
|
|
17
|
+
// Balancer as production sets it up: a
|
|
18
|
+
// static address and a forwarding rule, an HTTP proxy, a URL map, a backend
|
|
19
|
+
// service, and a serverless network endpoint group that names the service.
|
|
20
|
+
//
|
|
21
|
+
// Each reference is Config Connector's `{ name }`, spelled out: chant 0.124.36
|
|
22
|
+
// writes a `.name` reference correctly but its live read can't resolve one
|
|
23
|
+
// (reported to chant), and behold joins these by name.
|
|
24
|
+
const region = "asia-northeast1";
|
|
25
|
+
|
|
26
|
+
export const runtime = new GCPServiceAccount({
|
|
27
|
+
metadata: { name: "three-cloud-run" },
|
|
28
|
+
displayName: "three-cloud website runtime",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// The network Cloud Run sends its egress into (Direct VPC egress), a custom
|
|
32
|
+
// VPC with one subnet in the service's region.
|
|
33
|
+
export const vpc = new VPCNetwork({ metadata: { name: "three-cloud-vpc" }, autoCreateSubnetworks: false, routingMode: "REGIONAL" });
|
|
34
|
+
|
|
35
|
+
export const subnet = new Subnetwork({
|
|
36
|
+
metadata: { name: "three-cloud-apps" },
|
|
37
|
+
region,
|
|
38
|
+
ipCidrRange: "10.30.0.0/24",
|
|
39
|
+
networkRef: { name: "three-cloud-vpc" },
|
|
40
|
+
});
|
|
2
41
|
|
|
3
|
-
// The website on Cloud Run in Tokyo, open to unauthenticated callers.
|
|
4
42
|
export const web = CloudRunServiceComposite({
|
|
5
|
-
name: "
|
|
43
|
+
name: "three-cloud-site",
|
|
6
44
|
image: "traefik/whoami:v1.10",
|
|
7
45
|
projectId: "three-cloud",
|
|
8
|
-
location:
|
|
46
|
+
location: region,
|
|
9
47
|
port: 80,
|
|
10
48
|
minInstanceCount: 1,
|
|
11
49
|
maxInstanceCount: 1,
|
|
12
50
|
publicAccess: true,
|
|
51
|
+
serviceAccount: "three-cloud-run",
|
|
52
|
+
defaults: {
|
|
53
|
+
service: {
|
|
54
|
+
template: {
|
|
55
|
+
vpcAccess: {
|
|
56
|
+
egress: "PRIVATE_RANGES_ONLY",
|
|
57
|
+
networkInterfaces: [{ networkRef: { name: "three-cloud-vpc" }, subnetworkRef: { name: "three-cloud-apps" } }],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const neg = new RegionNetworkEndpointGroup({
|
|
65
|
+
metadata: { name: "three-cloud-neg" },
|
|
66
|
+
region,
|
|
67
|
+
networkEndpointType: "SERVERLESS",
|
|
68
|
+
cloudRun: { serviceRef: { name: "three-cloud-site" } },
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// A backend service over a serverless NEG takes no health check: Cloud Run
|
|
72
|
+
// reports its own readiness.
|
|
73
|
+
export const backend = new BackendService({
|
|
74
|
+
metadata: { name: "three-cloud-backend" },
|
|
75
|
+
location: "global",
|
|
76
|
+
loadBalancingScheme: "EXTERNAL_MANAGED",
|
|
77
|
+
protocol: "HTTP",
|
|
78
|
+
backend: [{ group: { networkEndpointGroupRef: { name: "three-cloud-neg" } } }],
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const urlMap = new URLMap({
|
|
82
|
+
metadata: { name: "three-cloud-map" },
|
|
83
|
+
location: "global",
|
|
84
|
+
defaultService: { backendServiceRef: { name: "three-cloud-backend" } },
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const proxy = new TargetHTTPProxy({
|
|
88
|
+
metadata: { name: "three-cloud-proxy" },
|
|
89
|
+
location: "global",
|
|
90
|
+
urlMapRef: { name: "three-cloud-map" },
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
export const address = new ComputeAddress({ metadata: { name: "three-cloud-ip" }, location: "global" });
|
|
94
|
+
|
|
95
|
+
export const rule = new ForwardingRule({
|
|
96
|
+
metadata: { name: "three-cloud-rule" },
|
|
97
|
+
location: "global",
|
|
98
|
+
loadBalancingScheme: "EXTERNAL_MANAGED",
|
|
99
|
+
portRange: "80",
|
|
100
|
+
ipAddress: { addressRef: { name: "three-cloud-ip" } },
|
|
101
|
+
target: { targetHTTPProxyRef: { name: "three-cloud-proxy" } },
|
|
13
102
|
});
|
|
14
103
|
|
|
15
|
-
// The dns member reads this as its `gcpEndpoint` parameter
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
104
|
+
// The dns member reads this as its `gcpEndpoint` parameter: the load
|
|
105
|
+
// balancer's front end, whose IP is the reserved address. Config Connector
|
|
106
|
+
// YAML has no outputs and neither kind exposes the IP as an attribute, so
|
|
107
|
+
// this declares the join for the graph, and scripts/front-door.ts reads the
|
|
108
|
+
// IP from the emulator.
|
|
109
|
+
export const gcpEndpoint = output(rule.status_selfLink, "gcpEndpoint");
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
"": {
|
|
7
7
|
"name": "behold-example-three-cloud",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@intentius/chant": "^0.124.
|
|
10
|
-
"@intentius/chant-lexicon-aws": "^0.124.
|
|
11
|
-
"@intentius/chant-lexicon-azure": "^0.124.
|
|
12
|
-
"@intentius/chant-lexicon-gcp": "^0.124.
|
|
9
|
+
"@intentius/chant": "^0.124.36",
|
|
10
|
+
"@intentius/chant-lexicon-aws": "^0.124.36",
|
|
11
|
+
"@intentius/chant-lexicon-azure": "^0.124.36",
|
|
12
|
+
"@intentius/chant-lexicon-gcp": "^0.124.36"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"node_modules/@dagrejs/dagre": {
|
|
@@ -444,9 +444,9 @@
|
|
|
444
444
|
}
|
|
445
445
|
},
|
|
446
446
|
"node_modules/@intentius/chant": {
|
|
447
|
-
"version": "0.124.
|
|
448
|
-
"resolved": "https://registry.npmjs.org/@intentius/chant/-/chant-0.124.
|
|
449
|
-
"integrity": "sha512-
|
|
447
|
+
"version": "0.124.36",
|
|
448
|
+
"resolved": "https://registry.npmjs.org/@intentius/chant/-/chant-0.124.36.tgz",
|
|
449
|
+
"integrity": "sha512-KcsdALy1O+P5i9bxL2FkIgW546zmyJnwzm0xS556YRSC4EytexW9okRVhv/hwhlj8dtcXJAxoyZmwh8qgznanA==",
|
|
450
450
|
"license": "Apache-2.0",
|
|
451
451
|
"dependencies": {
|
|
452
452
|
"@dagrejs/dagre": "^3.0.0",
|
|
@@ -473,34 +473,34 @@
|
|
|
473
473
|
}
|
|
474
474
|
},
|
|
475
475
|
"node_modules/@intentius/chant-lexicon-aws": {
|
|
476
|
-
"version": "0.124.
|
|
477
|
-
"resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-aws/-/chant-lexicon-aws-0.124.
|
|
478
|
-
"integrity": "sha512-
|
|
476
|
+
"version": "0.124.36",
|
|
477
|
+
"resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-aws/-/chant-lexicon-aws-0.124.36.tgz",
|
|
478
|
+
"integrity": "sha512-AdhC24jnc7gnvdDfFYzDJ+OKmaNJt4tki/oHmxzJkun0TiH12mZjdA/mR6LxK5GJkvNidK9TwyR/LtAwZAnU6Q==",
|
|
479
479
|
"license": "Apache-2.0",
|
|
480
480
|
"dependencies": {
|
|
481
481
|
"fflate": "^0.8.2",
|
|
482
482
|
"js-yaml": "^4.3.1"
|
|
483
483
|
},
|
|
484
484
|
"peerDependencies": {
|
|
485
|
-
"@intentius/chant": "^0.124.
|
|
485
|
+
"@intentius/chant": "^0.124.36"
|
|
486
486
|
}
|
|
487
487
|
},
|
|
488
488
|
"node_modules/@intentius/chant-lexicon-azure": {
|
|
489
|
-
"version": "0.124.
|
|
490
|
-
"resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-azure/-/chant-lexicon-azure-0.124.
|
|
491
|
-
"integrity": "sha512-
|
|
489
|
+
"version": "0.124.36",
|
|
490
|
+
"resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-azure/-/chant-lexicon-azure-0.124.36.tgz",
|
|
491
|
+
"integrity": "sha512-Ge/gqsqceUCCEo628DD7uxWxk35thZk9W1pCrbiwtr1j1IAQsY2hFtzL3PnBpuXpFUh9nAtx73SiNxrur0PGAA==",
|
|
492
492
|
"license": "Apache-2.0",
|
|
493
493
|
"dependencies": {
|
|
494
494
|
"fflate": "^0.8.2"
|
|
495
495
|
},
|
|
496
496
|
"peerDependencies": {
|
|
497
|
-
"@intentius/chant": "^0.124.
|
|
497
|
+
"@intentius/chant": "^0.124.36"
|
|
498
498
|
}
|
|
499
499
|
},
|
|
500
500
|
"node_modules/@intentius/chant-lexicon-gcp": {
|
|
501
|
-
"version": "0.124.
|
|
502
|
-
"resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-gcp/-/chant-lexicon-gcp-0.124.
|
|
503
|
-
"integrity": "sha512-
|
|
501
|
+
"version": "0.124.36",
|
|
502
|
+
"resolved": "https://registry.npmjs.org/@intentius/chant-lexicon-gcp/-/chant-lexicon-gcp-0.124.36.tgz",
|
|
503
|
+
"integrity": "sha512-g1xfRaMpm6bfJLfHkddMv0Y9w1lsCOvPqpsnJ+QwYOBsMSawkTC7Dd/ep8Cfp8AAH24uk7qngMc6MJZFIAcRMw==",
|
|
504
504
|
"license": "Apache-2.0",
|
|
505
505
|
"dependencies": {
|
|
506
506
|
"@types/js-yaml": "^4.0.9",
|
|
@@ -508,7 +508,7 @@
|
|
|
508
508
|
"js-yaml": "^4.3.1"
|
|
509
509
|
},
|
|
510
510
|
"peerDependencies": {
|
|
511
|
-
"@intentius/chant": "^0.124.
|
|
511
|
+
"@intentius/chant": "^0.124.36"
|
|
512
512
|
}
|
|
513
513
|
},
|
|
514
514
|
"node_modules/@types/js-yaml": {
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"front-door": "tsx scripts/front-door.ts all --out export"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@intentius/chant": "^0.124.
|
|
12
|
-
"@intentius/chant-lexicon-aws": "^0.124.
|
|
13
|
-
"@intentius/chant-lexicon-azure": "^0.124.
|
|
14
|
-
"@intentius/chant-lexicon-gcp": "^0.124.
|
|
11
|
+
"@intentius/chant": "^0.124.36",
|
|
12
|
+
"@intentius/chant-lexicon-aws": "^0.124.36",
|
|
13
|
+
"@intentius/chant-lexicon-azure": "^0.124.36",
|
|
14
|
+
"@intentius/chant-lexicon-gcp": "^0.124.36"
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -38,9 +38,9 @@ boot() {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
boot "${FLOCI_CONTAINER:-chant-floci}" "${FLOCI_PORT:-4566}" 4566 \
|
|
41
|
-
"${FLOCI_IMAGE:-ghcr.io/lex00/floci:
|
|
41
|
+
"${FLOCI_IMAGE:-ghcr.io/lex00/floci:48c6e47}" /_floci/health
|
|
42
42
|
boot "${FLOCI_AZ_CONTAINER:-chant-floci-az}" "${FLOCI_AZ_PORT:-4577}" 4577 \
|
|
43
|
-
"${FLOCI_AZ_IMAGE:-ghcr.io/lex00/floci-az:
|
|
43
|
+
"${FLOCI_AZ_IMAGE:-ghcr.io/lex00/floci-az:7f079c2}" /_floci/health \
|
|
44
44
|
-e FLOCI_AZ_SERVICES_CONTAINER_APPS_MOCKED=false
|
|
45
45
|
boot "${FLOCI_GCP_CONTAINER:-chant-floci-gcp}" "${FLOCI_GCP_PORT:-4588}" 4588 \
|
|
46
|
-
"${FLOCI_GCP_IMAGE:-ghcr.io/lex00/floci-gcp:
|
|
46
|
+
"${FLOCI_GCP_IMAGE:-ghcr.io/lex00/floci-gcp:641e6e8}" /_floci-gcp/health
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* until `chant lifecycle health` reads azureCheck healthy
|
|
8
8
|
* tsx scripts/front-door.ts azure-off deactivate the Azure app's active revision
|
|
9
9
|
* tsx scripts/front-door.ts wait until azureCheck reads unhealthy
|
|
10
|
-
* tsx scripts/front-door.ts export --out <dir> behold export, opening on env local at the
|
|
10
|
+
* tsx scripts/front-door.ts export --out <dir> behold export, opening on env local at the logical zoom
|
|
11
11
|
*
|
|
12
12
|
* dns/ops/front-door.op.ts runs the same steps as an Op's phases. The emulators
|
|
13
13
|
* are the ones `behold demo three-cloud` boots (chant-floci, chant-floci-az,
|
|
@@ -115,10 +115,21 @@ async function applyGcp(): Promise<string> {
|
|
|
115
115
|
// is not written (chant warns). The URI is read from the service instead.
|
|
116
116
|
// The service's location is the manifest's, or us-central1 where gcpApply
|
|
117
117
|
// puts a service that names none.
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
// The RunService's own location: the load balancer's kinds say `global`.
|
|
119
|
+
const location = /kind:\s*RunService[\s\S]*?^\s+location:\s*['"]?([a-z0-9-]+)/m.exec(readFileSync(manifest, "utf8"))?.[1] ?? "us-central1";
|
|
120
|
+
const svc = (await getJson(`${GCP}/v2/projects/${GCP_PROJECT}/locations/${location}/services/three-cloud-site`)) as { uri?: string };
|
|
121
|
+
if (!svc.uri) throw new Refusal(`gcp: the Cloud Run service three-cloud-site has no uri yet (${JSON.stringify(svc).slice(0, 300)})`);
|
|
122
|
+
say(`gcp: Cloud Run answers as ${new URL(svc.uri).hostname}`);
|
|
123
|
+
// Route 53 points at the load balancer's address. A chant older than
|
|
124
|
+
// 0.124.35 skips the load balancer kinds ("no mapper"), and then there is
|
|
125
|
+
// no address: the record gets one nothing answers on (192.0.2.1, kept for
|
|
126
|
+
// documentation by RFC 5737), and the page shows GCP failing its check.
|
|
127
|
+
const addr = (await fetch(`${GCP}/compute/v1/projects/${GCP_PROJECT}/global/addresses/three-cloud-ip`).then((r) => (r.ok ? r.json() : {}))) as { address?: string };
|
|
128
|
+
if (!addr.address) {
|
|
129
|
+
say("gcp: the load balancer was NOT APPLIED (it needs chant 0.124.35 or newer), so the gcp record has nothing behind it");
|
|
130
|
+
return "192.0.2.1";
|
|
131
|
+
}
|
|
132
|
+
return addr.address;
|
|
122
133
|
}
|
|
123
134
|
|
|
124
135
|
async function applyAzure(): Promise<string> {
|
|
@@ -146,9 +157,7 @@ async function azureOn(): Promise<void> {
|
|
|
146
157
|
|
|
147
158
|
/** The aws member, or why it could not be applied. */
|
|
148
159
|
async function applyAws(): Promise<{ endpoint: string } | { refused: string }> {
|
|
149
|
-
const
|
|
150
|
-
const subnets = await defaultSubnets();
|
|
151
|
-
const params = withDefaults(template, { vpcId: subnets.vpc, subnetIds: subnets.ids.join(",") });
|
|
160
|
+
const params = build("aws");
|
|
152
161
|
// A stack that rolled back on its first create can't be updated; start it again.
|
|
153
162
|
if ((await stackStatus("three-cloud-aws")) === "ROLLBACK_COMPLETE") {
|
|
154
163
|
await awsDelete({ templatePath: params, stackName: "three-cloud-aws", endpoint: AWS, timeoutMs: 180_000 });
|
|
@@ -201,7 +210,7 @@ async function applyDns(endpoints: Record<string, string>, probes: Record<string
|
|
|
201
210
|
|
|
202
211
|
export async function apply(): Promise<void> {
|
|
203
212
|
const gcp = await applyGcp();
|
|
204
|
-
say(`gcp:
|
|
213
|
+
say(`gcp: the load balancer answers on ${gcp}`);
|
|
205
214
|
const azure = await applyAzure();
|
|
206
215
|
say(`azure: web answers as ${azure}`);
|
|
207
216
|
const aws = await applyAws();
|
|
@@ -223,8 +232,8 @@ export async function apply(): Promise<void> {
|
|
|
223
232
|
awsCheck: { address: "endpoint" in aws ? containerAddress(CONTAINERS.aws) : "192.0.2.1", port: 80 },
|
|
224
233
|
// floci-az serves every app on its own port, by Host header.
|
|
225
234
|
azureCheck: { address: containerAddress(CONTAINERS.azure), port: 4577 },
|
|
226
|
-
// floci-gcp
|
|
227
|
-
gcpCheck: { address: containerAddress(CONTAINERS.gcp), port:
|
|
235
|
+
// floci-gcp opens a forwarding rule's port (80) in its container.
|
|
236
|
+
gcpCheck: { address: gcp === "192.0.2.1" ? gcp : containerAddress(CONTAINERS.gcp), port: 80 },
|
|
228
237
|
},
|
|
229
238
|
);
|
|
230
239
|
say("dns: applied");
|
|
@@ -299,7 +308,7 @@ export function exportPage(out: string): void {
|
|
|
299
308
|
// BEHOLD names the behold to run (a checkout's `tsx src/cli.ts`, say);
|
|
300
309
|
// by default it is the published one.
|
|
301
310
|
const behold = (process.env.BEHOLD ?? "npx --yes @intentius/behold").split(" ");
|
|
302
|
-
const args = [...behold.slice(1), "export", ROOT, "--out", resolve(out), "--open-env", ENV, "--open-zoom", "
|
|
311
|
+
const args = [...behold.slice(1), "export", ROOT, "--out", resolve(out), "--open-env", ENV, "--open-zoom", "logical", "--note", NOTE];
|
|
303
312
|
say(`export: ${behold[0]} ${args.join(" ")}`);
|
|
304
313
|
const r = spawnSync(behold[0]!, args, { env: childEnv, stdio: "inherit" });
|
|
305
314
|
if (r.status !== 0) throw new Refusal(`behold export exited ${r.status}`);
|
|
@@ -329,16 +338,6 @@ async function awsQuery(service: string, form: Record<string, string>): Promise<
|
|
|
329
338
|
return text;
|
|
330
339
|
}
|
|
331
340
|
|
|
332
|
-
async function defaultSubnets(): Promise<{ vpc: string; ids: string[] }> {
|
|
333
|
-
const vpcs = await awsQuery("ec2", { Action: "DescribeVpcs", Version: "2016-11-15", "Filter.1.Name": "isDefault", "Filter.1.Value.1": "true" });
|
|
334
|
-
const vpc = /<vpcId>([^<]+)<\/vpcId>/.exec(vpcs)?.[1];
|
|
335
|
-
if (!vpc) throw new Refusal("aws: the emulator has no default VPC");
|
|
336
|
-
const subnets = await awsQuery("ec2", { Action: "DescribeSubnets", Version: "2016-11-15", "Filter.1.Name": "vpc-id", "Filter.1.Value.1": vpc });
|
|
337
|
-
const ids = [...subnets.matchAll(/<subnetId>([^<]+)<\/subnetId>/g)].map((m) => m[1]!).slice(0, 2);
|
|
338
|
-
if (ids.length < 2) throw new Refusal(`aws: the default VPC ${vpc} has fewer than two subnets`);
|
|
339
|
-
return { vpc, ids };
|
|
340
|
-
}
|
|
341
|
-
|
|
342
341
|
async function stackStatus(stack: string): Promise<string | undefined> {
|
|
343
342
|
try {
|
|
344
343
|
const xml = await awsQuery("cloudformation", { Action: "DescribeStacks", Version: "2010-05-15", StackName: stack });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/behold",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.53",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@hono/node-server": "^2.0.5",
|
|
50
|
-
"@intentius/chant": "^0.124.
|
|
50
|
+
"@intentius/chant": "^0.124.36",
|
|
51
51
|
"@intentius/chant-k8s-client": "^0.124.24",
|
|
52
52
|
"@intentius/pinhole": "^0.5.0",
|
|
53
53
|
"ajv": "^8.20.0",
|