79270102

Date: 2024-12-10 23:41:04
Score: 0.5
Natty:
Report link

Looking at your code I presume you're using Amplify Gen 2 backend?

They've moved from the Gen 1 way of doing this (where amplify generates the table variables etc.). The Lambda should use the schema with generateClient from aws-amplify/data to access the dynamodb tables. This is far better than messing around with env variables everywhere IMO. The schema has to allow the lambda function to do this - permissions defined in the (amplify/data/resource.ts).

Follow the guide here:

https://docs.amplify.aws/react-native/build-a-backend/functions/examples/create-user-profile-record/

You need the latest version of everything amplify. To support importing env from "$amplify/env/post-confirmation" I had to add the path to the amplify/tsconfig.json:

{
  "compilerOptions": {
    "target": "es2022",
    "module": "es2022",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "skipLibCheck": true,
    "paths": {
      "$amplify/*": ["../.amplify/generated/*"]
    }
  },
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: upp22