AWS JS SDK V3(Lambda模块)-无法连接到实例元数据服务 [英] AWS JS SDK V3 (Lambda module) - Unable to connect to instance metadata service

查看:171
本文介绍了AWS JS SDK V3(Lambda模块)-无法连接到实例元数据服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前使用的是一体式 aws-sdk npm模块( https://www.npmjs.com/package/aws-sdk )来调用AWS Lambda函数,因此以下代码运行良好:

I was previously using the all-in-one aws-sdk npm module (https://www.npmjs.com/package/aws-sdk) to invoke an AWS Lambda function, and for that the following code had been working well:

        //Some code to get "credentials"
        ...
        const AWS = require('aws-sdk');
        const lambda = new AWS.Lambda({
            accessKeyId: credentials.accessKeyId,
            secretAccessKey: credentials.secretAccessKey,
            region: Config.REGION
        });
        lambda.invoke(pullParams, (err, data) =>
            //I would do something with data
        );
        ...

现在,从 https://github.com/aws/aws-sdk-js-v3 ,我希望用于模块化 @ aws-sdk / client-lambda-node ,因为它是我项目中唯一需要的类。因此,我更改了代码(如此处的建议: https://github.com/aws/aws-sdk-js-v3/tree/master/packages/client-lambda-node#usage ),像这样:

Now, taking a cue from https://github.com/aws/aws-sdk-js-v3, I wish to use to modularised @aws-sdk/client-lambda-node, since it is the only class that I need in my project. Thus, I have changed my code (as suggested here: https://github.com/aws/aws-sdk-js-v3/tree/master/packages/client-lambda-node#usage) like so:

        import * as AWS from "@aws-sdk/client-lambda-node/Lambda";
        /*
          I believe there is a typo in the form of 
          "
           import * as AWS from "@aws-sdk/@aws-sdk/client-lambda-node/Lambda";
          "
          at the original page
        */
        ...
        //Some code to get the same "credentials" as above
        const lambda = new AWS.Lambda({
            accessKeyId: credentials.accessKeyId,
            secretAccessKey: credentials.secretAccessKey,
            region: Config.REGION
        });
        lambda.invokeAsync(pullParams, (err, data) =>
            //I want to do something with err / data
        );
        ...

对于它的价值,它位于ReactJS应用程序中(尽管我'确定那是不相关的)。在浏览器(运行较早的版本)中永久尝试使用版本为 0.1.0-preview.5 的上述代码给我

For what its worth, this is inside a ReactJS app (though I'm sure thats not relevant). Trying the above code with version 0.1.0-preview.5 inside a browser (where it worked earlier) perpetually gives me


  1. http://169.254.169.254/latest/meta-data/iam/security-credentials/ net :: ERR_CONNECTION_TIMED_OUT

  2. 错误:无法连接到实例元数据服务(我想与(1)有关)

  1. http://169.254.169.254/latest/meta-data/iam/security-credentials/ net::ERR_CONNECTION_TIMED_OUT
  2. Error: Unable to connect to instance metadata service (I guess related to (1))

库使用不稳定吗?还是我做错了事?

Is the library unstable for use, or am I doing something wrong

推荐答案

是的,SDK的版本3仍处于beta预览中,并且他们已经声明,期望可以做出重大更改:

Yes, version 3 of the SDK is still in beta preview and they've stated that breaking changes are to be expected:


在SDK处于预览状态时,您可能会遇到错误。

While the SDK is in preview, you may encounter bugs.

要回答您的问题,是的,目前生产绝对不稳定时间。您的特定问题很常见,我也无法深入探究。我的作品仍然使用v2。

To answer your question, yes, it is absolutely unstable for production at the present time. Your specific issue is quite common and I was unable to get to the bottom of it either. My production work all uses v2 still.

这篇关于AWS JS SDK V3(Lambda模块)-无法连接到实例元数据服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆