@intentius/chant-lexicon-pulumi 0.124.102 → 0.124.103
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/change-set.d.ts +5 -0
- package/dist/change-set.js +4 -0
- package/dist/chant-floors.d.ts +36 -0
- package/dist/chant-floors.js +36 -0
- package/dist/cost-hold.d.ts +45 -0
- package/dist/cost-hold.js +49 -0
- package/dist/describe-resources.d.ts +10 -0
- package/dist/describe-resources.js +79 -3
- package/dist/disruption.d.ts +50 -0
- package/dist/disruption.js +104 -0
- package/dist/engine-graph.d.ts +1 -1
- package/dist/engine-graph.js +40 -1
- package/dist/health-targets.d.ts +25 -0
- package/dist/health-targets.js +57 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/integrity.json +2 -2
- package/dist/manifest.json +1 -1
- package/dist/plugin.js +33 -1
- package/dist/preview-observation.d.ts +97 -0
- package/dist/preview-observation.js +218 -0
- package/dist/pulumi-up.d.ts +44 -3
- package/dist/pulumi-up.js +71 -11
- package/dist/reference-catalog.d.ts +84 -0
- package/dist/reference-catalog.js +383 -0
- package/dist/reference-props.d.ts +19 -0
- package/dist/reference-props.js +93 -0
- package/dist/stack-references.js +6 -1
- package/dist/workspace-member.js +9 -3
- package/dist/workspace-stack-reads.d.ts +12 -0
- package/dist/workspace-stack-reads.js +60 -0
- package/package.json +3 -3
package/dist/pulumi-up.js
CHANGED
|
@@ -538,6 +538,15 @@ async function planStack(ctx, original, opts) {
|
|
|
538
538
|
throw err;
|
|
539
539
|
}
|
|
540
540
|
const planDigest = read.part.member.planDigest;
|
|
541
|
+
// #5341: the preview document beside the plan, which a wave's cost hold reads as {planJson}.
|
|
542
|
+
const planJson = join(files.scratch, `${fileSafe(r.member)}.preview.json`);
|
|
543
|
+
let wrotePreview = true;
|
|
544
|
+
try {
|
|
545
|
+
writeFileSync(planJson, JSON.stringify(read.preview), { mode: 0o600 });
|
|
546
|
+
}
|
|
547
|
+
catch {
|
|
548
|
+
wrotePreview = false;
|
|
549
|
+
}
|
|
541
550
|
const references = stackReferencesOf(read.prior, input);
|
|
542
551
|
const planned = pulumiMemberPlannedOutputs(r.member, {
|
|
543
552
|
part: read.part,
|
|
@@ -556,6 +565,7 @@ async function planStack(ctx, original, opts) {
|
|
|
556
565
|
shape: read.shape,
|
|
557
566
|
scratch: files.scratch,
|
|
558
567
|
...(files.planFile ? { planFile: files.planFile } : {}),
|
|
568
|
+
...(wrotePreview ? { planJson } : {}),
|
|
559
569
|
...(files.configFile ? { configFile: files.configFile } : {}),
|
|
560
570
|
policy: read.policy,
|
|
561
571
|
...(packs.read ? { policyPacks: packs.read } : {}),
|
|
@@ -602,13 +612,12 @@ export function exportUpdatedAt(exported) {
|
|
|
602
612
|
return typeof time === "string" && !Number.isNaN(Date.parse(time)) ? time : undefined;
|
|
603
613
|
}
|
|
604
614
|
/**
|
|
605
|
-
* `declaredReads` (#4547)
|
|
606
|
-
* export (the index store's,
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
* `/stackReferences/<reference name>/<output>`.
|
|
615
|
+
* The one reader behind `declaredReads` (#4547) and `graphReads` (#5331):
|
|
616
|
+
* each step's `StackReference`s, read from its export (the index store's,
|
|
617
|
+
* else the checked-in one), each resolved to the one other `pulumi-up` step
|
|
618
|
+
* whose project and stack it names, else to the stack it names.
|
|
610
619
|
*/
|
|
611
|
-
export async function
|
|
620
|
+
export async function pulumiStackReads(ctx, members, opts = {}) {
|
|
612
621
|
const steps = members
|
|
613
622
|
.map((m) => {
|
|
614
623
|
const step = m.step;
|
|
@@ -625,15 +634,54 @@ export async function pulumiDeclaredReads(ctx, members, opts = {}) {
|
|
|
625
634
|
const exported = await memberExportOf(s.dir, { stack: s.step.stack, ...(opts.exportStore !== undefined ? { store: opts.exportStore } : {}) });
|
|
626
635
|
for (const ref of pulumiStackReferences(exported)) {
|
|
627
636
|
const found = stackReferenceOwner(ref, { component: s.m.component, project: s.project }, owners);
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
637
|
+
const stack = [ref.org, ref.project ?? s.project, ref.stack].filter((p) => p !== undefined).join("/");
|
|
638
|
+
out.push({
|
|
639
|
+
reader: s.m.component,
|
|
640
|
+
index: s.m.index,
|
|
641
|
+
ref: ref.name,
|
|
642
|
+
target: "owner" in found ? { upstream: found.owner.component } : { external: stack },
|
|
643
|
+
outputs: ref.outputs,
|
|
644
|
+
secretOutputs: ref.secretOutputs,
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return out;
|
|
649
|
+
}
|
|
650
|
+
/**
|
|
651
|
+
* `declaredReads` (#4547): each step's `StackReference`s as reads of the one
|
|
652
|
+
* other `pulumi-up` step whose project and stack the reference names, one
|
|
653
|
+
* per output the export recorded that is not secret, placed at
|
|
654
|
+
* `/stackReferences/<reference name>/<output>`.
|
|
655
|
+
*/
|
|
656
|
+
export async function pulumiDeclaredReads(ctx, members, opts = {}) {
|
|
657
|
+
const out = [];
|
|
658
|
+
for (const r of await pulumiStackReads(ctx, members, opts)) {
|
|
659
|
+
if (!("upstream" in r.target))
|
|
660
|
+
continue;
|
|
661
|
+
for (const output of r.outputs) {
|
|
662
|
+
out.push({ reader: r.reader, index: r.index, upstream: r.target.upstream, output, at: `/stackReferences/${pointerSegment(r.ref)}/${pointerSegment(output)}` });
|
|
633
663
|
}
|
|
634
664
|
}
|
|
635
665
|
return out;
|
|
636
666
|
}
|
|
667
|
+
/**
|
|
668
|
+
* `graphReads` (#5331): the same reads, for `chant graph --components`. One
|
|
669
|
+
* per output the reference recorded, secret ones included by name, or one
|
|
670
|
+
* with no output when the export recorded none. A stack no `pulumi-up` step
|
|
671
|
+
* applies is `external`.
|
|
672
|
+
*/
|
|
673
|
+
export async function pulumiGraphReads(ctx, members, opts = {}) {
|
|
674
|
+
const out = [];
|
|
675
|
+
for (const r of await pulumiStackReads(ctx, members, opts)) {
|
|
676
|
+
const outputs = [...r.outputs, ...r.secretOutputs].sort();
|
|
677
|
+
const where = "upstream" in r.target ? { upstream: r.target.upstream } : { external: r.target.external };
|
|
678
|
+
if (outputs.length === 0)
|
|
679
|
+
out.push({ reader: r.reader, index: r.index, ...where });
|
|
680
|
+
for (const output of outputs)
|
|
681
|
+
out.push({ reader: r.reader, index: r.index, ...where, output });
|
|
682
|
+
}
|
|
683
|
+
return out;
|
|
684
|
+
}
|
|
637
685
|
/** An `up` that exited non-zero, read through the exit-code table (#4553). */
|
|
638
686
|
function upFailure(r, err, policy) {
|
|
639
687
|
const f = pulumiRunFailure(err);
|
|
@@ -834,6 +882,13 @@ export function createPulumiUpCapability(opts = {}) {
|
|
|
834
882
|
...runnerOptions(r, opts),
|
|
835
883
|
});
|
|
836
884
|
},
|
|
885
|
+
// #5345: a secret prints as `[secret]` under --show-secrets=false: the engine's mark, which a replan keeps no digest of.
|
|
886
|
+
async markedOutputs(ctx, original) {
|
|
887
|
+
const { step: input } = pulumiReviewStep(original, ctx.env, templateOf(opts));
|
|
888
|
+
const r = resolveStep(input, opts);
|
|
889
|
+
const outputs = await pulumiMemberStackOutputs({ dir: r.dir, stack: input.stack, engine: r.engine, ...runnerOptions(r, opts) });
|
|
890
|
+
return { outputs, sensitive: pulumiSecretOutputNames(outputs) };
|
|
891
|
+
},
|
|
837
892
|
releaseInputs: (input, ctx) => pulumiReleaseInputs(input, ctx),
|
|
838
893
|
// #4552: resource on plunge, the stack (target) on stock Pulumi.
|
|
839
894
|
defaultLockGrain(input) {
|
|
@@ -870,6 +925,11 @@ export function createPulumiUpCapability(opts = {}) {
|
|
|
870
925
|
// #4555: the stack, the engine and the summary's counts, for the step's span and run record.
|
|
871
926
|
traceFacts: (input, outcome) => pulumiTraceFacts(input, outcome),
|
|
872
927
|
declaredReads: (ctx, members) => pulumiDeclaredReads(ctx, members, opts.snapshots !== undefined ? { exportStore: opts.snapshots } : {}),
|
|
928
|
+
graphReads: (ctx, members) => pulumiGraphReads(ctx, members, opts.snapshots !== undefined ? { exportStore: opts.snapshots } : {}),
|
|
873
929
|
};
|
|
874
930
|
}
|
|
931
|
+
/** The outputs `pulumi stack output --show-secrets=false` printed as `[secret]` (#5345), sorted. */
|
|
932
|
+
export function pulumiSecretOutputNames(outputs) {
|
|
933
|
+
return Object.keys(outputs).filter((name) => outputs[name] === "[secret]").sort();
|
|
934
|
+
}
|
|
875
935
|
export const pulumiUpCapability = createPulumiUpCapability();
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the resources of a Pulumi stack name each other, as a `ReferenceCatalog`
|
|
3
|
+
* over the aws, gcp, azure and kubernetes providers (#5330).
|
|
4
|
+
*
|
|
5
|
+
* `chant workspace graph` runs each lexicon's catalog over the composed
|
|
6
|
+
* nodes (`packages/core/src/workspace/catalog-edges.ts`), and behold keeps
|
|
7
|
+
* its own name matcher for a lexicon that has none. This is the pulumi
|
|
8
|
+
* lexicon's, shaped like the terraform lexicon's
|
|
9
|
+
* (`../../terraform/src/behaviour/reference-catalog.ts`): rules grouped by
|
|
10
|
+
* the relation they produce, a short list of kinds known to reference
|
|
11
|
+
* nothing, and `identities` for what else names a kind.
|
|
12
|
+
*
|
|
13
|
+
* ## Shape
|
|
14
|
+
*
|
|
15
|
+
* A node's kind is the Pulumi type token (`aws:ec2/subnet:Subnet`), which is
|
|
16
|
+
* what the member read gives it (`./workspace-member.ts`). Its attrs are the
|
|
17
|
+
* resource's inputs as the stack export records them, in Pulumi's camelCase
|
|
18
|
+
* (`vpcId`, `networkConfiguration.subnets[]`), plus an `outputs` object
|
|
19
|
+
* holding its `id` and top-level string outputs (`outputs.arn`,
|
|
20
|
+
* `outputs.selfLink`), from `./reference-props.ts`. An export holds resolved
|
|
21
|
+
* values, so a reference reads as the physical id, ARN or name of its
|
|
22
|
+
* target, and the rules match that against the target's identities.
|
|
23
|
+
*
|
|
24
|
+
* ## Ids, ARNs and names
|
|
25
|
+
*
|
|
26
|
+
* Every target is identified by `outputs.id`, `outputs.arn`, `outputs.name`
|
|
27
|
+
* and the `name` input, with the extra names its provider uses
|
|
28
|
+
* ({@link EXTRA_IDS}): a bucket's `bucket`, a service account's `accountId`
|
|
29
|
+
* and `email`, a Kubernetes object's `metadata.name`. A rule names the kind
|
|
30
|
+
* it expects, so a name that two kinds share joins neither to the wrong one.
|
|
31
|
+
*
|
|
32
|
+
* ## Targets in other members
|
|
33
|
+
*
|
|
34
|
+
* A reference can name a resource that another member declares. The
|
|
35
|
+
* terraform lexicon identifies a few kinds by name (`aws_iam_role`,
|
|
36
|
+
* `aws_eks_cluster`, `aws_secretsmanager_secret`, `google_service_account`,
|
|
37
|
+
* `google_container_cluster`, `google_secret_manager_secret`,
|
|
38
|
+
* `azurerm_kubernetes_cluster`), and the k8s lexicon identifies its objects
|
|
39
|
+
* by `metadata.name`. A rule toward one of those has a second rule for the
|
|
40
|
+
* other lexicon's kind, under the same id, so a value that names a node of
|
|
41
|
+
* either is found and the other is not reported as missing. A Terraform
|
|
42
|
+
* block that names no identity (a VPC's id before it is applied) is not
|
|
43
|
+
* reachable by value; the edge appears once the id is on the node.
|
|
44
|
+
*
|
|
45
|
+
* ## Kubernetes
|
|
46
|
+
*
|
|
47
|
+
* A name is unique only inside its namespace. The namespaced kinds are
|
|
48
|
+
* `scopes` on `metadata.namespace`, and a pod spec's references to a service
|
|
49
|
+
* account, a ConfigMap or a Secret are `join` rules that look the name up in
|
|
50
|
+
* the holder's namespace across members, so a Deployment in this lexicon
|
|
51
|
+
* reaches a ServiceAccount of the k8s lexicon in the same namespace. A
|
|
52
|
+
* namespaced object also has an `in namespace` containment toward its
|
|
53
|
+
* `Namespace`, optional because most namespaces are created elsewhere.
|
|
54
|
+
*
|
|
55
|
+
* ## What "no rule" means
|
|
56
|
+
*
|
|
57
|
+
* A kind with no rule produces no edges. {@link REFERENCES_NOTHING} lists
|
|
58
|
+
* kinds looked at and found to hold no argument that identifies another
|
|
59
|
+
* resource, so {@link isUnresolvedKind} separates "nobody wrote a rule" from
|
|
60
|
+
* "there is nothing to find".
|
|
61
|
+
*
|
|
62
|
+
* ## Adding a rule
|
|
63
|
+
*
|
|
64
|
+
* A rule is one call to `rule` in the list for its provider: holder kind,
|
|
65
|
+
* input path, target kind or kinds, label. A target kind that others name
|
|
66
|
+
* goes in {@link EXTRA_IDS} or {@link NAMED_KINDS}. The test "each rule draws
|
|
67
|
+
* its edge" covers a new rule with no test of its own.
|
|
68
|
+
*/
|
|
69
|
+
import { type ReferenceCatalog } from "@intentius/chant/graph-refs";
|
|
70
|
+
/**
|
|
71
|
+
* Pulumi kinds this catalog has looked at and found to hold no input that
|
|
72
|
+
* identifies another resource. A node of one of these kinds is not an
|
|
73
|
+
* unresolved kind: nothing was looked for because there is nothing to find.
|
|
74
|
+
*/
|
|
75
|
+
export declare const REFERENCES_NOTHING: ReadonlySet<string>;
|
|
76
|
+
/** The catalog. Rules are grouped by provider; each provider lists containment before references. */
|
|
77
|
+
export declare const PULUMI_REFERENCE_CATALOG: ReferenceCatalog;
|
|
78
|
+
/** Every Pulumi kind the catalog has at least one rule from. */
|
|
79
|
+
export declare const CATALOGUED_KINDS: ReadonlySet<string>;
|
|
80
|
+
/**
|
|
81
|
+
* True when nothing would be looked for on a node of this kind: no rule is
|
|
82
|
+
* written for it, and it is not one of the kinds known to reference nothing.
|
|
83
|
+
*/
|
|
84
|
+
export declare function isUnresolvedKind(kind: string): boolean;
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the resources of a Pulumi stack name each other, as a `ReferenceCatalog`
|
|
3
|
+
* over the aws, gcp, azure and kubernetes providers (#5330).
|
|
4
|
+
*
|
|
5
|
+
* `chant workspace graph` runs each lexicon's catalog over the composed
|
|
6
|
+
* nodes (`packages/core/src/workspace/catalog-edges.ts`), and behold keeps
|
|
7
|
+
* its own name matcher for a lexicon that has none. This is the pulumi
|
|
8
|
+
* lexicon's, shaped like the terraform lexicon's
|
|
9
|
+
* (`../../terraform/src/behaviour/reference-catalog.ts`): rules grouped by
|
|
10
|
+
* the relation they produce, a short list of kinds known to reference
|
|
11
|
+
* nothing, and `identities` for what else names a kind.
|
|
12
|
+
*
|
|
13
|
+
* ## Shape
|
|
14
|
+
*
|
|
15
|
+
* A node's kind is the Pulumi type token (`aws:ec2/subnet:Subnet`), which is
|
|
16
|
+
* what the member read gives it (`./workspace-member.ts`). Its attrs are the
|
|
17
|
+
* resource's inputs as the stack export records them, in Pulumi's camelCase
|
|
18
|
+
* (`vpcId`, `networkConfiguration.subnets[]`), plus an `outputs` object
|
|
19
|
+
* holding its `id` and top-level string outputs (`outputs.arn`,
|
|
20
|
+
* `outputs.selfLink`), from `./reference-props.ts`. An export holds resolved
|
|
21
|
+
* values, so a reference reads as the physical id, ARN or name of its
|
|
22
|
+
* target, and the rules match that against the target's identities.
|
|
23
|
+
*
|
|
24
|
+
* ## Ids, ARNs and names
|
|
25
|
+
*
|
|
26
|
+
* Every target is identified by `outputs.id`, `outputs.arn`, `outputs.name`
|
|
27
|
+
* and the `name` input, with the extra names its provider uses
|
|
28
|
+
* ({@link EXTRA_IDS}): a bucket's `bucket`, a service account's `accountId`
|
|
29
|
+
* and `email`, a Kubernetes object's `metadata.name`. A rule names the kind
|
|
30
|
+
* it expects, so a name that two kinds share joins neither to the wrong one.
|
|
31
|
+
*
|
|
32
|
+
* ## Targets in other members
|
|
33
|
+
*
|
|
34
|
+
* A reference can name a resource that another member declares. The
|
|
35
|
+
* terraform lexicon identifies a few kinds by name (`aws_iam_role`,
|
|
36
|
+
* `aws_eks_cluster`, `aws_secretsmanager_secret`, `google_service_account`,
|
|
37
|
+
* `google_container_cluster`, `google_secret_manager_secret`,
|
|
38
|
+
* `azurerm_kubernetes_cluster`), and the k8s lexicon identifies its objects
|
|
39
|
+
* by `metadata.name`. A rule toward one of those has a second rule for the
|
|
40
|
+
* other lexicon's kind, under the same id, so a value that names a node of
|
|
41
|
+
* either is found and the other is not reported as missing. A Terraform
|
|
42
|
+
* block that names no identity (a VPC's id before it is applied) is not
|
|
43
|
+
* reachable by value; the edge appears once the id is on the node.
|
|
44
|
+
*
|
|
45
|
+
* ## Kubernetes
|
|
46
|
+
*
|
|
47
|
+
* A name is unique only inside its namespace. The namespaced kinds are
|
|
48
|
+
* `scopes` on `metadata.namespace`, and a pod spec's references to a service
|
|
49
|
+
* account, a ConfigMap or a Secret are `join` rules that look the name up in
|
|
50
|
+
* the holder's namespace across members, so a Deployment in this lexicon
|
|
51
|
+
* reaches a ServiceAccount of the k8s lexicon in the same namespace. A
|
|
52
|
+
* namespaced object also has an `in namespace` containment toward its
|
|
53
|
+
* `Namespace`, optional because most namespaces are created elsewhere.
|
|
54
|
+
*
|
|
55
|
+
* ## What "no rule" means
|
|
56
|
+
*
|
|
57
|
+
* A kind with no rule produces no edges. {@link REFERENCES_NOTHING} lists
|
|
58
|
+
* kinds looked at and found to hold no argument that identifies another
|
|
59
|
+
* resource, so {@link isUnresolvedKind} separates "nobody wrote a rule" from
|
|
60
|
+
* "there is nothing to find".
|
|
61
|
+
*
|
|
62
|
+
* ## Adding a rule
|
|
63
|
+
*
|
|
64
|
+
* A rule is one call to `rule` in the list for its provider: holder kind,
|
|
65
|
+
* input path, target kind or kinds, label. A target kind that others name
|
|
66
|
+
* goes in {@link EXTRA_IDS} or {@link NAMED_KINDS}. The test "each rule draws
|
|
67
|
+
* its edge" covers a new rule with no test of its own.
|
|
68
|
+
*/
|
|
69
|
+
import { readPath } from "@intentius/chant/graph-refs";
|
|
70
|
+
/** Terraform kinds the terraform lexicon identifies by name, keyed by the Pulumi kind that is the same resource. */
|
|
71
|
+
const TERRAFORM_ALIAS = {
|
|
72
|
+
"aws:iam/role:Role": "aws_iam_role",
|
|
73
|
+
"aws:eks/cluster:Cluster": "aws_eks_cluster",
|
|
74
|
+
"aws:secretsmanager/secret:Secret": "aws_secretsmanager_secret",
|
|
75
|
+
"gcp:serviceaccount/account:Account": "google_service_account",
|
|
76
|
+
"gcp:container/cluster:Cluster": "google_container_cluster",
|
|
77
|
+
"gcp:secretmanager/secret:Secret": "google_secret_manager_secret",
|
|
78
|
+
"azure:containerservice/kubernetesCluster:KubernetesCluster": "azurerm_kubernetes_cluster",
|
|
79
|
+
};
|
|
80
|
+
/** The k8s lexicon's kind for a Pulumi Kubernetes kind. */
|
|
81
|
+
const K8S_ALIAS = {
|
|
82
|
+
"kubernetes:core/v1:Namespace": "K8s::Core::Namespace",
|
|
83
|
+
"kubernetes:core/v1:ServiceAccount": "K8s::Core::ServiceAccount",
|
|
84
|
+
"kubernetes:core/v1:ConfigMap": "K8s::Core::ConfigMap",
|
|
85
|
+
"kubernetes:core/v1:Secret": "K8s::Core::Secret",
|
|
86
|
+
};
|
|
87
|
+
/** A Pulumi kind and the kinds of other lexicons that stand for the same resource, the Pulumi kind last: a missing target is reported under the last rule of its id. */
|
|
88
|
+
const targets = (kind) => [...[TERRAFORM_ALIAS[kind], K8S_ALIAS[kind]].filter((k) => k !== undefined), kind];
|
|
89
|
+
const rule = (from, path, target, label, relation = "reference", viaAttr) => targets(target).map((targetKind) => ({ from, path, targetKind, relation, label, ...(viaAttr ? { viaAttr } : {}) }));
|
|
90
|
+
const containment = (from, path, target, label, viaAttr) => rule(from, path, target, label, "containment", viaAttr);
|
|
91
|
+
/** `rule` for a value that names no node most of the time (an env var, a free-form name). */
|
|
92
|
+
const maybe = (from, path, target, label) => rule(from, path, target, label).map((r) => ({ ...r, optional: true }));
|
|
93
|
+
// ── aws ──
|
|
94
|
+
const EC2 = (t) => `aws:ec2/${t[0].toLowerCase()}${t.slice(1)}:${t}`;
|
|
95
|
+
const VPC = EC2("Vpc");
|
|
96
|
+
const SUBNET = EC2("Subnet");
|
|
97
|
+
const SECURITY_GROUP = EC2("SecurityGroup");
|
|
98
|
+
const ROUTE_TABLE = EC2("RouteTable");
|
|
99
|
+
const INTERNET_GATEWAY = EC2("InternetGateway");
|
|
100
|
+
const NAT_GATEWAY = EC2("NatGateway");
|
|
101
|
+
const EIP = EC2("Eip");
|
|
102
|
+
const INSTANCE = EC2("Instance");
|
|
103
|
+
const NETWORK_INTERFACE = EC2("NetworkInterface");
|
|
104
|
+
const LB = "aws:lb/loadBalancer:LoadBalancer";
|
|
105
|
+
const TARGET_GROUP = "aws:lb/targetGroup:TargetGroup";
|
|
106
|
+
const ECS_CLUSTER = "aws:ecs/cluster:Cluster";
|
|
107
|
+
const ECS_TASK = "aws:ecs/taskDefinition:TaskDefinition";
|
|
108
|
+
const IAM_ROLE = "aws:iam/role:Role";
|
|
109
|
+
const IAM_POLICY = "aws:iam/policy:Policy";
|
|
110
|
+
const INSTANCE_PROFILE = "aws:iam/instanceProfile:InstanceProfile";
|
|
111
|
+
const LAMBDA = "aws:lambda/function:Function";
|
|
112
|
+
const S3_BUCKET = "aws:s3/bucket:Bucket";
|
|
113
|
+
const S3_BUCKET_V2 = "aws:s3/bucketV2:BucketV2";
|
|
114
|
+
const ROUTE53_ZONE = "aws:route53/zone:Zone";
|
|
115
|
+
const EKS_CLUSTER = "aws:eks/cluster:Cluster";
|
|
116
|
+
const RDS_SUBNET_GROUP = "aws:rds/subnetGroup:SubnetGroup";
|
|
117
|
+
const RDS_CLUSTER = "aws:rds/cluster:Cluster";
|
|
118
|
+
const SQS_QUEUE = "aws:sqs/queue:Queue";
|
|
119
|
+
const SNS_TOPIC = "aws:sns/topic:Topic";
|
|
120
|
+
const KMS_KEY = "aws:kms/key:Key";
|
|
121
|
+
const LOG_GROUP = "aws:cloudwatch/logGroup:LogGroup";
|
|
122
|
+
/** A bucket is `Bucket` or `BucketV2`; a rule toward one has the same rule toward the other. */
|
|
123
|
+
const bucketRules = (from, path, label, relation = "reference") => [S3_BUCKET, S3_BUCKET_V2].flatMap((b) => rule(from, path, b, label, relation));
|
|
124
|
+
const awsRules = [
|
|
125
|
+
// containment
|
|
126
|
+
...[SUBNET, SECURITY_GROUP, ROUTE_TABLE, INTERNET_GATEWAY, "aws:lb/targetGroup:TargetGroup", "aws:ec2/vpcEndpoint:VpcEndpoint"].flatMap((k) => containment(k, "vpcId", VPC, "in VPC")),
|
|
127
|
+
...containment(INSTANCE, "subnetId", SUBNET, "in subnet", "subnetId"),
|
|
128
|
+
...[NAT_GATEWAY, NETWORK_INTERFACE].flatMap((k) => containment(k, "subnetId", SUBNET, "in subnet")),
|
|
129
|
+
...[LB, "aws:rds/subnetGroup:SubnetGroup", "aws:elasticache/subnetGroup:SubnetGroup", "aws:eks/nodeGroup:NodeGroup"].flatMap((k) => containment(k, k === LB ? "subnets[]" : "subnetIds[]", SUBNET, "in subnet")),
|
|
130
|
+
...containment(LAMBDA, "vpcConfig.subnetIds[]", SUBNET, "in subnet"),
|
|
131
|
+
...containment("aws:ecs/service:Service", "networkConfiguration.subnets[]", SUBNET, "in subnet"),
|
|
132
|
+
...containment(EKS_CLUSTER, "vpcConfig.subnetIds[]", SUBNET, "in subnet"),
|
|
133
|
+
...[RDS_CLUSTER, "aws:rds/instance:Instance"].flatMap((k) => containment(k, "dbSubnetGroupName", RDS_SUBNET_GROUP, "in subnet group")),
|
|
134
|
+
// references
|
|
135
|
+
...rule(INSTANCE, "vpcSecurityGroupIds[]", SECURITY_GROUP, "sg", "reference", "vpcSecurityGroupIds"),
|
|
136
|
+
...rule(INSTANCE, "iamInstanceProfile", INSTANCE_PROFILE, "as"),
|
|
137
|
+
...[NETWORK_INTERFACE, LB].flatMap((k) => rule(k, "securityGroups[]", SECURITY_GROUP, "sg")),
|
|
138
|
+
...rule(LAMBDA, "vpcConfig.securityGroupIds[]", SECURITY_GROUP, "sg"),
|
|
139
|
+
...[RDS_CLUSTER, "aws:rds/instance:Instance"].flatMap((k) => rule(k, "vpcSecurityGroupIds[]", SECURITY_GROUP, "sg")),
|
|
140
|
+
...rule("aws:ecs/service:Service", "networkConfiguration.securityGroups[]", SECURITY_GROUP, "sg"),
|
|
141
|
+
...rule("aws:ec2/securityGroupRule:SecurityGroupRule", "securityGroupId", SECURITY_GROUP, "rule on", "reference", "securityGroupId"),
|
|
142
|
+
...rule("aws:ec2/securityGroupRule:SecurityGroupRule", "sourceSecurityGroupId", SECURITY_GROUP, "allows"),
|
|
143
|
+
...rule("aws:lb/listener:Listener", "loadBalancerArn", LB, "on"),
|
|
144
|
+
...rule("aws:lb/listener:Listener", "defaultActions[].targetGroupArn", TARGET_GROUP, "forwards to"),
|
|
145
|
+
...rule("aws:lb/targetGroupAttachment:TargetGroupAttachment", "targetGroupArn", TARGET_GROUP, "in group"),
|
|
146
|
+
...[INSTANCE, LAMBDA].flatMap((k) => maybe("aws:lb/targetGroupAttachment:TargetGroupAttachment", "targetId", k, "targets")),
|
|
147
|
+
...rule("aws:ec2/route:Route", "routeTableId", ROUTE_TABLE, "in table", "reference", "routeTableId"),
|
|
148
|
+
...rule("aws:ec2/route:Route", "gatewayId", INTERNET_GATEWAY, "via", "reference", "gatewayId"),
|
|
149
|
+
...rule("aws:ec2/route:Route", "natGatewayId", NAT_GATEWAY, "via"),
|
|
150
|
+
...rule("aws:ec2/routeTableAssociation:RouteTableAssociation", "subnetId", SUBNET, "associates", "reference", "subnetId"),
|
|
151
|
+
...rule("aws:ec2/routeTableAssociation:RouteTableAssociation", "routeTableId", ROUTE_TABLE, "to table", "reference", "routeTableId"),
|
|
152
|
+
...rule("aws:ec2/internetGatewayAttachment:InternetGatewayAttachment", "internetGatewayId", INTERNET_GATEWAY, "attaches"),
|
|
153
|
+
...rule("aws:ec2/internetGatewayAttachment:InternetGatewayAttachment", "vpcId", VPC, "to VPC"),
|
|
154
|
+
...rule(NAT_GATEWAY, "allocationId", EIP, "uses"),
|
|
155
|
+
...rule("aws:ecs/service:Service", "cluster", ECS_CLUSTER, "in cluster"),
|
|
156
|
+
...rule("aws:ecs/service:Service", "taskDefinition", ECS_TASK, "runs"),
|
|
157
|
+
...rule("aws:ecs/service:Service", "loadBalancers[].targetGroupArn", TARGET_GROUP, "registered in"),
|
|
158
|
+
...["executionRoleArn", "taskRoleArn"].flatMap((p) => rule(ECS_TASK, p, IAM_ROLE, "as")),
|
|
159
|
+
...rule(LAMBDA, "role", IAM_ROLE, "as"),
|
|
160
|
+
...rule(EKS_CLUSTER, "roleArn", IAM_ROLE, "as"),
|
|
161
|
+
...rule("aws:eks/nodeGroup:NodeGroup", "clusterName", EKS_CLUSTER, "in cluster"),
|
|
162
|
+
...rule("aws:eks/nodeGroup:NodeGroup", "nodeRoleArn", IAM_ROLE, "as"),
|
|
163
|
+
...rule("aws:iam/rolePolicyAttachment:RolePolicyAttachment", "role", IAM_ROLE, "on"),
|
|
164
|
+
...rule("aws:iam/rolePolicyAttachment:RolePolicyAttachment", "policyArn", IAM_POLICY, "attaches"),
|
|
165
|
+
...rule("aws:iam/rolePolicy:RolePolicy", "role", IAM_ROLE, "on"),
|
|
166
|
+
...rule(INSTANCE_PROFILE, "role", IAM_ROLE, "holds"),
|
|
167
|
+
...["aws:s3/bucketPolicy:BucketPolicy", "aws:s3/bucketAclV2:BucketAclV2", "aws:s3/bucketVersioningV2:BucketVersioningV2", "aws:s3/bucketPublicAccessBlock:BucketPublicAccessBlock", "aws:s3/bucketServerSideEncryptionConfigurationV2:BucketServerSideEncryptionConfigurationV2", "aws:s3/bucketOwnershipControls:BucketOwnershipControls"].flatMap((k) => bucketRules(k, "bucket", "setting on")),
|
|
168
|
+
...rule("aws:sqs/queuePolicy:QueuePolicy", "queueUrl", SQS_QUEUE, "grant on"),
|
|
169
|
+
...rule("aws:sns/topicSubscription:TopicSubscription", "topic", SNS_TOPIC, "on"),
|
|
170
|
+
...[LOG_GROUP, SNS_TOPIC].flatMap((k) => rule(k, k === LOG_GROUP ? "kmsKeyId" : "kmsMasterKeyId", KMS_KEY, "encrypted with")),
|
|
171
|
+
...rule("aws:route53/record:Record", "zoneId", ROUTE53_ZONE, "in zone"),
|
|
172
|
+
...rule("aws:secretsmanager/secretVersion:SecretVersion", "secretId", "aws:secretsmanager/secret:Secret", "version of"),
|
|
173
|
+
...rule("aws:lambda/permission:Permission", "function", LAMBDA, "grant on"),
|
|
174
|
+
...rule("aws:lambda/eventSourceMapping:EventSourceMapping", "functionName", LAMBDA, "invokes"),
|
|
175
|
+
...rule("aws:lambda/eventSourceMapping:EventSourceMapping", "eventSourceArn", SQS_QUEUE, "drains"),
|
|
176
|
+
// A bucket's regional domain name or a load balancer's DNS name; no target kind.
|
|
177
|
+
{ from: "aws:cloudfront/distribution:Distribution", path: "origins[].domainName", relation: "reference", label: "origin" },
|
|
178
|
+
];
|
|
179
|
+
// ── gcp ──
|
|
180
|
+
const GCP_NETWORK = "gcp:compute/network:Network";
|
|
181
|
+
const GCP_SUBNETWORK = "gcp:compute/subnetwork:Subnetwork";
|
|
182
|
+
const GCP_INSTANCE = "gcp:compute/instance:Instance";
|
|
183
|
+
const GCP_CLUSTER = "gcp:container/cluster:Cluster";
|
|
184
|
+
const GCP_SERVICE_ACCOUNT = "gcp:serviceaccount/account:Account";
|
|
185
|
+
const GCP_SECRET = "gcp:secretmanager/secret:Secret";
|
|
186
|
+
const GCP_BUCKET = "gcp:storage/bucket:Bucket";
|
|
187
|
+
const gcpRules = [
|
|
188
|
+
...containment(GCP_SUBNETWORK, "network", GCP_NETWORK, "in network"),
|
|
189
|
+
...containment(GCP_INSTANCE, "networkInterfaces[].subnetwork", GCP_SUBNETWORK, "in subnet"),
|
|
190
|
+
...rule(GCP_INSTANCE, "networkInterfaces[].network", GCP_NETWORK, "on network"),
|
|
191
|
+
...rule(GCP_INSTANCE, "serviceAccount.email", GCP_SERVICE_ACCOUNT, "as"),
|
|
192
|
+
...rule(GCP_CLUSTER, "network", GCP_NETWORK, "on network"),
|
|
193
|
+
...containment(GCP_CLUSTER, "subnetwork", GCP_SUBNETWORK, "in subnet"),
|
|
194
|
+
...rule("gcp:container/nodePool:NodePool", "cluster", GCP_CLUSTER, "in cluster"),
|
|
195
|
+
...rule("gcp:container/nodePool:NodePool", "nodeConfig.serviceAccount", GCP_SERVICE_ACCOUNT, "as"),
|
|
196
|
+
...rule("gcp:compute/firewall:Firewall", "network", GCP_NETWORK, "on network"),
|
|
197
|
+
...rule("gcp:compute/router:Router", "network", GCP_NETWORK, "on network"),
|
|
198
|
+
...rule("gcp:secretmanager/secretVersion:SecretVersion", "secret", GCP_SECRET, "version of"),
|
|
199
|
+
...rule("gcp:secretmanager/secretIamMember:SecretIamMember", "secretId", GCP_SECRET, "grant on"),
|
|
200
|
+
...rule("gcp:storage/bucketIAMMember:BucketIAMMember", "bucket", GCP_BUCKET, "grant on"),
|
|
201
|
+
...rule("gcp:storage/bucketIAMBinding:BucketIAMBinding", "bucket", GCP_BUCKET, "grant on"),
|
|
202
|
+
...rule("gcp:storage/bucketObject:BucketObject", "bucket", GCP_BUCKET, "in bucket"),
|
|
203
|
+
...rule("gcp:serviceaccount/iAMMember:IAMMember", "serviceAccountId", GCP_SERVICE_ACCOUNT, "grant on"),
|
|
204
|
+
...rule("gcp:serviceaccount/key:Key", "serviceAccountId", GCP_SERVICE_ACCOUNT, "key of"),
|
|
205
|
+
];
|
|
206
|
+
const AZURE_NATIVE = {
|
|
207
|
+
group: "azure-native:resources:ResourceGroup",
|
|
208
|
+
vnet: "azure-native:network:VirtualNetwork",
|
|
209
|
+
subnet: "azure-native:network:Subnet",
|
|
210
|
+
aks: "azure-native:containerservice:ManagedCluster",
|
|
211
|
+
nic: "azure-native:network:NetworkInterface",
|
|
212
|
+
nsg: "azure-native:network:NetworkSecurityGroup",
|
|
213
|
+
inGroup: ["azure-native:storage:StorageAccount", "azure-native:keyvault:Vault", "azure-native:network:PublicIPAddress", "azure-native:compute:VirtualMachine", "azure-native:web:WebApp", "azure-native:app:ContainerApp", "azure-native:app:ManagedEnvironment", "azure-native:containerregistry:Registry"],
|
|
214
|
+
subnetVnet: "virtualNetworkName",
|
|
215
|
+
aksSubnet: "agentPoolProfiles[].vnetSubnetID",
|
|
216
|
+
nicSubnet: "ipConfigurations[].subnet.id",
|
|
217
|
+
nicNsg: "networkSecurityGroup.id",
|
|
218
|
+
};
|
|
219
|
+
const AZURE_CLASSIC = {
|
|
220
|
+
group: "azure:core/resourceGroup:ResourceGroup",
|
|
221
|
+
vnet: "azure:network/virtualNetwork:VirtualNetwork",
|
|
222
|
+
subnet: "azure:network/subnet:Subnet",
|
|
223
|
+
aks: "azure:containerservice/kubernetesCluster:KubernetesCluster",
|
|
224
|
+
nic: "azure:network/networkInterface:NetworkInterface",
|
|
225
|
+
nsg: "azure:network/networkSecurityGroup:NetworkSecurityGroup",
|
|
226
|
+
inGroup: ["azure:storage/account:Account", "azure:keyvault/keyVault:KeyVault", "azure:network/publicIp:PublicIp", "azure:compute/linuxVirtualMachine:LinuxVirtualMachine", "azure:containerservice/registry:Registry"],
|
|
227
|
+
subnetVnet: "virtualNetworkName",
|
|
228
|
+
aksSubnet: "defaultNodePool.vnetSubnetId",
|
|
229
|
+
nicSubnet: "ipConfigurations[].subnetId",
|
|
230
|
+
nicNsg: "networkSecurityGroupId",
|
|
231
|
+
};
|
|
232
|
+
const AZURE_FAMILIES = [AZURE_NATIVE, AZURE_CLASSIC];
|
|
233
|
+
function azureRulesOf(f) {
|
|
234
|
+
return [
|
|
235
|
+
// Both providers name the group by `resourceGroupName`.
|
|
236
|
+
...[f.vnet, f.subnet, f.aks, f.nic, f.nsg, ...f.inGroup].flatMap((k) => containment(k, "resourceGroupName", f.group, "in resource group")),
|
|
237
|
+
...containment(f.subnet, f.subnetVnet, f.vnet, "in VNet"),
|
|
238
|
+
...containment(f.aks, f.aksSubnet, f.subnet, "in subnet"),
|
|
239
|
+
...containment(f.nic, f.nicSubnet, f.subnet, "in subnet"),
|
|
240
|
+
...rule(f.nic, f.nicNsg, f.nsg, "sg"),
|
|
241
|
+
];
|
|
242
|
+
}
|
|
243
|
+
const azureRules = AZURE_FAMILIES.flatMap(azureRulesOf);
|
|
244
|
+
// ── kubernetes ──
|
|
245
|
+
/** Workload kinds and the path to their pod spec. */
|
|
246
|
+
const POD_SPECS = [
|
|
247
|
+
["kubernetes:core/v1:Pod", "spec"],
|
|
248
|
+
["kubernetes:apps/v1:Deployment", "spec.template.spec"],
|
|
249
|
+
["kubernetes:apps/v1:StatefulSet", "spec.template.spec"],
|
|
250
|
+
["kubernetes:apps/v1:DaemonSet", "spec.template.spec"],
|
|
251
|
+
["kubernetes:batch/v1:Job", "spec.template.spec"],
|
|
252
|
+
["kubernetes:batch/v1:CronJob", "spec.jobTemplate.spec.template.spec"],
|
|
253
|
+
];
|
|
254
|
+
const NAMESPACE = "kubernetes:core/v1:Namespace";
|
|
255
|
+
const SERVICE_ACCOUNT = "kubernetes:core/v1:ServiceAccount";
|
|
256
|
+
const CONFIG_MAP = "kubernetes:core/v1:ConfigMap";
|
|
257
|
+
const SECRET = "kubernetes:core/v1:Secret";
|
|
258
|
+
/** Kinds that sit in a namespace, so `metadata.namespace` places them. */
|
|
259
|
+
const NAMESPACED_KINDS = [
|
|
260
|
+
...POD_SPECS.map(([kind]) => kind),
|
|
261
|
+
"kubernetes:core/v1:Service",
|
|
262
|
+
CONFIG_MAP,
|
|
263
|
+
SECRET,
|
|
264
|
+
SERVICE_ACCOUNT,
|
|
265
|
+
"kubernetes:core/v1:PersistentVolumeClaim",
|
|
266
|
+
"kubernetes:networking.k8s.io/v1:Ingress",
|
|
267
|
+
"kubernetes:rbac.authorization.k8s.io/v1:Role",
|
|
268
|
+
"kubernetes:rbac.authorization.k8s.io/v1:RoleBinding",
|
|
269
|
+
];
|
|
270
|
+
/** Kinds other objects name by `metadata.name`. */
|
|
271
|
+
const NAMED_KINDS = [...NAMESPACED_KINDS, NAMESPACE];
|
|
272
|
+
const first = (holder, path) => readPath(holder.attrs, path).find((v) => v !== "");
|
|
273
|
+
/**
|
|
274
|
+
* A pod spec's reference to a namespaced object, by name: the name is looked
|
|
275
|
+
* up inside the holder's `metadata.namespace` in any member, so the object
|
|
276
|
+
* can be this lexicon's or the k8s lexicon's. A holder that names no
|
|
277
|
+
* namespace looks inside its own scope.
|
|
278
|
+
*/
|
|
279
|
+
function namespacedRule(from, path, target, label) {
|
|
280
|
+
return targets(target).map((targetKind) => ({
|
|
281
|
+
from,
|
|
282
|
+
path,
|
|
283
|
+
targetKind,
|
|
284
|
+
relation: "reference",
|
|
285
|
+
label,
|
|
286
|
+
join(holder, find) {
|
|
287
|
+
const namespace = first(holder, "metadata.namespace");
|
|
288
|
+
return [...new Set(readPath(holder.attrs, path))]
|
|
289
|
+
.filter((name) => name !== "")
|
|
290
|
+
.map((name) => ({ value: name, targets: (namespace === undefined ? find(name) : find(name, namespace)).filter((n) => n.kind === targetKind) }));
|
|
291
|
+
},
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
/** What a pod spec names: its service account, mounted config and secrets, and env sources. */
|
|
295
|
+
function podSpecRules(kind, p) {
|
|
296
|
+
return [
|
|
297
|
+
...namespacedRule(kind, `${p}.serviceAccountName`, SERVICE_ACCOUNT, "runs as"),
|
|
298
|
+
...namespacedRule(kind, `${p}.volumes[].configMap.name`, CONFIG_MAP, "mounts"),
|
|
299
|
+
...namespacedRule(kind, `${p}.volumes[].secret.secretName`, SECRET, "mounts"),
|
|
300
|
+
...namespacedRule(kind, `${p}.containers[].envFrom[].configMapRef.name`, CONFIG_MAP, "env from"),
|
|
301
|
+
...namespacedRule(kind, `${p}.containers[].envFrom[].secretRef.name`, SECRET, "env from"),
|
|
302
|
+
// An env var whose value is a bucket's literal name (behold#166).
|
|
303
|
+
...[S3_BUCKET, S3_BUCKET_V2].flatMap((b) => maybe(kind, `${p}.containers[].env[].value`, b, "uses bucket")),
|
|
304
|
+
];
|
|
305
|
+
}
|
|
306
|
+
const kubernetesRules = [
|
|
307
|
+
...POD_SPECS.flatMap(([kind, p]) => podSpecRules(kind, p)),
|
|
308
|
+
// A namespaced object is in its Namespace. Optional: most namespaces are made elsewhere.
|
|
309
|
+
...NAMESPACED_KINDS.flatMap((kind) => rule(kind, "metadata.namespace", NAMESPACE, "in namespace", "containment").map((r) => ({ ...r, optional: true }))),
|
|
310
|
+
];
|
|
311
|
+
// ── identities, scopes, and the kinds that reference nothing ──
|
|
312
|
+
/** What else names a kind, beyond `outputs.id`, `outputs.arn`, `outputs.name` and `name`. */
|
|
313
|
+
const EXTRA_IDS = {
|
|
314
|
+
[S3_BUCKET]: ["bucket", "outputs.bucket"],
|
|
315
|
+
[S3_BUCKET_V2]: ["bucket", "outputs.bucket"],
|
|
316
|
+
[SQS_QUEUE]: ["outputs.url"],
|
|
317
|
+
[IAM_POLICY]: [],
|
|
318
|
+
[ROUTE53_ZONE]: ["outputs.zoneId"],
|
|
319
|
+
[LB]: ["outputs.dnsName"],
|
|
320
|
+
[GCP_NETWORK]: ["outputs.selfLink"],
|
|
321
|
+
[GCP_SUBNETWORK]: ["outputs.selfLink"],
|
|
322
|
+
[GCP_SERVICE_ACCOUNT]: ["accountId", "outputs.email"],
|
|
323
|
+
[GCP_SECRET]: ["secretId"],
|
|
324
|
+
[GCP_CLUSTER]: ["outputs.selfLink"],
|
|
325
|
+
[AZURE_NATIVE.group]: ["resourceGroupName"],
|
|
326
|
+
[AZURE_NATIVE.vnet]: ["virtualNetworkName"],
|
|
327
|
+
[AZURE_NATIVE.subnet]: ["subnetName"],
|
|
328
|
+
};
|
|
329
|
+
const AWS_NAMED = [
|
|
330
|
+
VPC, SUBNET, SECURITY_GROUP, ROUTE_TABLE, INTERNET_GATEWAY, NAT_GATEWAY, EIP, INSTANCE, NETWORK_INTERFACE, LB, TARGET_GROUP, ECS_CLUSTER, ECS_TASK,
|
|
331
|
+
IAM_ROLE, IAM_POLICY, INSTANCE_PROFILE, LAMBDA, S3_BUCKET, S3_BUCKET_V2, ROUTE53_ZONE, EKS_CLUSTER, RDS_SUBNET_GROUP, RDS_CLUSTER, SQS_QUEUE, SNS_TOPIC, KMS_KEY, LOG_GROUP,
|
|
332
|
+
"aws:secretsmanager/secret:Secret", "aws:elasticache/subnetGroup:SubnetGroup", "aws:rds/instance:Instance",
|
|
333
|
+
];
|
|
334
|
+
const GCP_NAMED = [GCP_NETWORK, GCP_SUBNETWORK, GCP_INSTANCE, GCP_CLUSTER, GCP_SERVICE_ACCOUNT, GCP_SECRET, GCP_BUCKET];
|
|
335
|
+
const AZURE_NAMED = AZURE_FAMILIES.flatMap((f) => [f.group, f.vnet, f.subnet, f.aks, f.nsg]);
|
|
336
|
+
/** Kinds whose identities are `metadata.name`, in place of the provider outputs. */
|
|
337
|
+
const K8S_NAMED = new Set(NAMED_KINDS);
|
|
338
|
+
const identities = [
|
|
339
|
+
...[...AWS_NAMED, ...GCP_NAMED, ...AZURE_NAMED].map((kind) => ({ kind, ids: ["outputs.id", "outputs.arn", "outputs.name", "name", ...(EXTRA_IDS[kind] ?? [])] })),
|
|
340
|
+
...[...K8S_NAMED].map((kind) => ({ kind, ids: ["metadata.name"] })),
|
|
341
|
+
];
|
|
342
|
+
const scopes = NAMESPACED_KINDS.map((kind) => ({ kind, path: "metadata.namespace" }));
|
|
343
|
+
/**
|
|
344
|
+
* Pulumi kinds this catalog has looked at and found to hold no input that
|
|
345
|
+
* identifies another resource. A node of one of these kinds is not an
|
|
346
|
+
* unresolved kind: nothing was looked for because there is nothing to find.
|
|
347
|
+
*/
|
|
348
|
+
export const REFERENCES_NOTHING = new Set([
|
|
349
|
+
VPC,
|
|
350
|
+
EIP,
|
|
351
|
+
S3_BUCKET,
|
|
352
|
+
S3_BUCKET_V2,
|
|
353
|
+
ECS_CLUSTER,
|
|
354
|
+
ROUTE53_ZONE,
|
|
355
|
+
KMS_KEY,
|
|
356
|
+
SQS_QUEUE,
|
|
357
|
+
SNS_TOPIC,
|
|
358
|
+
GCP_NETWORK,
|
|
359
|
+
GCP_SECRET,
|
|
360
|
+
GCP_BUCKET,
|
|
361
|
+
GCP_SERVICE_ACCOUNT,
|
|
362
|
+
AZURE_NATIVE.group,
|
|
363
|
+
AZURE_CLASSIC.group,
|
|
364
|
+
NAMESPACE,
|
|
365
|
+
CONFIG_MAP,
|
|
366
|
+
SECRET,
|
|
367
|
+
SERVICE_ACCOUNT,
|
|
368
|
+
]);
|
|
369
|
+
/** The catalog. Rules are grouped by provider; each provider lists containment before references. */
|
|
370
|
+
export const PULUMI_REFERENCE_CATALOG = {
|
|
371
|
+
identities,
|
|
372
|
+
scopes,
|
|
373
|
+
refs: [...awsRules, ...gcpRules, ...azureRules, ...kubernetesRules],
|
|
374
|
+
};
|
|
375
|
+
/** Every Pulumi kind the catalog has at least one rule from. */
|
|
376
|
+
export const CATALOGUED_KINDS = new Set(PULUMI_REFERENCE_CATALOG.refs.map((r) => r.from));
|
|
377
|
+
/**
|
|
378
|
+
* True when nothing would be looked for on a node of this kind: no rule is
|
|
379
|
+
* written for it, and it is not one of the kinds known to reference nothing.
|
|
380
|
+
*/
|
|
381
|
+
export function isUnresolvedKind(kind) {
|
|
382
|
+
return !CATALOGUED_KINDS.has(kind) && !REFERENCES_NOTHING.has(kind);
|
|
383
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a property named `key` may be copied to a node (#5332): not a
|
|
3
|
+
* Pulumi `__` key, not credential-like, and, at the top level of a Kubernetes
|
|
4
|
+
* Secret or ConfigMap, not its payload. The preview observation
|
|
5
|
+
* (`./preview-observation.ts`) asks this of every path it puts on a node.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mayCarryKey(key: string, opts?: {
|
|
8
|
+
type?: unknown;
|
|
9
|
+
topLevel?: boolean;
|
|
10
|
+
}): boolean;
|
|
11
|
+
/** Whether a string is short enough to be a name rather than a document. */
|
|
12
|
+
export declare const isNameSized: (value: string) => boolean;
|
|
13
|
+
/** The inputs and `outputs` a resource's node carries, as the node's props. */
|
|
14
|
+
export declare function referenceProps(resource: {
|
|
15
|
+
type?: unknown;
|
|
16
|
+
id?: unknown;
|
|
17
|
+
inputs?: unknown;
|
|
18
|
+
outputs?: unknown;
|
|
19
|
+
}): Record<string, unknown>;
|