The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import * as AWS from "@alchemy.run/aws"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | |
| 4 | export const database = Effect.gen(function* () { |
| 5 | const vpc = yield* AWS.EC2.Vpc("Vpc", { cidrBlock: "10.62.0.0/16" }); |
| 6 | const subnetA = yield* AWS.EC2.Subnet("SubnetA", { |
| 7 | vpcId: vpc.vpcId, |
| 8 | cidrBlock: "10.62.0.0/24", |
| 9 | availabilityZone: "us-west-2a", |
| 10 | }); |
| 11 | const subnetB = yield* AWS.EC2.Subnet("SubnetB", { |
| 12 | vpcId: vpc.vpcId, |
| 13 | cidrBlock: "10.62.1.0/24", |
| 14 | availabilityZone: "us-west-2b", |
| 15 | }); |
| 16 | const lambdaSecurityGroup = yield* AWS.EC2.SecurityGroup("LambdaSecurityGroup", { |
| 17 | vpcId: vpc.vpcId, |
| 18 | description: "Aurora example application; no inbound connections", |
| 19 | }); |
| 20 | const dbSecurityGroup = yield* AWS.EC2.SecurityGroup("DatabaseSecurityGroup", { |
| 21 | vpcId: vpc.vpcId, |
| 22 | description: "Postgres from the application security group only", |
| 23 | ingress: [ |
| 24 | { |
| 25 | ipProtocol: "tcp", |
| 26 | fromPort: 5432, |
| 27 | toPort: 5432, |
| 28 | referencedGroupId: lambdaSecurityGroup.groupId, |
| 29 | }, |
| 30 | ], |
| 31 | }); |
| 32 | const subnetIds = [subnetA.subnetId, subnetB.subnetId]; |
| 33 | const aurora = yield* AWS.RDS.Aurora("Database", { |
| 34 | databaseName: "app", |
| 35 | engine: "aurora-postgresql", |
| 36 | engineVersion: "17.5", |
| 37 | subnetIds, |
| 38 | securityGroupIds: [dbSecurityGroup.groupId], |
| 39 | secret: { username: "dbadmin" }, |
| 40 | dataApi: true, |
| 41 | cluster: { |
| 42 | enableIAMDatabaseAuthentication: true, |
| 43 | serverlessV2ScalingConfiguration: { MinCapacity: 0.5, MaxCapacity: 1 }, |
| 44 | }, |
| 45 | instance: { dbInstanceClass: "db.serverless", publiclyAccessible: false }, |
| 46 | }); |
| 47 | return { ...aurora, vpc, subnetIds, lambdaSecurityGroup }; |
| 48 | }); |