| 1 | import type * as iam from "@distilled.cloud/aws/iam"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { AccessKey } from "./AccessKey.ts"; |
| 5 | |
| 6 | /** |
| 7 | * Runtime binding for `iam:GetAccessKeyLastUsed` — read when (and against |
| 8 | * which service/region) a bound {@link AccessKey} last authenticated. The |
| 9 | * primitive behind key-rotation and stale-credential reapers. |
| 10 | * |
| 11 | * Bind a canonical `AccessKey`; the runtime callable injects the key's |
| 12 | * `AccessKeyId`. AWS scopes the action to the owning *user*, whose exact |
| 13 | * path-qualified ARN is not derivable from the key, so the grant is |
| 14 | * `iam:GetAccessKeyLastUsed` on `*`. Provide the implementation with |
| 15 | * `Effect.provide(AWS.IAM.GetAccessKeyLastUsedHttp)`. |
| 16 | * |
| 17 | * ### Access Key Hygiene |
| 18 | * **Example:** Check When a Key Was Last Used |
| 19 | * ```typescript |
| 20 | * // init |
| 21 | * const getAccessKeyLastUsed = yield* IAM.GetAccessKeyLastUsed(accessKey); |
| 22 | * |
| 23 | * // runtime |
| 24 | * const { AccessKeyLastUsed, UserName } = yield* getAccessKeyLastUsed(); |
| 25 | * const lastUsed = AccessKeyLastUsed?.LastUsedDate; |
| 26 | * ``` |
| 27 | * |
| 28 | * @binding |
| 29 | */ |
| 30 | export interface GetAccessKeyLastUsed extends Binding.Service< |
| 31 | GetAccessKeyLastUsed, |
| 32 | "AWS.IAM.GetAccessKeyLastUsed", |
| 33 | <K extends AccessKey>( |
| 34 | accessKey: K, |
| 35 | ) => Effect.Effect< |
| 36 | () => Effect.Effect< |
| 37 | iam.GetAccessKeyLastUsedResponse, |
| 38 | iam.GetAccessKeyLastUsedError |
| 39 | > |
| 40 | > |
| 41 | > {} |
| 42 | export const GetAccessKeyLastUsed = Binding.Service<GetAccessKeyLastUsed>( |
| 43 | "AWS.IAM.GetAccessKeyLastUsed", |
| 44 | ); |