Access DynamoDB from /api/ #13920
-
Do you have a recommended flow for working with AWS resources like DynamoDB? I have an api endpoint at /api/signup that creates a user in dynamodb.
When I run next locally I use an
However, once deployed Vercel sets its own AWS_ACCESS_KEY_ID and SECRET which does not have access to my resources. I know I can set the key and secret in the aws-skd, but then this will prevent the AWS_PROFILE from working. Anyone have a better development flow for working with aws resources? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 7 replies
-
It doesn't seem that we can attach policies to the roles of the Lambdas that Vercel deploys on our behalf (API routes / getServerSideProps). User and role credentials expire. It seems we're unable to use Vercel while simultaneously following best practices for authorizing access to AWS resources. This deployment solution seems decent (although I'm hesitant to use it myself). I'd be very grateful if a Vercel team member could offer clarity. & apologies if I missed some docs... although I don't believe I have. |
Beta Was this translation helpful? Give feedback.
-
Can you make sure you're on the latest stable version of Next.js? |
Beta Was this translation helpful? Give feedback.
-
Here's an AWS example with S3 and CDK for Infra. Not exactly what you're looking for (Dynamo) but it might help point you in the right direction. |
Beta Was this translation helpful? Give feedback.
-
@Timer @leerob using global AWS credentials is not a solution with which all users will feel comfortable. Being able to interact with API route roles would allow users to follow security practices, such as automated credential rotation. I don't know how you'd offer the power-user experience within the managed service... it's a shame that we otherwise lose out on the API route serialization magic. It does seem like this is a catch 22 of building a business around open source. Whatever the case, I love what you and the team are doing! |
Beta Was this translation helpful? Give feedback.
-
Hopefully this helps! https://vercel.com/templates/next.js/aws-dynamodb-with-nextjs-api-routes |
Beta Was this translation helpful? Give feedback.
Hopefully this helps! https://vercel.com/templates/next.js/aws-dynamodb-with-nextjs-api-routes