mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
⭐feat(infra): Use a shared VPC (#218)
## Description The scope of this PR is to add a shared VPC for everyone on the team.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { vpc } from "./vpc";
|
import { vpc } from "./vpc";
|
||||||
import { bus } from "./bus";
|
import { bus } from "./bus";
|
||||||
import { domain } from "./dns";
|
import { domain } from "./dns";
|
||||||
import { email } from "./email";
|
// import { email } from "./email";
|
||||||
import { secret } from "./secret";
|
import { secret } from "./secret";
|
||||||
import { postgres } from "./postgres";
|
import { postgres } from "./postgres";
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ export const auth = new sst.aws.Auth("Auth", {
|
|||||||
handler: "packages/functions/src/auth.handler",
|
handler: "packages/functions/src/auth.handler",
|
||||||
link: [
|
link: [
|
||||||
bus,
|
bus,
|
||||||
email,
|
// email,
|
||||||
postgres,
|
postgres,
|
||||||
authFingerprintKey,
|
authFingerprintKey,
|
||||||
secret.PolarSecret,
|
secret.PolarSecret,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { vpc } from "./vpc";
|
import { vpc } from "./vpc";
|
||||||
import { email } from "./email";
|
// import { email } from "./email";
|
||||||
import { allSecrets } from "./secret";
|
import { allSecrets } from "./secret";
|
||||||
import { postgres } from "./postgres";
|
import { postgres } from "./postgres";
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ bus.subscribe("Event", {
|
|||||||
vpc,
|
vpc,
|
||||||
handler: "./packages/functions/src/event/event.handler",
|
handler: "./packages/functions/src/event/event.handler",
|
||||||
link: [
|
link: [
|
||||||
email,
|
// email,
|
||||||
postgres,
|
postgres,
|
||||||
...allSecrets
|
...allSecrets
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { domain } from "./dns";
|
import { domain } from "./dns";
|
||||||
|
|
||||||
export const email = new sst.aws.Email("Mail",{
|
// export const email = new sst.aws.Email("Mail",{
|
||||||
sender: domain,
|
// sender: domain,
|
||||||
dns: sst.cloudflare.dns(),
|
// dns: sst.cloudflare.dns(),
|
||||||
})
|
// })
|
||||||
@@ -2,7 +2,7 @@ import { vpc } from "./vpc";
|
|||||||
import { isPermanentStage } from "./stage";
|
import { isPermanentStage } from "./stage";
|
||||||
|
|
||||||
// TODO: Add a dev db to use, this will help with running zero locally... and testing it
|
// TODO: Add a dev db to use, this will help with running zero locally... and testing it
|
||||||
export const postgres = new sst.aws.Aurora("Postgres", {
|
export const postgres = new sst.aws.Aurora("Database", {
|
||||||
vpc,
|
vpc,
|
||||||
engine: "postgres",
|
engine: "postgres",
|
||||||
scaling: isPermanentStage
|
scaling: isPermanentStage
|
||||||
|
|||||||
26
infra/vpc.ts
26
infra/vpc.ts
@@ -1,17 +1,11 @@
|
|||||||
// import { isPermanentStage } from "./stage";
|
import { isPermanentStage } from "./stage";
|
||||||
|
|
||||||
// export const vpc = isPermanentStage
|
export const vpc = isPermanentStage
|
||||||
// ? new sst.aws.Vpc("Vpc", {
|
? new sst.aws.Vpc("VPC", {
|
||||||
// az: 2,
|
az: 2,
|
||||||
// })
|
// For lambdas to work in this VPC
|
||||||
// //FIXME: Change this ID
|
nat: "ec2",
|
||||||
// : undefined //sst.aws.Vpc.get("Vpc", "vpc-070a1a7598f4c12d1");
|
// For SST tunnel to work
|
||||||
// //
|
bastion: true,
|
||||||
|
})
|
||||||
export const vpc = new sst.aws.Vpc("NestriVpc", {
|
: sst.aws.Vpc.get("VPC", "vpc-0beb1cdc21a725748");
|
||||||
az: 2,
|
|
||||||
// For lambdas to work in this VPC
|
|
||||||
nat: "ec2",
|
|
||||||
// For SST tunnel to work
|
|
||||||
bastion: true
|
|
||||||
})
|
|
||||||
@@ -2,9 +2,9 @@ import { Resource } from "sst";
|
|||||||
import { defineConfig } from "drizzle-kit";
|
import { defineConfig } from "drizzle-kit";
|
||||||
|
|
||||||
const connection = {
|
const connection = {
|
||||||
user: Resource.Postgres.username,
|
user: Resource.Database.username,
|
||||||
password: Resource.Postgres.password,
|
password: Resource.Database.password,
|
||||||
host: Resource.Postgres.host,
|
host: Resource.Database.host,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import { drizzle } from "drizzle-orm/postgres-js";
|
|||||||
const client = postgres({
|
const client = postgres({
|
||||||
idle_timeout: 30000,
|
idle_timeout: 30000,
|
||||||
connect_timeout: 30000,
|
connect_timeout: 30000,
|
||||||
host: Resource.Postgres.host,
|
host: Resource.Database.host,
|
||||||
database: Resource.Postgres.database,
|
database: Resource.Database.database,
|
||||||
user: Resource.Postgres.username,
|
user: Resource.Database.username,
|
||||||
password: Resource.Postgres.password,
|
password: Resource.Database.password,
|
||||||
port: Resource.Postgres.port,
|
port: Resource.Database.port,
|
||||||
max: parseInt(process.env.POSTGRES_POOL_MAX || "1"),
|
max: parseInt(process.env.POSTGRES_POOL_MAX || "1"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
7
packages/functions/sst-env.d.ts
vendored
7
packages/functions/sst-env.d.ts
vendored
@@ -28,13 +28,6 @@ declare module "sst" {
|
|||||||
"name": string
|
"name": string
|
||||||
"type": "sst.aws.Bus"
|
"type": "sst.aws.Bus"
|
||||||
}
|
}
|
||||||
"Database": {
|
|
||||||
"host": string
|
|
||||||
"name": string
|
|
||||||
"password": string
|
|
||||||
"type": "sst.sst.Linkable"
|
|
||||||
"user": string
|
|
||||||
}
|
|
||||||
"DatabaseMigrator": {
|
"DatabaseMigrator": {
|
||||||
"name": string
|
"name": string
|
||||||
"type": "sst.aws.Function"
|
"type": "sst.aws.Function"
|
||||||
|
|||||||
7
sst-env.d.ts
vendored
7
sst-env.d.ts
vendored
@@ -28,13 +28,6 @@ declare module "sst" {
|
|||||||
"name": string
|
"name": string
|
||||||
"type": "sst.aws.Bus"
|
"type": "sst.aws.Bus"
|
||||||
}
|
}
|
||||||
"Database": {
|
|
||||||
"host": string
|
|
||||||
"name": string
|
|
||||||
"password": string
|
|
||||||
"type": "sst.sst.Linkable"
|
|
||||||
"user": string
|
|
||||||
}
|
|
||||||
"DatabaseMigrator": {
|
"DatabaseMigrator": {
|
||||||
"name": string
|
"name": string
|
||||||
"type": "sst.aws.Function"
|
"type": "sst.aws.Function"
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ export default $config({
|
|||||||
},
|
},
|
||||||
cloudflare: "5.49.0",
|
cloudflare: "5.49.0",
|
||||||
random: "4.17.0",
|
random: "4.17.0",
|
||||||
neon: "0.6.3",
|
|
||||||
command: "1.0.2",
|
command: "1.0.2",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user