-
Notifications
You must be signed in to change notification settings - Fork 112
feat(aws): rewrite AWS resources to use aws4fetch + Effect #403
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
91fdc2f
feat: rewrite AWS resources to use aws4fetch + Effect
claude[bot] a545ab6
refactor(aws): use EffectResource pattern for declarative Effect flow…
claude[bot] 4632f85
refactor(aws): address PR review feedback for Effect-based AWS resources
claude[bot] 2a500b9
refactor(aws): address PR review feedback for Effect-based AWS resources
claude[bot] 2cd840a
fix(aws): address PR review feedback for Effect-based AWS resources
claude[bot] 5f615e5
refactor(aws): use Data.TaggedError and catchTag for error handling
claude[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,29 @@ | ||
| import { GetCallerIdentityCommand, STSClient } from "@aws-sdk/client-sts"; | ||
|
|
||
| const sts = new STSClient({}); | ||
| import { Effect } from "effect"; | ||
| import { createAwsClient, type AwsError } from "./client.ts"; | ||
|
|
||
| export type AccountId = string & { | ||
| readonly __brand: "AccountId"; | ||
| }; | ||
|
|
||
| /** | ||
| * Helper to get the current AWS account ID | ||
| * Helper to get the current AWS account ID using Effect-based API | ||
| */ | ||
| export function AccountId(): Effect.Effect<AccountId, AwsError> { | ||
| return Effect.gen(function* () { | ||
| const client = yield* createAwsClient({ service: "sts" }); | ||
| const identity = yield* client.postJson<{ | ||
| GetCallerIdentityResult: { Account: string }; | ||
| }>("/", { | ||
| Action: "GetCallerIdentity", | ||
| Version: "2011-06-15", | ||
| }); | ||
| return identity.GetCallerIdentityResult.Account as AccountId; | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Helper to get the current AWS account ID as a Promise (for backwards compatibility) | ||
| */ | ||
| export async function AccountId(): Promise<AccountId> { | ||
| const identity = await sts.send(new GetCallerIdentityCommand({})); | ||
| return identity.Account! as AccountId; | ||
| export async function getAccountId(): Promise<AccountId> { | ||
| return Effect.runPromise(AccountId()); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why resource not found is succeeds or whether it would be thrown anyway?
Is ResourceNotFound misleading and it should just be NotFound?