| 1 | import type * as WAFV2 from "@distilled.cloud/aws/wafv2"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { RuleGroup } from "./RuleGroup.ts"; |
| 5 | |
| 6 | export interface PutPermissionPolicyRequest extends Omit< |
| 7 | WAFV2.PutPermissionPolicyRequest, |
| 8 | "ResourceArn" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `wafv2:PutPermissionPolicy` — attach an IAM policy |
| 13 | * that shares the bound {@link RuleGroup} with other accounts (e.g. a SaaS |
| 14 | * granting tenant accounts the right to reference the group from their web |
| 15 | * ACLs); the rule group ARN is injected automatically. A malformed policy |
| 16 | * fails with the typed `WAFInvalidPermissionPolicyException`. |
| 17 | * |
| 18 | * Provide `WAFv2.PutPermissionPolicyHttp` on the hosting Lambda Function to |
| 19 | * satisfy the requirement. |
| 20 | * ### Sharing Rule Groups |
| 21 | * **Example:** Share the Rule Group with Another Account |
| 22 | * ```typescript |
| 23 | * // init — grants wafv2:PutPermissionPolicy on the rule group |
| 24 | * const putPermissionPolicy = yield* AWS.WAFv2.PutPermissionPolicy(group); |
| 25 | * |
| 26 | * // runtime |
| 27 | * yield* putPermissionPolicy({ |
| 28 | * Policy: JSON.stringify({ |
| 29 | * Version: "2012-10-17", |
| 30 | * Statement: [ |
| 31 | * { |
| 32 | * Effect: "Allow", |
| 33 | * Principal: { AWS: "arn:aws:iam::123456789012:root" }, |
| 34 | * Action: ["wafv2:CreateWebACL", "wafv2:UpdateWebACL"], |
| 35 | * Resource: group.ruleGroupArn, |
| 36 | * }, |
| 37 | * ], |
| 38 | * }), |
| 39 | * }); |
| 40 | * ``` |
| 41 | * |
| 42 | * @binding |
| 43 | */ |
| 44 | export interface PutPermissionPolicy extends Binding.Service< |
| 45 | PutPermissionPolicy, |
| 46 | "AWS.WAFv2.PutPermissionPolicy", |
| 47 | ( |
| 48 | ruleGroup: RuleGroup, |
| 49 | ) => Effect.Effect< |
| 50 | ( |
| 51 | request: PutPermissionPolicyRequest, |
| 52 | ) => Effect.Effect< |
| 53 | WAFV2.PutPermissionPolicyResponse, |
| 54 | WAFV2.PutPermissionPolicyError |
| 55 | > |
| 56 | > |
| 57 | > {} |
| 58 | |
| 59 | export const PutPermissionPolicy = Binding.Service<PutPermissionPolicy>( |
| 60 | "AWS.WAFv2.PutPermissionPolicy", |
| 61 | ); |