@intentius/chant-lexicon-aws 0.124.54 → 0.124.56
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/components/apply.d.ts +2 -0
- package/dist/components/apply.d.ts.map +1 -1
- package/dist/components/apply.js +6 -1
- 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/cloud-executor.d.ts +7 -0
- package/dist/components/cloud-executor.d.ts.map +1 -1
- package/dist/components/cloud-executor.js +20 -0
- package/dist/health.js +1 -1
- package/dist/index-import.d.ts +8 -0
- package/dist/index-import.d.ts.map +1 -1
- package/dist/index-import.js +20 -3
- 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 +3 -3
- package/dist/manifest.json +1 -1
- package/dist/plugin.js +3 -3
- package/dist/skills/chant-aws-carve-terraform.md +21 -14
- 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/components/apply.ts +6 -1
- package/src/components/cfn-adopt-run.test.ts +227 -0
- package/src/components/cfn-adopt-run.ts +141 -0
- package/src/components/cloud-executor.ts +25 -0
- package/src/health.ts +1 -1
- package/src/index-import.test.ts +16 -1
- package/src/index-import.ts +20 -2
- package/src/index.ts +1 -1
- package/src/plugin.ts +3 -3
- package/src/skills/chant-aws-carve-terraform.md +21 -14
- package/dist/api/sigv4.d.ts.map +0 -1
- package/dist/api/sigv4.js +0 -185
- package/src/api/sigv4.ts +0 -243
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-import.d.ts","sourceRoot":"","sources":["../src/index-import.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"index-import.d.ts","sourceRoot":"","sources":["../src/index-import.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAMrG,gEAAgE;AAChE,MAAM,WAAW,mBAAmB;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAgBD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAqB,GAAG,OAAO,CAEjI;AAyBD,qFAAqF;AACrF,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,QAAQ,GAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAqB,GACrE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUzB;AAQD,wDAAwD;AACxD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,iBAAiB,EACzB,QAAQ,GAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAqB,GACrE,OAAO,GAAG,SAAS,CAUrB;AAED,kGAAkG;AAClG,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAA+D,CAAC;AAEzI,wBAAgB,oBAAoB,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,kBAAkB,CA0B5G;AAED,eAAO,MAAM,cAAc,EAAE,kBAA2C,CAAC"}
|
package/dist/index-import.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import { createRequire } from "module";
|
|
23
23
|
import { moduleSourceUrl } from "@intentius/chant/module-source";
|
|
24
|
+
import { awsKindForListedType } from "./listed-types.js";
|
|
24
25
|
const require = createRequire(moduleSourceUrl(import.meta.url));
|
|
25
26
|
let cachedManifest;
|
|
26
27
|
/** The generated registry keyed by type, or an empty map in a checkout that has not generated. */
|
|
@@ -36,7 +37,23 @@ function defaultManifest() {
|
|
|
36
37
|
}
|
|
37
38
|
return cachedManifest;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
/**
|
|
41
|
+
* Whether `type` is a resource type this lexicon can write: the listed-type
|
|
42
|
+
* rule (./listed-types.ts) against the registry's kinds. The organization
|
|
43
|
+
* segment is not pinned to `AWS`, so `Alexa::ASK::Skill` imports. With no
|
|
44
|
+
* registry (a checkout that has not generated) every well-formed
|
|
45
|
+
* CloudFormation type does, as the listed-type mapping assumes.
|
|
46
|
+
*/
|
|
47
|
+
export function isImportableAwsType(type, manifest = defaultManifest()) {
|
|
48
|
+
return awsKindForListedType(type, manifest.size > 0 ? manifestKinds(manifest) : null) !== undefined;
|
|
49
|
+
}
|
|
50
|
+
const kindSets = new WeakMap();
|
|
51
|
+
function manifestKinds(manifest) {
|
|
52
|
+
let kinds = kindSets.get(manifest);
|
|
53
|
+
if (!kinds)
|
|
54
|
+
kindSets.set(manifest, (kinds = new Set(manifest.keys())));
|
|
55
|
+
return kinds;
|
|
56
|
+
}
|
|
40
57
|
function isRecord(v) {
|
|
41
58
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
42
59
|
}
|
|
@@ -88,8 +105,8 @@ export function createAwsIndexImport(manifest) {
|
|
|
88
105
|
const m = () => manifest ?? defaultManifest();
|
|
89
106
|
return {
|
|
90
107
|
resource(node) {
|
|
91
|
-
if (!
|
|
92
|
-
return { unsupported: `${node.kind} is not a CloudFormation resource type` };
|
|
108
|
+
if (!isImportableAwsType(node.kind, m()))
|
|
109
|
+
return { unsupported: `${node.kind} is not a CloudFormation resource type the aws lexicon generates` };
|
|
93
110
|
// Retain on every imported resource until a person changes it in source
|
|
94
111
|
// (#4536, ruled on choudoufu#2284 Q4): CloudFormation deletes at stack
|
|
95
112
|
// level and reads no per-resource marker, so an adopted object is never
|
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export type { LexiconOutput } from "@intentius/chant/lexicon-output";
|
|
|
24
24
|
export { awsPlugin } from "./plugin.js";
|
|
25
25
|
export { observeResourcesDeepAws, awsDeepNormalizationHooks, hasOwnershipMarker, DEEP_READABLE_TYPES, AWS_READ_ONLY_NAMES, AWS_SERVICE_DEFAULTS, } from "./deep-observe.js";
|
|
26
26
|
export { describeStackResources, describeStackOutputs, describeStackDetail, getResource, listResources, parseResourceDescription, resolveEndpointOverride, serviceEndpointEnvVar, AwsReadError, type AwsReadHttp, type AwsReadClientOptions, type CloudControlDescription, type StackResource, type StackDetail, type AwsCredentials, type AwsCredentialResolver, type AwsCredentialSource, } from "./api/read-client.js";
|
|
27
|
-
export { signRequest, resolveCredentials, EMPTY_PAYLOAD_SHA256, type SigV4Request, } from "./api/
|
|
27
|
+
export { signRequest, resolveCredentials, EMPTY_PAYLOAD_SHA256, type SigV4Request, } from "./api/signing.js";
|
|
28
28
|
export { Sub, Ref, GetAtt, If, Join, Select, Split, Base64, GetAZs, Equals, And, Or, Not, SubIntrinsic, RefIntrinsic, GetAttIntrinsic, IfIntrinsic, JoinIntrinsic, SelectIntrinsic, SplitIntrinsic, Base64Intrinsic, GetAZsIntrinsic, EqualsIntrinsic, AndIntrinsic, OrIntrinsic, NotIntrinsic, FindInMap, FindInMapIntrinsic, ImportValue, ImportValueIntrinsic, Cidr, CidrIntrinsic, } from "./intrinsics.js";
|
|
29
29
|
export type { ConditionOperand } from "./intrinsics.js";
|
|
30
30
|
export { AWS, StackName, Region, AccountId, StackId, URLSuffix, NoValue, NotificationARNs, Partition, } from "./pseudo.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE5E,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGpE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACjF,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACzG,YAAY,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACxH,YAAY,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAK3D,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,8BAA8B,EAC9B,4BAA4B,EAC5B,mBAAmB,EACnB,6BAA6B,GAC9B,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,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CAAC;AAKvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAIrE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAChI,YAAY,EACV,mBAAmB,EACnB,sBAAsB,EACtB,QAAQ,EACR,SAAS,EACT,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ export { describeStackResources, describeStackOutputs, describeStackDetail, getR
|
|
|
42
42
|
// SigV4 (#1686). Exported as its own surface because it is deliberately not
|
|
43
43
|
// specific to this transport: cedar's AVP client is the next caller, and the
|
|
44
44
|
// point of the module is that there is one signer rather than one per lexicon.
|
|
45
|
-
export { signRequest, resolveCredentials, EMPTY_PAYLOAD_SHA256, } from "./api/
|
|
45
|
+
export { signRequest, resolveCredentials, EMPTY_PAYLOAD_SHA256, } from "./api/signing.js";
|
|
46
46
|
// Intrinsics
|
|
47
47
|
export { Sub, Ref, GetAtt, If, Join, Select, Split, Base64, GetAZs, Equals, And, Or, Not, SubIntrinsic, RefIntrinsic, GetAttIntrinsic, IfIntrinsic, JoinIntrinsic, SelectIntrinsic, SplitIntrinsic, Base64Intrinsic, GetAZsIntrinsic, EqualsIntrinsic, AndIntrinsic, OrIntrinsic, NotIntrinsic, FindInMap, FindInMapIntrinsic, ImportValue, ImportValueIntrinsic, Cidr, CidrIntrinsic, } from "./intrinsics.js";
|
|
48
48
|
// Pseudo-parameters
|
package/dist/integrity.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"algorithm": "sha256",
|
|
3
3
|
"artifacts": {
|
|
4
|
-
"manifest.json": "
|
|
4
|
+
"manifest.json": "0e0fa00cfc824a79fd2a76e435f21a027aace72351bf71874629a17175accbd7",
|
|
5
5
|
"meta.json": "5a61f147f0c79262967f826c69a53b8b21fe6c41c6142e6c6c235b595482357f",
|
|
6
6
|
"types/index.d.ts": "8651f9ae166668f4311eea1fe61c3fe235f345947951c1d23d1df24a4fd3384f",
|
|
7
7
|
"rules/hardcoded-region.ts": "957eadcaa9f39cc17d21437565d7a94607d9b082cf28918b178fa067f07498a9",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"rules/waw071.ts": "d0d6e82aa7b347c1a3f41803c53906ea31a085bf04efca7f9bd7894e180b2846",
|
|
74
74
|
"skills/chant-aws.md": "4d65eb160e001f2af42eb7c622a5b498c2fd1f5afbd6c8155615c010fb265c63",
|
|
75
75
|
"skills/chant-aws-eks.md": "8789255709ff004ad0a875fd5999edcdc66fc6e33d710db058d9f42703bcfdfe",
|
|
76
|
-
"skills/chant-aws-carve-terraform.md": "
|
|
76
|
+
"skills/chant-aws-carve-terraform.md": "a6f528c814024422744118abbfd9bbf26f3d60c599e90c3f186f8b76e1e38a51"
|
|
77
77
|
},
|
|
78
|
-
"composite": "
|
|
78
|
+
"composite": "a8f4e4ad40448f8bfada7e753a7cd8dbad50e8e59991023d5a4a0b1a9b67b610"
|
|
79
79
|
}
|
package/dist/manifest.json
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -555,7 +555,7 @@ aws cloudformation wait stack-update-complete --stack-name my-app-prod`,
|
|
|
555
555
|
{
|
|
556
556
|
file: "chant-aws-carve-terraform.md",
|
|
557
557
|
name: "chant-aws-carve-terraform",
|
|
558
|
-
description: "Demo
|
|
558
|
+
description: "Demo moving one Terraform resource to native CloudFormation, fully offline (advise, emit, audit, bridge, apply); Terraform keeps the rest",
|
|
559
559
|
triggers: [
|
|
560
560
|
{ type: "context", value: "terraform" },
|
|
561
561
|
{ type: "context", value: "carve" },
|
|
@@ -579,12 +579,12 @@ aws cloudformation wait stack-update-complete --stack-name my-app-prod`,
|
|
|
579
579
|
{
|
|
580
580
|
title: "Run the offline demo",
|
|
581
581
|
description: "Demo the full advise → emit → bridge → apply loop with no cloud",
|
|
582
|
-
input: "Show me how chant
|
|
582
|
+
input: "Show me how chant moves one resource from Terraform to CloudFormation",
|
|
583
583
|
output: "cd examples/terraform-carve-out && ./demo.sh",
|
|
584
584
|
},
|
|
585
585
|
{
|
|
586
586
|
title: "Adopt a resource from state",
|
|
587
|
-
description: "Emit
|
|
587
|
+
description: "Emit chant source for the AWS lexicon from a Terraform-managed resource, offline",
|
|
588
588
|
input: "Adopt aws_s3_bucket.assets into chant",
|
|
589
589
|
output: "chant carve emit --from ./terraform --select aws_s3_bucket.assets --state ./terraform/terraform.tfstate",
|
|
590
590
|
},
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
---
|
|
2
2
|
skill: chant-aws-carve-terraform
|
|
3
|
-
description: Demo
|
|
3
|
+
description: Demo moving one Terraform resource to native CloudFormation, fully offline (advise, emit, audit, bridge, apply); Terraform keeps the rest
|
|
4
4
|
user-invocable: true
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
#
|
|
7
|
+
# Move one Terraform resource to CloudFormation (demo)
|
|
8
8
|
|
|
9
|
-
Use this skill to
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
estate
|
|
13
|
-
graduation.
|
|
9
|
+
Use this skill to demonstrate chant's carve flow, which moves one resource
|
|
10
|
+
from a Terraform estate to chant source for the AWS lexicon. The whole demo
|
|
11
|
+
runs **offline**, with no cloud account, Terraform binary or state backend. It
|
|
12
|
+
moves an S3 bucket from a small Terraform estate to chant source, patches the
|
|
13
|
+
resources that stay in Terraform, and plans the graduation.
|
|
14
14
|
|
|
15
15
|
## When to use
|
|
16
16
|
|
|
17
|
-
- Someone asks
|
|
17
|
+
- Someone asks how chant can manage one resource from a Terraform root as
|
|
18
|
+
native CloudFormation.
|
|
19
|
+
- Someone on Terraform or OpenTofu asks how to get chant's ownership markers
|
|
20
|
+
on their resources. Point them at choudoufu instead
|
|
21
|
+
(`terraform.binary: "choudoufu"`, see
|
|
22
|
+
https://intentius.io/chant/lexicons/terraform/ops/#choudoufu). Their roots
|
|
23
|
+
stay in OpenTofu.
|
|
18
24
|
- You want to show the advise → emit → audit → bridge → apply loop end to end.
|
|
19
25
|
- You are evaluating whether a Terraform estate is worth carving.
|
|
20
26
|
|
|
@@ -40,12 +46,12 @@ Walk the person through the output. That is the whole demo.
|
|
|
40
46
|
|
|
41
47
|
From `examples/terraform-carve-out`, with `TF=./terraform`:
|
|
42
48
|
|
|
43
|
-
1. **Advise
|
|
49
|
+
1. **Advise: rank the resources.**
|
|
44
50
|
```bash
|
|
45
51
|
chant carve advise --from ./terraform
|
|
46
52
|
```
|
|
47
53
|
Point out the three bands: clean leaves (carve now), carvable with edits,
|
|
48
|
-
and leave
|
|
54
|
+
and stays in Terraform (`leave in Terraform` in the JSON). `aws_s3_bucket.assets` is a clean leaf held back one
|
|
49
55
|
notch by the Lambda that reads it; `random_pet` has no native mapping.
|
|
50
56
|
|
|
51
57
|
2. **Emit — adopt the bucket into chant source, offline, from state.**
|
|
@@ -68,9 +74,9 @@ From `examples/terraform-carve-out`, with `TF=./terraform`:
|
|
|
68
74
|
chant build ./carveout/src --lexicon aws
|
|
69
75
|
```
|
|
70
76
|
The first build fails, deliberately: the post-synth audit refuses the
|
|
71
|
-
adopted bucket because
|
|
72
|
-
|
|
73
|
-
|
|
77
|
+
adopted bucket because it has no public-access block or TLS-only policy.
|
|
78
|
+
This is a feature of carving: chant tells the person which settings the
|
|
79
|
+
adopted resource is missing. Show the fix (add
|
|
74
80
|
`PublicAccessBlockConfiguration` and a companion `S3BucketPolicy` with an
|
|
75
81
|
`aws:SecureTransport = false` Deny — the tutorial page has the exact code),
|
|
76
82
|
then re-run the build and show the valid CloudFormation template.
|
|
@@ -96,7 +102,8 @@ From `examples/terraform-carve-out`, with `TF=./terraform`:
|
|
|
96
102
|
|
|
97
103
|
- Nothing is destroyed or applied; every step before graduation is reversible
|
|
98
104
|
with `terraform import`.
|
|
99
|
-
- You carve one resource at a time.
|
|
105
|
+
- You carve one resource at a time. Everything else stays in Terraform, where
|
|
106
|
+
it already works.
|
|
100
107
|
- `advise` and `bridge` work against **any** Terraform tree — offer to point
|
|
101
108
|
them at the person's own estate.
|
|
102
109
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/chant-lexicon-aws",
|
|
3
|
-
"version": "0.124.
|
|
3
|
+
"version": "0.124.56",
|
|
4
4
|
"description": "AWS CloudFormation lexicon for chant — declarative IaC in TypeScript",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://intentius.io/chant",
|
|
@@ -83,6 +83,6 @@
|
|
|
83
83
|
"typescript": "^5.9.3"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@intentius/chant": "^0.124.
|
|
86
|
+
"@intentius/chant": "^0.124.56"
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The AWS credential chain, as the AWS CLI walks it, for `chant lifecycle
|
|
3
3
|
* whoami` (#3954).
|
|
4
4
|
*
|
|
5
|
-
* `resolveCredentials` (./
|
|
5
|
+
* `resolveCredentials` (./signing.ts) reads the three environment variables and
|
|
6
6
|
* nothing else. That is right for the read transport's synchronous signing
|
|
7
7
|
* seam, and it made whoami wrong for anyone whose shell holds a profile rather
|
|
8
8
|
* than keys: `AWS_PROFILE=dev` with an SSO session came back as "no identity
|
|
@@ -55,7 +55,7 @@ import { readFileSync } from "node:fs";
|
|
|
55
55
|
import { homedir } from "node:os";
|
|
56
56
|
import { join } from "node:path";
|
|
57
57
|
import { AwsReadError, assumeRole, type AwsReadClientOptions } from "./read-client";
|
|
58
|
-
import type { AwsCredentials } from "./
|
|
58
|
+
import type { AwsCredentials } from "./signing";
|
|
59
59
|
|
|
60
60
|
/** One HTTP exchange for the SSO portal and OIDC calls. Injected by tests. */
|
|
61
61
|
export type CredentialChainHttp = (
|
|
@@ -613,7 +613,7 @@ async function walkForTransport(options: CredentialChainOptions, now: () => Date
|
|
|
613
613
|
* What the native read transport signs with when the caller injected nothing:
|
|
614
614
|
* the same chain whoami walks, so `lifecycle diff --live` signs as the
|
|
615
615
|
* principal whoami reports. The signing seam (`AwsCredentialResolver` in
|
|
616
|
-
* ./
|
|
616
|
+
* ./signing.ts) is synchronous and the chain is not, so the transport awaits
|
|
617
617
|
* this once before a request and passes the literal credentials in.
|
|
618
618
|
*
|
|
619
619
|
* Environment keys answer directly, as in the chain. Otherwise the walk is
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
xmlError,
|
|
22
22
|
type AwsReadHttp,
|
|
23
23
|
} from "./read-client";
|
|
24
|
-
import { EMPTY_PAYLOAD_SHA256 } from "./
|
|
24
|
+
import { EMPTY_PAYLOAD_SHA256 } from "./signing";
|
|
25
25
|
|
|
26
26
|
const respond = (text: string, status = 200): ReturnType<AwsReadHttp> => Promise.resolve({ status, text });
|
|
27
27
|
|
|
@@ -246,7 +246,7 @@ describe("the region an endpoint override cannot carry in its host", () => {
|
|
|
246
246
|
});
|
|
247
247
|
|
|
248
248
|
/**
|
|
249
|
-
* The signing decision, as the client makes it. `./
|
|
249
|
+
* The signing decision, as the client makes it. `./signing.test.ts` proves the
|
|
250
250
|
* signature is correct against AWS's own vectors; these prove the client only
|
|
251
251
|
* produces one when it should.
|
|
252
252
|
*/
|
package/src/api/read-client.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* ## Signing
|
|
21
21
|
*
|
|
22
22
|
* Requests are signed with SigV4 (#1686) when credentials resolve — see
|
|
23
|
-
* `./
|
|
23
|
+
* `./signing.ts`, which signs through core's signer (#4583) so that cedar's AVP client can
|
|
24
24
|
* adopt the same one rather than growing a second. With none injected, they
|
|
25
25
|
* resolve through the AWS CLI's chain (`./credential-chain.ts`, the one
|
|
26
26
|
* `chant lifecycle whoami` walks) once per process, by
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
*/
|
|
47
47
|
import { homedir } from "node:os";
|
|
48
48
|
import { transportCredentials } from "./credential-chain";
|
|
49
|
-
import { resolveCredentials, signRequest, type AwsCredentialSource } from "./
|
|
49
|
+
import { resolveCredentials, signRequest, type AwsCredentialSource } from "./signing";
|
|
50
50
|
|
|
51
|
-
export type { AwsCredentials, AwsCredentialResolver, AwsCredentialSource } from "./
|
|
51
|
+
export type { AwsCredentials, AwsCredentialResolver, AwsCredentialSource } from "./signing";
|
|
52
52
|
|
|
53
53
|
const DEFAULT_REGION = "us-east-1";
|
|
54
54
|
const CFN_API_VERSION = "2010-05-15";
|
|
@@ -1,75 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The aws lexicon's signing surface (#1686) over core's SigV4 signer (#4583).
|
|
3
3
|
*
|
|
4
|
-
* A signing implementation that is only tested against itself proves nothing
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* breaks canonicalization, those three stop matching.
|
|
4
|
+
* A signing implementation that is only tested against itself proves nothing,
|
|
5
|
+
* so the first block checks core's signer against `get-vanilla` from AWS's
|
|
6
|
+
* `aws-sig-v4-test-suite`. The Cloud Control vector further down was recorded
|
|
7
|
+
* from this lexicon's own signer before #4583 replaced it with core's: if the
|
|
8
|
+
* header set the lexicon signs drifts, that signature stops matching.
|
|
10
9
|
*
|
|
11
10
|
* Nothing here touches the network; there is nothing to touch. Signing is a
|
|
12
11
|
* pure function of the request and the clock.
|
|
13
12
|
*/
|
|
14
13
|
import { describe, test, expect } from "vitest";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
EMPTY_PAYLOAD_SHA256,
|
|
18
|
-
amzDate,
|
|
19
|
-
canonicalHeaders,
|
|
20
|
-
canonicalRequest,
|
|
21
|
-
resolveCredentials,
|
|
22
|
-
sha256Hex,
|
|
23
|
-
signRequest,
|
|
24
|
-
signingKey,
|
|
25
|
-
stringToSign,
|
|
26
|
-
} from "./sigv4";
|
|
14
|
+
import { sha256Hex, signV4 } from "@intentius/chant/cloud-lister/sigv4";
|
|
15
|
+
import { EMPTY_PAYLOAD_SHA256, UNSIGNED_HEADERS, resolveCredentials, signRequest } from "./signing";
|
|
27
16
|
|
|
28
17
|
/** The example secret AWS uses throughout its Signature Version 4 documentation. */
|
|
29
18
|
const SECRET = "wJalrXUtnFEMI/K7MDENG+bPxRfiCYEXAMPLEKEY";
|
|
30
19
|
const ACCESS_KEY = "AKIDEXAMPLE";
|
|
31
20
|
|
|
32
|
-
describe("the published
|
|
33
|
-
test("
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
expect(canonical).toBe(
|
|
50
|
-
[
|
|
51
|
-
"GET",
|
|
52
|
-
"/",
|
|
53
|
-
"",
|
|
54
|
-
"host:example.amazonaws.com",
|
|
55
|
-
"x-amz-date:20150830T123600Z",
|
|
56
|
-
"",
|
|
57
|
-
"host;x-amz-date",
|
|
58
|
-
EMPTY_PAYLOAD_SHA256,
|
|
59
|
-
].join("\n"),
|
|
60
|
-
);
|
|
61
|
-
expect(signed).toBe("host;x-amz-date");
|
|
62
|
-
|
|
63
|
-
const scope = "20150830/us-east-1/service/aws4_request";
|
|
64
|
-
const sts = stringToSign("20150830T123600Z", scope, canonical);
|
|
65
|
-
expect(sts).toBe(
|
|
66
|
-
"AWS4-HMAC-SHA256\n20150830T123600Z\n" +
|
|
67
|
-
`${scope}\nbb579772317eb040ac9ed261061d46c1f17a8133879d6129b6e1c25292927e63`,
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const key = signingKey(SECRET, "20150830", "us-east-1", "service");
|
|
71
|
-
expect(createHmac("sha256", key).update(sts, "utf8").digest("hex")).toBe(
|
|
72
|
-
"5fa00fa31553b73ebf1942676e86291e8372ff2a2260956d9b8aae1d763fbf31",
|
|
21
|
+
describe("the published vector", () => {
|
|
22
|
+
test("get-vanilla signs exactly as the test suite says", () => {
|
|
23
|
+
const headers = signV4({
|
|
24
|
+
method: "GET",
|
|
25
|
+
url: "https://example.amazonaws.com/",
|
|
26
|
+
headers: {},
|
|
27
|
+
body: "",
|
|
28
|
+
region: "us-east-1",
|
|
29
|
+
service: "service",
|
|
30
|
+
credentials: { accessKeyId: ACCESS_KEY, secretAccessKey: SECRET },
|
|
31
|
+
now: new Date("2015-08-30T12:36:00Z"),
|
|
32
|
+
});
|
|
33
|
+
expect(headers.authorization).toBe(
|
|
34
|
+
"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/service/aws4_request, " +
|
|
35
|
+
"SignedHeaders=host;x-amz-date, " +
|
|
36
|
+
"Signature=5fa00fa31553b73ebf1942676e86291e8372ff2a2260956d9b8aae1d763fbf31",
|
|
73
37
|
);
|
|
74
38
|
});
|
|
75
39
|
|
|
@@ -78,40 +42,78 @@ describe("the published vectors", () => {
|
|
|
78
42
|
});
|
|
79
43
|
});
|
|
80
44
|
|
|
81
|
-
describe("
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
45
|
+
describe("the Cloud Control vector (#4583)", () => {
|
|
46
|
+
// Recorded from lexicons/aws/src/api/sigv4.ts, the lexicon's own signer,
|
|
47
|
+
// with these inputs, before it was removed in favour of core's.
|
|
48
|
+
const request = {
|
|
49
|
+
method: "POST",
|
|
50
|
+
url: "https://cloudcontrolapi.us-east-1.amazonaws.com/",
|
|
51
|
+
headers: {
|
|
52
|
+
"content-type": "application/x-amz-json-1.0",
|
|
53
|
+
"x-amz-target": "CloudApiService.GetResource",
|
|
54
|
+
"user-agent": "chant/0.124.34",
|
|
55
|
+
"x-amzn-trace-id": "Root=1-5759e988-bd862e3fe1be46a994272793",
|
|
56
|
+
},
|
|
57
|
+
body: JSON.stringify({ TypeName: "AWS::S3::Bucket", Identifier: "chant-example-bucket" }),
|
|
58
|
+
service: "cloudcontrolapi",
|
|
59
|
+
region: "us-east-1",
|
|
60
|
+
now: new Date("2015-08-30T12:36:00Z"),
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
test("a GetResource read signs to the recorded signature, user-agent and trace id unsigned", () => {
|
|
64
|
+
const headers = signRequest({ ...request, credentials: { accessKeyId: ACCESS_KEY, secretAccessKey: SECRET } });
|
|
65
|
+
expect(headers).toEqual({
|
|
66
|
+
"content-type": "application/x-amz-json-1.0",
|
|
67
|
+
"x-amz-target": "CloudApiService.GetResource",
|
|
68
|
+
"user-agent": "chant/0.124.34",
|
|
69
|
+
"x-amzn-trace-id": "Root=1-5759e988-bd862e3fe1be46a994272793",
|
|
70
|
+
"x-amz-date": "20150830T123600Z",
|
|
71
|
+
"x-amz-content-sha256": "0748e7c18ab9933c78b1a34cd08c91183112acfa9918aea20ba2f1a6d33ef3d0",
|
|
72
|
+
authorization:
|
|
73
|
+
"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/cloudcontrolapi/aws4_request, " +
|
|
74
|
+
"SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-target, " +
|
|
75
|
+
"Signature=f8f2bbebcf51eed1126eca37ab3e614b540f0d769eb64ec2a0c5ee811b168f51",
|
|
95
76
|
});
|
|
96
77
|
});
|
|
97
78
|
|
|
98
|
-
test("
|
|
99
|
-
|
|
79
|
+
test("with a session token, the token is sent, signed, and the signature is the recorded one", () => {
|
|
80
|
+
const headers = signRequest({
|
|
81
|
+
...request,
|
|
82
|
+
credentials: { accessKeyId: ACCESS_KEY, secretAccessKey: SECRET, sessionToken: "FwoGZXIvYXdzEXAMPLE" },
|
|
83
|
+
});
|
|
84
|
+
expect(headers["x-amz-security-token"]).toBe("FwoGZXIvYXdzEXAMPLE");
|
|
85
|
+
expect(headers.authorization).toBe(
|
|
86
|
+
"AWS4-HMAC-SHA256 Credential=AKIDEXAMPLE/20150830/us-east-1/cloudcontrolapi/aws4_request, " +
|
|
87
|
+
"SignedHeaders=content-type;host;x-amz-content-sha256;x-amz-date;x-amz-security-token;x-amz-target, " +
|
|
88
|
+
"Signature=99fef393d5ff5ad524823b03476535fa00631828cc22dae15f8f3cfe9d18ab69",
|
|
89
|
+
);
|
|
100
90
|
});
|
|
91
|
+
});
|
|
101
92
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
93
|
+
describe("header set", () => {
|
|
94
|
+
test("the unsigned headers are sent but left out of the signature", () => {
|
|
95
|
+
const caller = {
|
|
105
96
|
"user-agent": "chant",
|
|
106
97
|
"x-amzn-trace-id": "Root=1-x",
|
|
107
98
|
connection: "keep-alive",
|
|
108
99
|
expect: "100-continue",
|
|
109
|
-
|
|
100
|
+
};
|
|
101
|
+
const headers = signRequest({
|
|
102
|
+
method: "POST",
|
|
103
|
+
url: "https://cloudformation.us-east-1.amazonaws.com/",
|
|
104
|
+
headers: { ...caller, authorization: "stale" },
|
|
105
|
+
body: "",
|
|
106
|
+
service: "cloudformation",
|
|
107
|
+
region: "us-east-1",
|
|
108
|
+
credentials: { accessKeyId: ACCESS_KEY, secretAccessKey: SECRET },
|
|
109
|
+
now: new Date("2015-08-30T12:36:00Z"),
|
|
110
110
|
});
|
|
111
|
-
expect(
|
|
111
|
+
for (const [name, value] of Object.entries(caller)) expect(headers[name]).toBe(value);
|
|
112
|
+
expect(headers.authorization).toContain("SignedHeaders=host;x-amz-content-sha256;x-amz-date,");
|
|
113
|
+
expect([...UNSIGNED_HEADERS].sort()).toEqual(["authorization", "connection", "expect", "user-agent", "x-amzn-trace-id"]);
|
|
112
114
|
});
|
|
113
115
|
|
|
114
|
-
test("a bodyless request hashes to the empty-payload constant
|
|
116
|
+
test("a bodyless request hashes to the empty-payload constant", () => {
|
|
115
117
|
const headers = signRequest({
|
|
116
118
|
method: "POST",
|
|
117
119
|
url: "https://cloudformation.us-east-1.amazonaws.com/",
|
|
@@ -124,20 +126,6 @@ describe("header canonicalization", () => {
|
|
|
124
126
|
});
|
|
125
127
|
expect(headers["x-amz-content-sha256"]).toBe(EMPTY_PAYLOAD_SHA256);
|
|
126
128
|
});
|
|
127
|
-
|
|
128
|
-
test("the query string sorts by name then value, RFC 3986 encoded", () => {
|
|
129
|
-
const { canonical } = canonicalRequest(
|
|
130
|
-
"GET",
|
|
131
|
-
new URL("https://example.amazonaws.com/?b=2&a=z&a=a&c=hi%20there*"),
|
|
132
|
-
{ host: "example.amazonaws.com" },
|
|
133
|
-
EMPTY_PAYLOAD_SHA256,
|
|
134
|
-
);
|
|
135
|
-
expect(canonical.split("\n")[2]).toBe("a=a&a=z&b=2&c=hi%20there%2A");
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
test("amzDate is ISO-8601 basic, which is what X-Amz-Date wants", () => {
|
|
139
|
-
expect(amzDate(new Date("2015-08-30T12:36:00.123Z"))).toBe("20150830T123600Z");
|
|
140
|
-
});
|
|
141
129
|
});
|
|
142
130
|
|
|
143
131
|
describe("signRequest", () => {
|