| 1 | import type * as datazone from "@distilled.cloud/aws/datazone"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Environment } from "./Environment.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for `datazone:GetEnvironmentCredentials`. |
| 8 | * |
| 9 | * Fetches the short-lived AWS credentials of the bound environment's provisioned user role. The `secretAccessKey` and `sessionToken` are `Redacted` — unwrap with `Redacted.value` only at the point of use. The domain and environment ids are injected from the binding. |
| 10 | * Provide the implementation with |
| 11 | * `Effect.provide(AWS.DataZone.GetEnvironmentCredentialsHttp)`. |
| 12 | * ### Environment Credentials |
| 13 | * **Example:** Assume the Environment's Role |
| 14 | * ```typescript |
| 15 | * // init — bind the operation to the environment |
| 16 | * const getEnvironmentCredentials = yield* AWS.DataZone.GetEnvironmentCredentials(environment); |
| 17 | * |
| 18 | * // runtime |
| 19 | * const creds = yield* getEnvironmentCredentials(); |
| 20 | * const secret = Redacted.value(creds.secretAccessKey!); |
| 21 | * ``` |
| 22 | * |
| 23 | * @binding |
| 24 | */ |
| 25 | export interface GetEnvironmentCredentials extends Binding.Service< |
| 26 | GetEnvironmentCredentials, |
| 27 | "AWS.DataZone.GetEnvironmentCredentials", |
| 28 | ( |
| 29 | environment: Environment, |
| 30 | ) => Effect.Effect< |
| 31 | () => Effect.Effect< |
| 32 | datazone.GetEnvironmentCredentialsOutput, |
| 33 | datazone.GetEnvironmentCredentialsError |
| 34 | > |
| 35 | > |
| 36 | > {} |
| 37 | export const GetEnvironmentCredentials = |
| 38 | Binding.Service<GetEnvironmentCredentials>( |
| 39 | "AWS.DataZone.GetEnvironmentCredentials", |
| 40 | ); |