@rc312/effect-aws-imds 0.1.0 → 0.2.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/README.md +4 -16
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +3 -0
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
An **Effect-native client for the AWS EC2 Instance Metadata Service** (IMDSv2). It has no runtime dependencies besides its `effect` peer.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
bun add @rc312/effect-aws-imds 'effect@^4.
|
|
6
|
+
bun add @rc312/effect-aws-imds 'effect@^4.1.2'
|
|
7
7
|
```
|
|
8
8
|
|
|
9
9
|
## Usage
|
|
@@ -13,7 +13,10 @@ import * as AwsImds from "@rc312/effect-aws-imds";
|
|
|
13
13
|
import { Effect } from "effect";
|
|
14
14
|
|
|
15
15
|
const program = Effect.gen(function* () {
|
|
16
|
+
// Yield the Effect to obtain the decoded, memoized document.
|
|
16
17
|
const document = yield* AwsImds.identityDocument;
|
|
18
|
+
// document.instanceType is already available without another request.
|
|
19
|
+
// This extra request demonstrates uncached reads with get(path).
|
|
17
20
|
const instanceType = yield* AwsImds.get("/latest/meta-data/instance-type");
|
|
18
21
|
|
|
19
22
|
return {
|
|
@@ -141,21 +144,6 @@ const ImdsLive = AwsImds.layerFetch.pipe(
|
|
|
141
144
|
|
|
142
145
|
- **Token handling.** The session token is held as a `Redacted` value. `x-aws-ec2-metadata-token` is added to `Headers.CurrentRedactedNames` for metadata requests, so client spans that capture request headers record it as `<redacted>`. Neither error type keeps the underlying HTTP request or its headers.
|
|
143
146
|
|
|
144
|
-
## Migrating from `effect-extensions/aws/imds`
|
|
145
|
-
|
|
146
|
-
| Before | Now |
|
|
147
|
-
| --- | --- |
|
|
148
|
-
| `awsIdentityDocument()` | `identityDocument` |
|
|
149
|
-
| `layer` | `layer`, with settings from `AwsImdsConfig` |
|
|
150
|
-
| `layerWithFetchHttpClient` | `layerFetch` |
|
|
151
|
-
| `AwsImdsIdentityDocumentFetchError` | `AwsImdsMetadataError` (with `path` and `status`) |
|
|
152
|
-
| `AwsImdsResolutionError` | `AwsImdsError` |
|
|
153
|
-
| One 100 ms timeout around all retries | A 1 second timeout on each attempt |
|
|
154
|
-
| 5 retries | `retryPolicy(2)`, or any bounded `Schedule` |
|
|
155
|
-
| 1 minute token TTL, token used once | 6 hour token TTL, cached and reused |
|
|
156
|
-
| `AwsImds` with `identityDocument` and `clearCache` | `InstanceIdentity` for the document; `AwsImds` for uncached `get(path)` |
|
|
157
|
-
| — | `getSchema`, `optional`, and a replaceable `AwsImdsToken` |
|
|
158
|
-
|
|
159
147
|
## Example and end-to-end tests
|
|
160
148
|
|
|
161
149
|
[`examples/instance-info`](examples/instance-info) is a CLI that uses the built package against a strict mock IMDS. Its end-to-end tests run the CLI as a real process for the healthy, throttled, token-expiry, malformed-document, unresponsive, and unreachable cases. See its [README](examples/instance-info/README.md) to run it by hand.
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
* import * as AwsImds from "@rc312/effect-aws-imds"
|
|
24
24
|
*
|
|
25
25
|
* const program = Effect.gen(function* () {
|
|
26
|
+
* // Yield the Effect to obtain the decoded, memoized document.
|
|
26
27
|
* const document = yield* AwsImds.identityDocument
|
|
28
|
+
* // document.instanceType is already available without another request.
|
|
29
|
+
* // This extra request demonstrates uncached reads with get(path).
|
|
27
30
|
* const instanceType = yield* AwsImds.get("/latest/meta-data/instance-type")
|
|
28
31
|
* return { region: document.region, instanceType }
|
|
29
32
|
* })
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,EACL,OAAO,EACP,KAAK,YAAY,EACjB,GAAG,EACH,SAAS,EACT,QAAQ,GACT,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE5E,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
* import * as AwsImds from "@rc312/effect-aws-imds"
|
|
24
24
|
*
|
|
25
25
|
* const program = Effect.gen(function* () {
|
|
26
|
+
* // Yield the Effect to obtain the decoded, memoized document.
|
|
26
27
|
* const document = yield* AwsImds.identityDocument
|
|
28
|
+
* // document.instanceType is already available without another request.
|
|
29
|
+
* // This extra request demonstrates uncached reads with get(path).
|
|
27
30
|
* const instanceType = yield* AwsImds.get("/latest/meta-data/instance-type")
|
|
28
31
|
* return { region: document.region, instanceType }
|
|
29
32
|
* })
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,OAAO,EACL,OAAO,EAEP,GAAG,EACH,SAAS,EACT,QAAQ,GACT,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,aAAa,EAGb,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE5E,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rc312/effect-aws-imds",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Effect-native client for the AWS EC2 Instance Metadata Service (IMDSv2).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"prepack": "bun run build"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@effect/vitest": "^4.
|
|
33
|
+
"@effect/vitest": "^4.1.2",
|
|
34
34
|
"@types/node": "^26.6.5",
|
|
35
|
-
"effect": "^4.
|
|
35
|
+
"effect": "^4.1.2",
|
|
36
36
|
"vitest": "^5.0.4"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"effect": "^4.
|
|
39
|
+
"effect": "^4.1.2"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
|
-
"node": ">=22.
|
|
42
|
+
"node": ">=22.19.0"
|
|
43
43
|
}
|
|
44
44
|
}
|
package/src/index.ts
CHANGED
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
* import * as AwsImds from "@rc312/effect-aws-imds"
|
|
24
24
|
*
|
|
25
25
|
* const program = Effect.gen(function* () {
|
|
26
|
+
* // Yield the Effect to obtain the decoded, memoized document.
|
|
26
27
|
* const document = yield* AwsImds.identityDocument
|
|
28
|
+
* // document.instanceType is already available without another request.
|
|
29
|
+
* // This extra request demonstrates uncached reads with get(path).
|
|
27
30
|
* const instanceType = yield* AwsImds.get("/latest/meta-data/instance-type")
|
|
28
31
|
* return { region: document.region, instanceType }
|
|
29
32
|
* })
|