sst / sst

Build full-stack apps on your own infrastructure.
https://sst.dev
MIT License
24.07k stars 1.86k forks source link

Deploy Remix app using `sst dev` does not attach VPC #5906

Closed geoffrey-syncx closed 1 hour ago

geoffrey-syncx commented 3 weeks ago

My sst.config.ts as below

/// <reference path="./.sst/platform/config.d.ts" />

export default $config({
  app(input) {
    return {
      name: "etsy-sync",
      removal: input?.stage === "production" ? "retain" : "remove",
      protect: ["production"].includes(input?.stage),
      home: "aws",
    };
  },
  async run() {
    const links: any[] = [];

    const vpc = new sst.aws.Vpc("SstVpc");

    if ($dev) {
      const url = new URL(process.env.DATABASE_URL!);
      const username = url.username;
      const password = url.password;
      const host = url.hostname;
      const port = parseInt(url.port);
      const database = url.pathname.slice(1);

      const postgres = new sst.aws.Postgres("SstPostgres", {
        vpc: vpc,
        dev: {
          host,
          username,
          password,
          database,
          port,
        },
      });
      links.push(postgres);
    }

    const fSimpleLogger = new sst.aws.Function("SimpleLogger", {
      handler: "packages/functions/simpleLogger.handler",
      link: links,
      vpc,
    });
    links.push(fSimpleLogger);

    new sst.aws.Remix("SstRemix", {
      dev: {
        command: "pnpm run dev:local-emb",
      },
      link: links,
      vpc,
    });
  },
});

After run sst dev and deployed, the vpc is blank in the remix lambda

Image

geoffrey-syncx commented 1 hour ago

not a problem anymore