1import type * as WAFV2 from "@distilled.cloud/aws/wafv2";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { IPSet } from "./IPSet.ts";
5
6export interface UpdateIPSetRequest {
7 /**
8 * The complete new set of IP addresses and CIDR ranges — WAF replaces
9 * the entire list.
10 */
11 addresses: string[];
12 /**
13 * New description of the IP set. Omitted — the existing description is
14 * kept.
15 */
16 description?: string;
17}
18
19/**
20 * Runtime binding for `wafv2:UpdateIPSet` — replace the bound
21 * {@link IPSet}'s address list at runtime (the classic dynamic block list:
22 * a Lambda appends offending IPs as it detects them). The binding reads the
23 * IP set for a fresh `LockToken`, applies the update, and retries
24 * optimistic-lock conflicts automatically.
25 *
26 * Provide `WAFv2.UpdateIPSetHttp` on the hosting Lambda Function to satisfy
27 * the requirement.
28 * ### Managing IP Sets at Runtime
29 * **Example:** Add an Offending IP to the Block List
30 * ```typescript
31 * // init — grants wafv2:GetIPSet + wafv2:UpdateIPSet on the IP set
32 * const getIPSet = yield* AWS.WAFv2.GetIPSet(blockList);
33 * const updateIPSet = yield* AWS.WAFv2.UpdateIPSet(blockList);
34 *
35 * // runtime
36 * const current = (yield* getIPSet()).IPSet?.Addresses ?? [];
37 * yield* updateIPSet({ addresses: [...current, "192.0.2.7/32"] });
38 * ```
39 *
40 * @binding
41 */
42export interface UpdateIPSet extends Binding.Service<
43 UpdateIPSet,
44 "AWS.WAFv2.UpdateIPSet",
45 (
46 ipSet: IPSet,
47 ) => Effect.Effect<
48 (
49 request: UpdateIPSetRequest,
50 ) => Effect.Effect<
51 WAFV2.UpdateIPSetResponse,
52 WAFV2.GetIPSetError | WAFV2.UpdateIPSetError
53 >
54 >
55> {}
56
57export const UpdateIPSet = Binding.Service<UpdateIPSet>(
58 "AWS.WAFv2.UpdateIPSet",
59);