The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as amplify from "@distilled.cloud/aws/amplify"; |
| 2 | import * as Output from "alchemy/Output"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as Layer from "effect/Layer"; |
| 5 | import * as AWSBindings from "../AWSBindings.ts"; |
| 6 | import type { App } from "./App.ts"; |
| 7 | import { GetArtifactUrl, type GetArtifactUrlRequest } from "./GetArtifactUrl.ts"; |
| 8 | |
| 9 | // Bespoke (not via makeAmplifyHttpBinding): GetArtifactUrl addresses the |
| 10 | // artifact by its globally-unique `artifactId` alone — there is no `appId` |
| 11 | // to inject. The app is still bound for the IAM grant over its artifacts. |
| 12 | export const GetArtifactUrlHttp = Layer.effect( |
| 13 | GetArtifactUrl, |
| 14 | Effect.gen(function* () { |
| 15 | const bind = yield* AWSBindings.Bind; |
| 16 | const getArtifactUrl = yield* AWSBindings.withCredentials(amplify.getArtifactUrl); |
| 17 | |
| 18 | return Effect.fn(function* (app: App) { |
| 19 | if (!globalThis.__ALCHEMY_RUNTIME__) { |
| 20 | yield* bind`AWS.Amplify.GetArtifactUrl(${app})`({ |
| 21 | policyStatements: [ |
| 22 | { |
| 23 | Effect: "Allow", |
| 24 | Action: ["amplify:GetArtifactUrl"], |
| 25 | Resource: [Output.interpolate`${app.appArn}/branches/*/jobs/*/artifacts/*`], |
| 26 | }, |
| 27 | ], |
| 28 | }); |
| 29 | } |
| 30 | return Effect.fn(`AWS.Amplify.GetArtifactUrl(${app.LogicalId})`)(function* ( |
| 31 | request: GetArtifactUrlRequest, |
| 32 | ) { |
| 33 | return yield* getArtifactUrl(request); |
| 34 | }); |
| 35 | }); |
| 36 | }), |
| 37 | ); |