@intentius/chant-lexicon-aws 0.124.52 → 0.124.55
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/api/credential-chain.d.ts +3 -3
- package/dist/api/credential-chain.d.ts.map +1 -1
- package/dist/api/credential-chain.js +2 -2
- package/dist/api/read-client.d.ts +2 -2
- package/dist/api/read-client.d.ts.map +1 -1
- package/dist/api/read-client.js +2 -2
- package/dist/api/{sigv4.d.ts → signing.d.ts} +14 -34
- package/dist/api/signing.d.ts.map +1 -0
- package/dist/api/signing.js +95 -0
- package/dist/codegen/generate-lexicon.d.ts +2 -0
- package/dist/codegen/generate-lexicon.d.ts.map +1 -1
- package/dist/codegen/generate-lexicon.js +1 -0
- package/dist/components/__tests__/mock-cloud-executor.d.ts +4 -0
- package/dist/components/__tests__/mock-cloud-executor.d.ts.map +1 -1
- package/dist/components/__tests__/mock-cloud-executor.js +18 -1
- package/dist/components/apply.d.ts +46 -2
- package/dist/components/apply.d.ts.map +1 -1
- package/dist/components/apply.js +266 -30
- package/dist/components/cfn-adopt-run.d.ts +37 -0
- package/dist/components/cfn-adopt-run.d.ts.map +1 -0
- package/dist/components/cfn-adopt-run.js +104 -0
- package/dist/components/cfn-adopt.d.ts +99 -0
- package/dist/components/cfn-adopt.d.ts.map +1 -0
- package/dist/components/cfn-adopt.js +278 -0
- package/dist/components/cfn-imports.d.ts +84 -0
- package/dist/components/cfn-imports.d.ts.map +1 -0
- package/dist/components/cfn-imports.js +239 -0
- package/dist/components/cloud-executor.d.ts +38 -2
- package/dist/components/cloud-executor.d.ts.map +1 -1
- package/dist/components/cloud-executor.js +84 -2
- package/dist/health.js +1 -1
- package/dist/importable.d.ts +30 -0
- package/dist/importable.d.ts.map +1 -0
- package/dist/importable.js +72 -0
- package/dist/index-identity.d.ts +19 -0
- package/dist/index-identity.d.ts.map +1 -0
- package/dist/index-identity.js +79 -0
- package/dist/index-import.d.ts +25 -0
- package/dist/index-import.d.ts.map +1 -0
- package/dist/index-import.js +132 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/integrity.json +4 -4
- package/dist/listed-types.d.ts +11 -0
- package/dist/listed-types.d.ts.map +1 -0
- package/dist/listed-types.js +52 -0
- package/dist/manifest.json +1 -1
- package/dist/meta.json +13206 -1237
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +12 -3
- package/dist/reference-catalog.d.ts.map +1 -1
- package/dist/reference-catalog.js +62 -20
- package/dist/skills/chant-aws-carve-terraform.md +21 -14
- package/dist/spec/fetch.d.ts +5 -0
- package/dist/spec/fetch.d.ts.map +1 -1
- package/dist/spec/parse.d.ts +8 -0
- package/dist/spec/parse.d.ts.map +1 -1
- package/dist/spec/parse.js +3 -0
- package/package.json +2 -2
- package/src/api/credential-chain.ts +3 -3
- package/src/api/read-client.test.ts +2 -2
- package/src/api/read-client.ts +3 -3
- package/src/api/{sigv4.test.ts → signing.test.ts} +84 -96
- package/src/api/signing.ts +130 -0
- package/src/codegen/generate-lexicon.ts +3 -0
- package/src/components/__tests__/mock-cloud-executor.ts +20 -1
- package/src/components/apply.ts +288 -30
- package/src/components/cfn-adopt-run.test.ts +227 -0
- package/src/components/cfn-adopt-run.ts +141 -0
- package/src/components/cfn-adopt.test.ts +284 -0
- package/src/components/cfn-adopt.ts +340 -0
- package/src/components/cfn-exports-in-use.test.ts +146 -0
- package/src/components/cfn-imports-preview.test.ts +178 -0
- package/src/components/cfn-imports-three-stacks.test.ts +107 -0
- package/src/components/cfn-imports.test.ts +213 -0
- package/src/components/cfn-imports.ts +246 -0
- package/src/components/cfn-plan-shape-conformance.test.ts +83 -0
- package/src/components/cloud-executor.ts +127 -5
- package/src/components/demo-composed-stacks-floci.e2e.test.ts +235 -0
- package/src/derived-edges.test.ts +142 -0
- package/src/generated/lexicon-aws.json +13206 -1237
- package/src/health.ts +1 -1
- package/src/importable.test.ts +86 -0
- package/src/importable.ts +83 -0
- package/src/index-identity.test.ts +134 -0
- package/src/index-identity.ts +98 -0
- package/src/index-import.test.ts +257 -0
- package/src/index-import.ts +158 -0
- package/src/index-search.test.ts +87 -0
- package/src/index.ts +1 -1
- package/src/listed-types.test.ts +97 -0
- package/src/listed-types.ts +56 -0
- package/src/plugin.ts +13 -3
- package/src/reference-catalog.ts +63 -20
- package/src/skills/chant-aws-carve-terraform.md +21 -14
- package/src/spec/fetch.ts +5 -0
- package/src/spec/parse.test.ts +15 -0
- package/src/spec/parse.ts +12 -0
- package/src/testdata/indexed/identity.listing.json +65 -0
- package/src/testdata/indexed/import.listing.json +126 -0
- package/src/testdata/indexed/listing.json +69 -0
- package/src/testdata/indexed/topology.listing.json +350 -0
- package/src/testdata/three-cloud/dns.graph.json +336 -0
- package/src/three-cloud-parity.test.ts +49 -0
- package/dist/api/sigv4.d.ts.map +0 -1
- package/dist/api/sigv4.js +0 -185
- package/src/api/sigv4.ts +0 -243
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS request signing for the shared read transport (#1686), through core's
|
|
3
|
+
* one SigV4 signer (`@intentius/chant/cloud-lister/sigv4`, #4583).
|
|
4
|
+
*
|
|
5
|
+
* This lexicon kept its own SigV4 implementation until #4583; it now holds
|
|
6
|
+
* only the lexicon's signing surface (`signRequest`, `resolveCredentials` and
|
|
7
|
+
* the credential types cedar's AVP client restates) and the header set it
|
|
8
|
+
* signs. Core does the canonicalization and the HMACs.
|
|
9
|
+
*
|
|
10
|
+
* ## What is signed, and what is not
|
|
11
|
+
*
|
|
12
|
+
* Header signing only. `host` is signed but never emitted: `fetch` computes
|
|
13
|
+
* `Host` from the URL and forbids overriding it, so the signer derives the
|
|
14
|
+
* same value from the URL it was given. A transport that rewrites the URL
|
|
15
|
+
* underneath the signer (a proxy that keeps the original `Host`, say) would
|
|
16
|
+
* invalidate the signature; the injectable-HTTP seam is for tests and
|
|
17
|
+
* emulators, not for URL rewriting.
|
|
18
|
+
*
|
|
19
|
+
* `x-amz-content-sha256` is always sent and signed. The headers in
|
|
20
|
+
* {@link UNSIGNED_HEADERS} are sent when a caller sets them but never signed.
|
|
21
|
+
*
|
|
22
|
+
* The canonical path is the URL's pathname as it stands (core's rule, which is
|
|
23
|
+
* S3's). Every caller here POSTs to `/` or reads a Route 53 path of plain
|
|
24
|
+
* segments, where that agrees with the twice-encoded form other services
|
|
25
|
+
* define; a caller with a path that needs encoding is the moment to revisit it.
|
|
26
|
+
*/
|
|
27
|
+
import { signV4 } from "@intentius/chant/cloud-lister/sigv4";
|
|
28
|
+
|
|
29
|
+
/** SHA-256 of the empty string, the payload hash of every bodyless request. */
|
|
30
|
+
export const EMPTY_PAYLOAD_SHA256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Headers that are never signed even when a caller sets them: `authorization`
|
|
34
|
+
* is the output, and the others are rewritten in transit by proxies and agents,
|
|
35
|
+
* so signing them produces intermittent 403s rather than security.
|
|
36
|
+
*/
|
|
37
|
+
export const UNSIGNED_HEADERS: readonly string[] = ["authorization", "connection", "expect", "user-agent", "x-amzn-trace-id"];
|
|
38
|
+
|
|
39
|
+
/** A resolved credential set. `sessionToken` is present for STS/role credentials. */
|
|
40
|
+
export interface AwsCredentials {
|
|
41
|
+
accessKeyId: string;
|
|
42
|
+
secretAccessKey: string;
|
|
43
|
+
sessionToken?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The credential injection seam: a function the caller supplies to decide, by
|
|
48
|
+
* whatever means it likes, what to sign with. Returning `undefined` means "this
|
|
49
|
+
* process has no credentials" and is respected as an answer, not overridden.
|
|
50
|
+
*/
|
|
51
|
+
export type AwsCredentialResolver = () => AwsCredentials | undefined;
|
|
52
|
+
|
|
53
|
+
/** Either literal credentials or a resolver for them. */
|
|
54
|
+
export type AwsCredentialSource = AwsCredentials | AwsCredentialResolver;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Credentials for a request: explicit, then environment, then absent.
|
|
58
|
+
*
|
|
59
|
+
* A resolver function is authoritative: if one is injected and it declines,
|
|
60
|
+
* the environment is not consulted behind its back, because the point of
|
|
61
|
+
* injecting one is to control the answer. Literal credentials are likewise
|
|
62
|
+
* final. Only the no-source case falls through to `AWS_ACCESS_KEY_ID` /
|
|
63
|
+
* `AWS_SECRET_ACCESS_KEY` (plus `AWS_SESSION_TOKEN` when set), and a half-set
|
|
64
|
+
* environment (a key id with no secret) is absent rather than a signature
|
|
65
|
+
* that cannot verify.
|
|
66
|
+
*
|
|
67
|
+
* The shared profile files are resolved asynchronously by
|
|
68
|
+
* `./credential-chain.ts`, and the read transport passes its answer in as
|
|
69
|
+
* literal credentials (#3958), so this function stays synchronous. Not
|
|
70
|
+
* implemented anywhere: IMDS and the container credential endpoints.
|
|
71
|
+
*/
|
|
72
|
+
export function resolveCredentials(
|
|
73
|
+
source?: AwsCredentialSource,
|
|
74
|
+
env: Record<string, string | undefined> = process.env,
|
|
75
|
+
): AwsCredentials | undefined {
|
|
76
|
+
if (typeof source === "function") return source();
|
|
77
|
+
if (source) return source;
|
|
78
|
+
const accessKeyId = env.AWS_ACCESS_KEY_ID;
|
|
79
|
+
const secretAccessKey = env.AWS_SECRET_ACCESS_KEY;
|
|
80
|
+
if (!accessKeyId || !secretAccessKey) return undefined;
|
|
81
|
+
return {
|
|
82
|
+
accessKeyId,
|
|
83
|
+
secretAccessKey,
|
|
84
|
+
...(env.AWS_SESSION_TOKEN ? { sessionToken: env.AWS_SESSION_TOKEN } : {}),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** One request to sign. `headers` are the caller's; the signer adds its own. */
|
|
89
|
+
export interface SigV4Request {
|
|
90
|
+
method: string;
|
|
91
|
+
/** Absolute URL. Its host is signed and its path/query are canonicalized. */
|
|
92
|
+
url: string;
|
|
93
|
+
headers: Record<string, string>;
|
|
94
|
+
body: string;
|
|
95
|
+
/** Service name as it appears in the credential scope (`cloudformation`, `cloudcontrolapi`, ...). */
|
|
96
|
+
service: string;
|
|
97
|
+
region: string;
|
|
98
|
+
credentials: AwsCredentials;
|
|
99
|
+
/** Signing clock. Injected by tests; otherwise now. */
|
|
100
|
+
now?: Date;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The headers core's signer adds, the ones {@link signRequest} returns beside the caller's own. */
|
|
104
|
+
const ADDED = ["x-amz-date", "x-amz-content-sha256", "x-amz-security-token", "authorization"] as const;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The caller's headers, as given, plus everything SigV4 adds: `x-amz-date`,
|
|
108
|
+
* `x-amz-content-sha256`, `x-amz-security-token` when the credentials are
|
|
109
|
+
* temporary, and the `Authorization` header itself.
|
|
110
|
+
*
|
|
111
|
+
* `host` is signed (AWS requires it) but not returned; see the module header.
|
|
112
|
+
*/
|
|
113
|
+
export function signRequest(request: SigV4Request): Record<string, string> {
|
|
114
|
+
const signed = signV4({
|
|
115
|
+
method: request.method,
|
|
116
|
+
url: request.url,
|
|
117
|
+
headers: request.headers,
|
|
118
|
+
body: request.body,
|
|
119
|
+
region: request.region,
|
|
120
|
+
service: request.service,
|
|
121
|
+
credentials: request.credentials,
|
|
122
|
+
now: request.now ?? new Date(),
|
|
123
|
+
contentSha256: true,
|
|
124
|
+
omitHost: true,
|
|
125
|
+
unsignedHeaders: UNSIGNED_HEADERS,
|
|
126
|
+
});
|
|
127
|
+
const out: Record<string, string> = { ...request.headers };
|
|
128
|
+
for (const name of ADDED) if (signed[name] !== undefined) out[name] = signed[name];
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
@@ -34,6 +34,8 @@ export interface LexiconEntry {
|
|
|
34
34
|
conditionalCreateOnly?: string[];
|
|
35
35
|
replacementStrategy?: "delete_then_create" | "create_then_delete";
|
|
36
36
|
tagging?: ResourceTagging;
|
|
37
|
+
/** The registry schema's handler operations, sorted (#4536). Absent for a legacy type. */
|
|
38
|
+
handlers?: string[];
|
|
37
39
|
runtimeDeprecations?: Record<string, string>;
|
|
38
40
|
}
|
|
39
41
|
|
|
@@ -81,6 +83,7 @@ export function generateLexiconJSON(
|
|
|
81
83
|
...(r.resource.conditionalCreateOnly?.length && { conditionalCreateOnly: r.resource.conditionalCreateOnly }),
|
|
82
84
|
...(r.resource.replacementStrategy && { replacementStrategy: r.resource.replacementStrategy }),
|
|
83
85
|
...(r.resource.tagging && { tagging: r.resource.tagging }),
|
|
86
|
+
...(r.resource.handlers?.length && { handlers: r.resource.handlers }),
|
|
84
87
|
...(runtimeDepr && { runtimeDeprecations: runtimeDepr }),
|
|
85
88
|
};
|
|
86
89
|
},
|
|
@@ -82,6 +82,10 @@ export interface FakeStackConfig {
|
|
|
82
82
|
missing?: boolean;
|
|
83
83
|
/** Set by the mock: the empty `REVIEW_IN_PROGRESS` stack a CREATE change set made for a missing stack. */
|
|
84
84
|
shell?: boolean;
|
|
85
|
+
/** The stack's exports (#4466c), export name to the output it is; the value is the output's. */
|
|
86
|
+
exports?: Record<string, string>;
|
|
87
|
+
/** The stacks that import each of this stack's exports now, by export name (#4466c). */
|
|
88
|
+
importedBy?: Record<string, string[]>;
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
export interface FakeDeploymentConfig {
|
|
@@ -171,7 +175,10 @@ export function createMockCloudExecutor(options: MockCloudExecutorOptions = {}):
|
|
|
171
175
|
|
|
172
176
|
function stackStatus(name: string): CfnStackStatus {
|
|
173
177
|
const config = stacks.get(name);
|
|
174
|
-
|
|
178
|
+
const exports = config?.exports
|
|
179
|
+
? Object.fromEntries(Object.entries(config.exports).map(([exportName, output]) => [exportName, { output, value: config.outputs?.[output] ?? "" }]))
|
|
180
|
+
: undefined;
|
|
181
|
+
return { stackStatus: config?.terminalStatus ?? "UPDATE_COMPLETE", outputs: config?.outputs ?? {}, ...(exports ? { exports } : {}) };
|
|
175
182
|
}
|
|
176
183
|
|
|
177
184
|
const docker: CloudExecutor["docker"] = {
|
|
@@ -260,6 +267,18 @@ export function createMockCloudExecutor(options: MockCloudExecutorOptions = {}):
|
|
|
260
267
|
stacks.set(stackName, { ...config, shell: false, missing: true });
|
|
261
268
|
return true;
|
|
262
269
|
},
|
|
270
|
+
// Only a mock some stack's `importedBy` was given has ListImports, so the
|
|
271
|
+
// plans of every other test make the calls they always made (#4466c).
|
|
272
|
+
...(Object.values(options.stacks ?? {}).some((c) => c.importedBy !== undefined)
|
|
273
|
+
? {
|
|
274
|
+
async listImports(exportName: string) {
|
|
275
|
+
record("cloudformation", "listImports", exportName);
|
|
276
|
+
const out = new Set<string>();
|
|
277
|
+
for (const config of stacks.values()) for (const s of config.importedBy?.[exportName] ?? []) out.add(s);
|
|
278
|
+
return [...out].sort();
|
|
279
|
+
},
|
|
280
|
+
}
|
|
281
|
+
: {}),
|
|
263
282
|
async waitForStack(stackName: string) {
|
|
264
283
|
record("cloudformation", "waitForStack", stackName);
|
|
265
284
|
return stackStatus(stackName);
|