| 1 | import type * as ec2 from "@distilled.cloud/aws/ec2"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { SecurityGroup } from "./SecurityGroup.ts"; |
| 5 | |
| 6 | /** |
| 7 | * `AuthorizeSecurityGroupIngress` request with `GroupId` injected from the |
| 8 | * bound {@link SecurityGroup}. |
| 9 | */ |
| 10 | export interface AuthorizeSecurityGroupIngressRequest extends Omit< |
| 11 | ec2.AuthorizeSecurityGroupIngressRequest, |
| 12 | "GroupId" | "GroupName" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Runtime binding for the `AuthorizeSecurityGroupIngress` operation scoped to |
| 17 | * the bound {@link SecurityGroup} (IAM action |
| 18 | * `ec2:AuthorizeSecurityGroupIngress` on the security group ARN). |
| 19 | * |
| 20 | * Adds an inbound rule to the group at runtime — the classic dynamic |
| 21 | * IP-allowlisting Lambda that opens a port for an operator's current address. |
| 22 | * Pair with {@link RevokeSecurityGroupIngress} to remove the rule afterwards. |
| 23 | * Provide the implementation with |
| 24 | * `Effect.provide(AWS.EC2.AuthorizeSecurityGroupIngressHttp)`. |
| 25 | * ### Dynamic Security Group Rules |
| 26 | * **Example:** Allowlist an address for SSH |
| 27 | * ```typescript |
| 28 | * // init — bind the operation to the security group |
| 29 | * const authorizeIngress = yield* AWS.EC2.AuthorizeSecurityGroupIngress(group); |
| 30 | * |
| 31 | * // runtime — open port 22 for the caller's address |
| 32 | * yield* authorizeIngress({ |
| 33 | * IpProtocol: "tcp", |
| 34 | * FromPort: 22, |
| 35 | * ToPort: 22, |
| 36 | * CidrIp: "203.0.113.7/32", |
| 37 | * }); |
| 38 | * ``` |
| 39 | * |
| 40 | * @binding |
| 41 | */ |
| 42 | export interface AuthorizeSecurityGroupIngress extends Binding.Service< |
| 43 | AuthorizeSecurityGroupIngress, |
| 44 | "AWS.EC2.AuthorizeSecurityGroupIngress", |
| 45 | ( |
| 46 | group: SecurityGroup, |
| 47 | ) => Effect.Effect< |
| 48 | ( |
| 49 | request: AuthorizeSecurityGroupIngressRequest, |
| 50 | ) => Effect.Effect< |
| 51 | ec2.AuthorizeSecurityGroupIngressResult, |
| 52 | ec2.AuthorizeSecurityGroupIngressError |
| 53 | > |
| 54 | > |
| 55 | > {} |
| 56 | |
| 57 | export const AuthorizeSecurityGroupIngress = |
| 58 | Binding.Service<AuthorizeSecurityGroupIngress>( |
| 59 | "AWS.EC2.AuthorizeSecurityGroupIngress", |
| 60 | ); |