prisma / docs

πŸ“š Prisma Documentation
https://www.prisma.io/docs
Apache License 2.0
983 stars 779 forks source link

AWS SAM CLI instructions recommends invalid BuildProperties #5525

Open ianwremmel opened 11 months ago

ianwremmel commented 11 months ago

The instructions at https://www.prisma.io/docs/guides/deployment/serverless/deploy-to-aws-lambda#loading-required-files say to add the following to each function's Metadata.BuildProperties:

Loader:
  - .prisma=file
  - .so.node=file
AssetNames: '[name]'

However, in so doing, sam build fails with

Error: NodejsNpmEsbuildBuilder:EsbuildBundle - Esbuild Failed: ✘ [ERROR] Invalid option in build() call: "loader:"

and

Error: NodejsNpmEsbuildBuilder:EsbuildBundle - Esbuild Failed: ✘ [ERROR] Invalid option in build() call: "asset-names:"
nikolasburk commented 1 week ago

Hey @ianwremmel πŸ‘‹ sorry for the delay on this! Do you recall if you found a solution for this issue by any chance?

IsaacMM01 commented 1 week ago

Hi @nikolasburk I am working on implementing Prisma in a SAM application to enable queries with PostgreSQL. I came across the same documentation mentioned in the post, but as someone with limited experience in CloudFormation or AWS SAM, I find the process of setting it up in a layer a bit challenging. I read this post, Deploying Prisma with AWS Lambda Layers in CDK, as well as this one on deploying Prisma with Serverless, but they don’t fully work for local testing scenarios. Do you have any solutions or documentation that might help with a local setup?

ianwremmel commented 5 days ago

Mostly, I just chose to ignore those instructions. As far as I can tell, the prisma schema file is not, in fact, necessary at runtime. It's been to long since I did most of this, so I don't remember the details, but this is my prisma config:

generator client {
  provider        = "prisma-client-js"
  binaryTargets   = ["native", "rhel-openssl-1.0.x"]
  previewFeatures = ["driverAdapters", "views"]
}

datasource db {
  provider  = "postgresql"
  url       = env("DATABASE_URL")
  directUrl = env("DIRECT_URL")
}

My assumption is that, by using prisma-client-js, I don't need to the schema file or the compiled .node.so file.