我正在嘗試訪問 DynamoDb 表,但我不斷收到“找不到資源”錯誤。
表定義如下,注意表是Active,Region是Paris (eu-west-3)

我正在使用的代碼:
export class EncuestaComponent implements OnInit {
[...]
client: DynamoDBClient = new DynamoDBClient({
region : 'eu-west-3',
credentials: {
accessKeyId: '[REDACTED]',
secretAccessKey: '[REDACTED]'
}
});
[...]
onDbClick() {
const commandParams = {};
const input: BatchExecuteStatementInput = {
Statements: [
{Statement: "SELECT opciones FROM encuesta.encuesta WHERE id = 'user.1'"}
],
}
const command = new BatchExecuteStatementCommand(input);
this.client.send(command).
then(data => console.log(data.Responses![0].Error)).
catch(error => {console.log("Error"); console.log(error)});
}
并且,在控制臺中,顯示then方法已執行,但列印的訊息是{Code: 'ResourceNotFound', Message: 'Requested resource not found'}
我究竟做錯了什么?
uj5u.com熱心網友回復:
在 PartiQL for DynamoDB 中,當您這樣做時,select * from something.else 意味著您希望它在名為 something 的表上查詢名為 else 的索引。您需要執行以下操作之一:
- 逃離.
- 用引號將表名括起來
- 創建一個具有不同名稱的新表
我不在電腦前,否則我會弄清楚它適合你,但這是我要開始的地方。
uj5u.com熱心網友回復:
這是可能導致問題的原因。
你能確認一下嗎
- 您正在使用的 accessKey 是否有權從 DynamoDB 表中讀取?
- 那個accessKey沒有過期還能用嗎?
這里有一些可以幫助您測驗功能的東西嘗試在 ~/.aws/credentials 中添加密鑰并運行此命令。
aws dynamodb scan --table-name encuesta.encuesta
并確認它確實顯示了表格內容并且沒有收到拒絕訪問錯誤。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/485600.html
