@intentius/chant-lexicon-aws 0.33.0 → 0.34.0
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/ambient.d.ts +39 -0
- package/dist/ambient.d.ts.map +1 -0
- package/dist/deep-observe.d.ts +5 -0
- package/dist/deep-observe.d.ts.map +1 -1
- package/dist/defaults.d.ts +44 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/dependencies.d.ts +60 -0
- package/dist/dependencies.d.ts.map +1 -0
- package/dist/generated/index.d.ts +61 -136
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/integrity.json +4 -4
- package/dist/manifest.json +1 -1
- package/dist/meta.json +577 -2759
- package/dist/plugin.d.ts.map +1 -1
- package/dist/properties.d.ts +48 -0
- package/dist/properties.d.ts.map +1 -0
- package/dist/reference-catalog.d.ts.map +1 -1
- package/dist/types/index.d.ts +1206 -2296
- package/package.json +2 -2
- package/src/ambient.test.ts +71 -0
- package/src/ambient.ts +147 -0
- package/src/deep-observe.ts +9 -0
- package/src/defaults.test.ts +73 -0
- package/src/defaults.ts +97 -0
- package/src/dependencies.test.ts +208 -0
- package/src/dependencies.ts +323 -0
- package/src/generated/index.d.ts +1206 -2296
- package/src/generated/index.ts +62 -137
- package/src/generated/lexicon-aws.json +577 -2759
- package/src/plugin.ts +65 -64
- package/src/properties.test.ts +113 -0
- package/src/properties.ts +166 -0
- package/src/reference-catalog.ts +24 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resources that are simply *there* (#1278).
|
|
3
|
+
*
|
|
4
|
+
* `describeResources` answers "what do I manage" and `observeDependencies`
|
|
5
|
+
* answers "what do I rely on". Both resolve outward from the declared estate,
|
|
6
|
+
* so neither can see a resource nothing points at — and "which of my security
|
|
7
|
+
* groups are unused" is precisely a question about resources nothing points at.
|
|
8
|
+
*
|
|
9
|
+
* A state file cannot answer this at all: it knows what it created, and an
|
|
10
|
+
* unused resource is by definition not something it created and attached. A
|
|
11
|
+
* lexicon that can enumerate a kind can.
|
|
12
|
+
*
|
|
13
|
+
* Bounded by the kinds the project declares. A project managing security groups
|
|
14
|
+
* is asked about security groups, not about the account.
|
|
15
|
+
*/
|
|
16
|
+
import type { ResourceMetadata } from "@intentius/chant/lexicon";
|
|
17
|
+
/** The requested kinds, plus the ones they imply. */
|
|
18
|
+
export declare function withImplied(kinds: string[]): string[];
|
|
19
|
+
/** The kinds this reader can enumerate. Declared so a caller can mention
|
|
20
|
+
* `--ambient` without paying for a scan to discover it is relevant. */
|
|
21
|
+
export declare const AMBIENT_KINDS: string[];
|
|
22
|
+
/** True when this lexicon can enumerate the kind, so a caller can say what it skipped. */
|
|
23
|
+
export declare function canEnumerate(kind: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* List resources of the declared kinds that exist in the account but are
|
|
26
|
+
* neither managed nor already observed.
|
|
27
|
+
*
|
|
28
|
+
* Attachment is deliberately NOT decided here. Whether a security group is
|
|
29
|
+
* "unused" is a graph question — does anything reference it — and the graph
|
|
30
|
+
* answers it once the group is a node. Deciding it in the reader would put a
|
|
31
|
+
* conclusion in the observation, which is the mistake `liveInternetFacing` made
|
|
32
|
+
* and #1271 undid.
|
|
33
|
+
*/
|
|
34
|
+
export declare function observeAwsAmbient(options: {
|
|
35
|
+
kinds: string[];
|
|
36
|
+
observed: Record<string, ResourceMetadata>;
|
|
37
|
+
region?: string;
|
|
38
|
+
}): Promise<Record<string, ResourceMetadata>>;
|
|
39
|
+
//# sourceMappingURL=ambient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ambient.d.ts","sourceRoot":"","sources":["../src/ambient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAkDjE,qDAAqD;AACrD,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAErD;AAED;uEACuE;AACvE,eAAO,MAAM,aAAa,EAAE,MAAM,EAA4B,CAAC;AAE/D,0FAA0F;AAC1F,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE;IAC/C,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAmD5C"}
|
package/dist/deep-observe.d.ts
CHANGED
|
@@ -85,6 +85,11 @@ export interface AwsDeepObserveOptions {
|
|
|
85
85
|
props: Record<string, unknown>;
|
|
86
86
|
}>;
|
|
87
87
|
stack?: string;
|
|
88
|
+
/** Region this stack is deployed in (#1267). Same reason the thin path takes
|
|
89
|
+
* one (#1261): without it a multi-region estate reads every stack against the
|
|
90
|
+
* ambient region, the out-of-region ones come back empty, and a deep snapshot
|
|
91
|
+
* silently records no properties for them. */
|
|
92
|
+
region?: string;
|
|
88
93
|
owned?: boolean;
|
|
89
94
|
}
|
|
90
95
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-observe.d.ts","sourceRoot":"","sources":["../src/deep-observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAGV,sBAAsB,EACtB,qBAAqB,EAItB,MAAM,0BAA0B,CAAC;AAKlC;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAKlD,CAAC;AAEH;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAkBlD,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,E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O,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAkBlD,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgBxE,CAAC;AAkBF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,EAAE,sBAmDvC,CAAC;AAMF,uFAAuF;AACvF,MAAM,WAAW,oBAAoB;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CAuBrF;AASD,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAI/E;AAED,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CAAC;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;kDAG8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,qBAAqB,CAAC,CA4HhC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which resources the provider created, rather than anyone's infrastructure code.
|
|
3
|
+
*
|
|
4
|
+
* Every account arrives with resources nobody wrote: a default VPC and its
|
|
5
|
+
* subnets, a default security group per VPC, a main route table, AWS-managed
|
|
6
|
+
* KMS keys and IAM policies. They are yours to account for and were never
|
|
7
|
+
* yours to declare, and until now chant recorded them looking exactly like
|
|
8
|
+
* everything else.
|
|
9
|
+
*
|
|
10
|
+
* That matters wherever a question is about what you built. Asked which
|
|
11
|
+
* security groups were unused, agents split three ways on the same correct set
|
|
12
|
+
* of four — one excluded the three VPC defaults as "not real cleanup
|
|
13
|
+
* candidates" and answered one, another counted something extra and answered
|
|
14
|
+
* five. The answers that were accepted all did the same thing: listed all four
|
|
15
|
+
* and said which were defaults. They could only do that by recognising them,
|
|
16
|
+
* and chant gave them nothing to recognise them by.
|
|
17
|
+
*
|
|
18
|
+
* This records a fact and stops. `providerDefault: true` says the provider
|
|
19
|
+
* created this; it does not say the resource is unused, safe to ignore, or
|
|
20
|
+
* exempt from anything. Deciding that here would put a conclusion in an
|
|
21
|
+
* observation — the mistake `liveInternetFacing` made and #1271 undid — and it
|
|
22
|
+
* would be wrong in this very case, since the accepted answers count defaults
|
|
23
|
+
* as unused.
|
|
24
|
+
*
|
|
25
|
+
* Almost none of this is chant's judgement. AWS marks these itself, on the same
|
|
26
|
+
* payloads chant already reads; the fields were simply being dropped. The one
|
|
27
|
+
* derivation is the security group, and it is safe because `default` is a
|
|
28
|
+
* reserved group name — AWS rejects it on create, so a group called `default`
|
|
29
|
+
* is that VPC's default group.
|
|
30
|
+
*/
|
|
31
|
+
import type { ResourceMetadata } from "@intentius/chant/lexicon";
|
|
32
|
+
/** True when this lexicon can tell whether the kind is a provider default. */
|
|
33
|
+
export declare function canDetectDefault(kind: string): boolean;
|
|
34
|
+
/** The kinds whose provider-default status this lexicon can report. */
|
|
35
|
+
export declare const DEFAULT_AWARE_KINDS: string[];
|
|
36
|
+
/**
|
|
37
|
+
* Mark the resources the provider created.
|
|
38
|
+
*
|
|
39
|
+
* Only ever sets the attribute to `true`, and only for kinds with a known
|
|
40
|
+
* marker: absent means "not a default, or chant cannot tell", and those are
|
|
41
|
+
* genuinely different from each other in a way a blanket `false` would hide.
|
|
42
|
+
*/
|
|
43
|
+
export declare function stampProviderDefaults(resources: Record<string, ResourceMetadata>): Record<string, ResourceMetadata>;
|
|
44
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AA8BjE,8EAA8E;AAC9E,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD;AAED,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,EAAE,MAAM,EAAkC,CAAC;AAE3E;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAC1C,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAkBlC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an AWS estate depends on but does not declare (#1273).
|
|
3
|
+
*
|
|
4
|
+
* `describeResources` is scoped to the stack. An instance placed in the
|
|
5
|
+
* account's default VPC routes through a route table nobody declared, so that
|
|
6
|
+
* table is never observed, never a node, and no fold can traverse to it. The
|
|
7
|
+
* answer used to be computed inside the lexicon and injected as an attribute —
|
|
8
|
+
* which is a conclusion no snapshot can record enough to recompute.
|
|
9
|
+
*
|
|
10
|
+
* This reports the resources instead, so the one graph fold derives the answer.
|
|
11
|
+
*
|
|
12
|
+
* The closure is bounded: start from the observed instances, follow the
|
|
13
|
+
* reference chain the catalog declares as meaningful — subnet, then route
|
|
14
|
+
* table, then gateway — and stop. Anything not reached from a declared resource
|
|
15
|
+
* along a declared reference is not a dependency, it is just the account.
|
|
16
|
+
*/
|
|
17
|
+
import type { DependencyObservation, ResourceMetadata } from "@intentius/chant/lexicon";
|
|
18
|
+
/** One ingress permission as `describe-security-groups` returns it. */
|
|
19
|
+
interface RawIpPermission {
|
|
20
|
+
IpProtocol?: string;
|
|
21
|
+
FromPort?: number;
|
|
22
|
+
ToPort?: number;
|
|
23
|
+
IpRanges?: Array<{
|
|
24
|
+
CidrIp?: string;
|
|
25
|
+
}>;
|
|
26
|
+
Ipv6Ranges?: Array<{
|
|
27
|
+
CidrIpv6?: string;
|
|
28
|
+
}>;
|
|
29
|
+
UserIdGroupPairs?: Array<{
|
|
30
|
+
GroupId?: string;
|
|
31
|
+
}>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Flatten `IpPermissions` into the CloudFormation-shaped rules the fold reads.
|
|
35
|
+
*
|
|
36
|
+
* The two AWS surfaces disagree about the same concept: a template's
|
|
37
|
+
* `SecurityGroupIngress` carries `CidrIp` flat on the rule, while
|
|
38
|
+
* `describe-security-groups` nests sources under `IpRanges[]`, `Ipv6Ranges[]`
|
|
39
|
+
* and `UserIdGroupPairs[]`, and one permission can hold several. Handing the
|
|
40
|
+
* describe shape to the fold unchanged yields a rule with no recognisable
|
|
41
|
+
* source, which `normalizeIngress` renders as `?` — an ingress rule that
|
|
42
|
+
* matches no CIDR query and quietly narrows the answer.
|
|
43
|
+
*
|
|
44
|
+
* One rule per source, because that is what the flat shape means.
|
|
45
|
+
*/
|
|
46
|
+
export declare function toIngressRules(permissions: RawIpPermission[]): Array<Record<string, unknown>>;
|
|
47
|
+
/**
|
|
48
|
+
* Read the routing an observed estate depends on.
|
|
49
|
+
*
|
|
50
|
+
* Only the tables that actually serve an observed instance are reported: one
|
|
51
|
+
* reached by an explicit subnet association, or the VPC's main table standing in
|
|
52
|
+
* for a subnet with none. A route table serving nothing chant deployed is not a
|
|
53
|
+
* dependency of this estate.
|
|
54
|
+
*/
|
|
55
|
+
export declare function observeAwsDependencies(options: {
|
|
56
|
+
observed: Record<string, ResourceMetadata>;
|
|
57
|
+
region?: string;
|
|
58
|
+
}): Promise<DependencyObservation>;
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAU,MAAM,0BAA0B,CAAC;AAKhG,uEAAuE;AACvE,UAAU,eAAe;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,KAAK,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC1C,gBAAgB,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAChD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,eAAe,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAmB7F;AASD;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE;IACpD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CA6OjC"}
|