![](/img/trans.png)
[英]User is not authorized to perform: dynamodb:PutItem on resource
[英]User is not authorized to perform: dynamodb:GetItem
我在 vercel 中創建了我的 api,它使用 aws lambda。在我的 function 中,我在我的 aws 帳戶中調用了 dynamodb。
但我不斷收到AccessDeniedException
。
但是,當我在本地運行它時,沒有問題。
AccessDeniedException: User: arn:aws:sts::764717618004:assumed-role/cloudwatch_logs_events_putter/L0ZFqQmkoVXQ44u8QwB1yH0f-805fd9d54732e5470e54bf12bd9a25672e379b5
is not authorized to perform: dynamodb:GetItem on resource: arn:aws:dynamodb:ap-south-1:764717618004:table/users
這解決了 lambda 和 dynamo 屬於同一用戶帳戶時的問題。
猜猜看,經過數小時的 aws 文檔梳理后,我找到了問題的根源。 user: arn:aws:sts::764717618004:assumed-role/
和arn:aws:dynamodb:ap-south-1:764717618004:table/users
是一樣的,我一想就覺得很奇怪。
因為dynamodb的aws Id本來應該是我的,但顯然不是。 所以我嘗試記錄accessKeyId
,令我驚訝的是它不是我在環境中設置的。
然后我檢查了vercel env ls
中的內容。 乍一看沒什么問題,但后來我注意到DYNAMODB_ACCESS_KYE_ID
中有一點錯字。
是的,這只是一個錯字。 在環境變量的拼寫錯誤上成功浪費了 6 個多小時。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.