我们正在尝试启用 DAX 以在我们的 NodeJS Lambda 中使用。我们已经创建了 VPC,将 DAX 和 Lambda 添加到 VPC,但是现在当 lambda 函数抛出错误时:
Failed to pull from xxxxx (xxx.xx.xx.122): { Error: Client does not have permission to invoke Endpoints
code: undefined,
retryable: false,
requestId: null,
statusCode: -1,
_tubeInvalid: true,
waitForRecoveryBeforeRetrying: false,
_message: 'Client does not have permission to invoke Endpoints',
codeSeq: [ 4, 23, 31, 34 ],
cancellationReasons: undefined }
这是 Lambda 代码:
const daxOptions = {
endpoint: 'xxx.apse2.cache.amazonaws.com:8111',
region: 'ap-southeast-2',
};
const daxClient = new AmazonDaxClient(daxOptions);
const dynamoDb = new DynamoDB.DocumentClient({ service: daxClient, convertEmptyValues: true });
...
const payload = {
RequestItems: {
['tableName']: {
Keys: items.map(itemId => ({
id: itemId,
})),
},
},
};
const response = await dynamoDb.batchGet(payload).promise();
DAX 集群似乎工作正常。我们可以使用以下方法列出 DAX 集群:aws dax describe-clusters --r ap-southeast-2 --profile tst