The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import * as Context from "effect/Context"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as Layer from "effect/Layer"; |
| 5 | |
| 6 | export interface ExampleNetwork { |
| 7 | vpc: AWS.EC2.Network; |
| 8 | functionSecurityGroup: AWS.EC2.SecurityGroup; |
| 9 | databaseSecurityGroup: AWS.EC2.SecurityGroup; |
| 10 | privateSecurityGroups: AWS.EC2.SecurityGroup[]; |
| 11 | } |
| 12 | |
| 13 | export class Network extends Context.Service<Network, ExampleNetwork>()("Network") {} |
| 14 | |
| 15 | export const NetworkLive = Layer.effect( |
| 16 | Network, |
| 17 | Effect.gen(function* () { |
| 18 | const network = yield* AWS.EC2.Network("Network", { |
| 19 | cidrBlock: "10.0.0.0/16", |
| 20 | availabilityZones: 2, |
| 21 | nat: "single", |
| 22 | }); |
| 23 | |
| 24 | const functionSecurityGroup = yield* AWS.EC2.SecurityGroup("FunctionSecurityGroup", { |
| 25 | vpcId: network.vpcId, |
| 26 | description: "Security group for the RDS example Lambda function", |
| 27 | }); |
| 28 | |
| 29 | const databaseSecurityGroup = yield* AWS.EC2.SecurityGroup("DatabaseSecurityGroup", { |
| 30 | vpcId: network.vpcId, |
| 31 | description: "Security group for the RDS example Aurora cluster", |
| 32 | ingress: [ |
| 33 | { |
| 34 | ipProtocol: "tcp", |
| 35 | fromPort: 5432, |
| 36 | toPort: 5432, |
| 37 | referencedGroupId: functionSecurityGroup.groupId, |
| 38 | description: "Allow Lambda to reach Aurora PostgreSQL", |
| 39 | }, |
| 40 | ], |
| 41 | }); |
| 42 | |
| 43 | return { |
| 44 | vpc: network, |
| 45 | functionSecurityGroup, |
| 46 | databaseSecurityGroup, |
| 47 | privateSecurityGroups: [functionSecurityGroup], |
| 48 | } satisfies ExampleNetwork; |
| 49 | }), |
| 50 | ); |