amazon-web-services - 无法将 DynamoDB 与 Lambda 连接

标签 amazon-web-services aws-lambda amazon-dynamodb

这是我的代码

var dynamodb = new AWS.DynamoDB();
dynamodb.batchGetItem(params, function(err, data) {
    if (err) console.log(err, err.stack); // an error occurred
    else console.log(data); // successful response
});

我收到了这个错误

{
    message: 'Could not load credentials from any providers',
    errno: 'ETIMEDOUT',
    code: 'CredentialsError',
    syscall: 'connect',
    address: 'x.x.x.x',
    port: 80,
    time: 2019-03-13T07:59:34.279Z,
    originalError: {
        errno: 'ETIMEDOUT',
        code: 'ETIMEDOUT',
        syscall: 'connect',
        address: 'x.x.x.x',
        port: 80,
        message: 'connect ETIMEDOUT x.x.x.x:80'
    }
}

我是 AWS 新手。我认为使用 Lambda 调用 DynamoDB 不需要访问权限和 key 。那是对的吗? 我还授予完整的 DynamoDB 访问权限角色。是什么原因导致这个问题?

最佳答案

我在这里遇到了同样的问题。原因是您的 Lambda 函数似乎位于 VPC 内部,而 DynamoDB 则不然。尝试删除设置中网络部分的 VPC,应该可以解决。

关于amazon-web-services - 无法将 DynamoDB 与 Lambda 连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55137164/

相关文章:

amazon-web-services - 如何向 URL 发送简单的 GET 并在 Lambda 中查看返回的响应?

node.js - S3.getSignedUrl 接受多种内容类型

node.js - 如何从 s3 在 dynamodb 中存储和检索照片的 url?

php - 如何使用 DynamoDB PHP 从表中获取最新的时间戳值

amazon-web-services - 在 YAML 文件中设置 S3 存储桶的生命周期配置

amazon-web-services - AWS Data Pipeline 不支持“m3.xlarge”

amazon-web-services - 如何在AWS ELB后面获得客户端IP?

java - 如何为 Amazon Web Service 重构 Java Web 应用程序?

javascript - AWS Dynamodb不通过 Node js同步获取数据

amazon-web-services - 我在执行 aws cloudformation 模板时遇到错误,抛出错误 ROLLBACK_COMPLETE