| 1 | import type * as mwaa from "@distilled.cloud/aws/mwaa"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { AirflowRoleOptions } from "./BindingHttp.ts"; |
| 5 | import type { Environment } from "./Environment.ts"; |
| 6 | |
| 7 | /** |
| 8 | * Runtime binding for `airflow:CreateWebLoginToken`. |
| 9 | * |
| 10 | * Bind an {@link Environment} inside a function runtime to mint short-lived |
| 11 | * Apache Airflow web login tokens — exchange the token against |
| 12 | * `https://{WebServerHostname}/aws_mwaa/aws-console-sso` to open an |
| 13 | * authenticated Airflow UI session. The IAM grant is scoped to the Airflow |
| 14 | * RBAC role the session is mapped to (`Admin` by default — pass |
| 15 | * `{ airflowRole }` to scope it down). The `WebToken` is `Redacted` — unwrap |
| 16 | * it with `Redacted.value`. Provide the implementation with |
| 17 | * `Effect.provide(AWS.MWAA.CreateWebLoginTokenHttp)`. |
| 18 | * ### Creating Web Login Tokens |
| 19 | * **Example:** Mint a Web Login Token |
| 20 | * ```typescript |
| 21 | * // init — bind the operation to the environment (Admin session) |
| 22 | * const createWebLoginToken = yield* AWS.MWAA.CreateWebLoginToken(environment); |
| 23 | * |
| 24 | * // runtime — mint a token and build the SSO login URL |
| 25 | * const token = yield* createWebLoginToken(); |
| 26 | * const loginUrl = |
| 27 | * `https://${token.WebServerHostname}/aws_mwaa/aws-console-sso` + |
| 28 | * `?login=true#${Redacted.value(token.WebToken!)}`; |
| 29 | * ``` |
| 30 | * |
| 31 | * **Example:** Scope the Session to a Read-Only Airflow Role |
| 32 | * ```typescript |
| 33 | * const createViewerToken = yield* AWS.MWAA.CreateWebLoginToken(environment, { |
| 34 | * airflowRole: "Viewer", |
| 35 | * }); |
| 36 | * ``` |
| 37 | * |
| 38 | * @binding |
| 39 | */ |
| 40 | export interface CreateWebLoginToken extends Binding.Service< |
| 41 | CreateWebLoginToken, |
| 42 | "AWS.MWAA.CreateWebLoginToken", |
| 43 | ( |
| 44 | environment: Environment, |
| 45 | options?: AirflowRoleOptions, |
| 46 | ) => Effect.Effect< |
| 47 | () => Effect.Effect< |
| 48 | mwaa.CreateWebLoginTokenResponse, |
| 49 | mwaa.CreateWebLoginTokenError |
| 50 | > |
| 51 | > |
| 52 | > {} |
| 53 | |
| 54 | export const CreateWebLoginToken = Binding.Service<CreateWebLoginToken>( |
| 55 | "AWS.MWAA.CreateWebLoginToken", |
| 56 | ); |