@distilled.cloud/aws 0.2.6 → 0.3.0-alpha
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 +49 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ npm install @distilled.cloud/aws effect
|
|
|
11
11
|
## Quick Start
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
import { Effect } from "effect";
|
|
14
|
+
import { Effect, Layer } from "effect";
|
|
15
15
|
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
|
|
16
16
|
import * as S3 from "@distilled.cloud/aws/s3";
|
|
17
17
|
import { Credentials, Region } from "@distilled.cloud/aws";
|
|
@@ -31,14 +31,57 @@ const program = Effect.gen(function* () {
|
|
|
31
31
|
return result.ContentType;
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
Effect.runPromise,
|
|
34
|
+
const AwsLive = Layer.mergeAll(
|
|
35
|
+
FetchHttpClient.layer,
|
|
36
|
+
Region.fromEnv(),
|
|
37
|
+
Credentials.fromChain(),
|
|
39
38
|
);
|
|
39
|
+
|
|
40
|
+
program.pipe(Effect.provide(AwsLive), Effect.runPromise);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
### Region
|
|
46
|
+
|
|
47
|
+
`Region.fromEnv()` reads from the `AWS_REGION` environment variable (falls back to `AWS_DEFAULT_REGION`):
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
AWS_REGION=us-east-1
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Credentials
|
|
54
|
+
|
|
55
|
+
`Credentials.fromChain()` uses the standard AWS credential provider chain, which tries each source in order until one succeeds:
|
|
56
|
+
|
|
57
|
+
1. **Environment variables** — `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and optionally `AWS_SESSION_TOKEN`
|
|
58
|
+
2. **Shared credentials file** — `~/.aws/credentials` (supports multiple profiles via `AWS_PROFILE`)
|
|
59
|
+
3. **SSO** — `aws sso login --profile your-profile` (reads cached SSO tokens)
|
|
60
|
+
4. **Container metadata** — ECS task role credentials
|
|
61
|
+
5. **EC2 instance metadata** — IMDS instance profile credentials
|
|
62
|
+
6. **Token file** — `AWS_WEB_IDENTITY_TOKEN_FILE` for OIDC federation (EKS)
|
|
63
|
+
|
|
64
|
+
You can also use a specific provider directly:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
// Environment variables only
|
|
68
|
+
Credentials.fromEnv()
|
|
69
|
+
|
|
70
|
+
// SSO profile (run `aws sso login` first)
|
|
71
|
+
Credentials.fromSSO("my-profile")
|
|
72
|
+
|
|
73
|
+
// Shared credentials file (~/.aws/credentials)
|
|
74
|
+
Credentials.fromIni()
|
|
75
|
+
|
|
76
|
+
// Static credentials
|
|
77
|
+
Credentials.fromCredentials({
|
|
78
|
+
accessKeyId: "AKIA...",
|
|
79
|
+
secretAccessKey: "...",
|
|
80
|
+
})
|
|
40
81
|
```
|
|
41
82
|
|
|
83
|
+
Credentials are cached and automatically refreshed 5 minutes before expiration.
|
|
84
|
+
|
|
42
85
|
## Error Handling
|
|
43
86
|
|
|
44
87
|
All operations return typed errors for pattern matching:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/aws",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0-alpha",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/alchemy-run/distilled",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@aws-crypto/util": "^5.2.0",
|
|
83
83
|
"@aws-sdk/credential-providers": "^3.994.0",
|
|
84
84
|
"@aws-sdk/types": "^3.973.1",
|
|
85
|
-
"@distilled.cloud/core": "0.
|
|
85
|
+
"@distilled.cloud/core": "0.3.0-alpha",
|
|
86
86
|
"@smithy/shared-ini-file-loader": "^4.4.3",
|
|
87
87
|
"@smithy/types": "^4.12.0",
|
|
88
88
|
"@smithy/util-base64": "^4.3.0",
|