首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Claudiajs hello word示例中的凭证不加载

Claudiajs hello word示例中的凭证不加载
EN

Stack Overflow用户
提问于 2018-06-13 08:03:05
回答 2查看 896关注 0票数 1

我尝试在aws中使用ClaudiaJS,所以首先我从claudiajs下载hello示例,然后在aws上使用这些AWSLambdaFullAccessIAMFullAccessAmazonAPIGatewayAdministrator创建一个用户,然后用awscli配置.aws/credentials文件并将配置文件名从默认更改为claudia,现在我的凭据如下:

代码语言:javascript
复制
[claudia]
aws_access_key_id = xxxxxxxxx
aws_secret_access_key = xxxxxx

之后,根据教程,我运行npm i,然后npm start.the脚本如下所示:

代码语言:javascript
复制
 "scripts": {
    "start": "claudia create --name hello-world --region us-east-1 --handler main.handler",
    "test": "claudia test-lambda",
    "deploy": "claudia update"
},

但是在npm start之后,我得到了以下错误:

代码语言:javascript
复制
npm start

> hello-world@1.0.0 start /home/interact/Try/hello-world
> claudia create --name hello-world --region us-east-1 --handler 
main.handler

initialising IAM role   iam.createRole  RoleName=hello-world-executor
{ Error: connect EHOSTUNREACH 169.254.169.254:80
at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1186:14)
 message: 'Missing credentials in config',
 code: 'CredentialsError',
 errno: 'EHOSTUNREACH',
 syscall: 'connect',
 address: '169.254.169.254',
 port: 80,
 time: 2018-06-13T07:50:47.292Z,
 originalError: 
   { message: 'Could not load credentials from any providers',
 code: 'CredentialsError',
 errno: 'EHOSTUNREACH',
 syscall: 'connect',
 address: '169.254.169.254',
 port: 80,
 time: 2018-06-13T07:50:47.292Z,
 originalError: 
  { code: 'EHOSTUNREACH',
    errno: 'EHOSTUNREACH',
    syscall: 'connect',
    address: '169.254.169.254',
    port: 80,
    message: 'connect EHOSTUNREACH 169.254.169.254:80' } } }
 npm ERR! code ELIFECYCLE
 npm ERR! errno 1
 npm ERR! hello-world@1.0.0 start: `claudia create --name hello-world --region us-east-1 --handler main.handler`
 npm ERR! Exit status 1
 npm ERR! 
 npm ERR! Failed at the hello-world@1.0.0 start script.
 npm ERR! This is probably not a problem with npm. There is likely 
 additional logging output above.

 npm ERR! A complete log of this run can be found in:
 npm ERR!     /home/interact/.npm/_logs/2018-06-13T07_50_47_317Z-
 debug.log

所传达的信息是:

代码语言:javascript
复制
  enter code here`message: 'Could not load credentials from any providers'

我在SF和网络上搜索,但是没有发现任何能解决我的问题的东西。

我的节点版本是v8.11.3,npm版本是5.6.0

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-06-13 08:37:09

你可以用两种方式很容易地解决你的问题

1.通过更改..aws/凭据文件。将claudia重命名为默认

代码语言:javascript
复制
 [default]
    aws_access_key_id = xxxxxxxxx
    aws_secret_access_key = xxxxxxxxx

2.设置AWS_PROFILE环境变量。

代码语言:javascript
复制
AWS_PROFILE=deployment claudia <options>

如果您想要多个AWS用户,可以使用这种方式添加。

修改..aws/凭据文件

代码语言:javascript
复制
[default]
aws_access_key_id = xxxxxxxxx
aws_secret_access_key = xxxxxxxxx

[claudia]
aws_access_key_id = xxxxxxxxx
aws_secret_access_key = xxxx
票数 4
EN

Stack Overflow用户

发布于 2019-09-10 18:07:52

您可以将AWS_PROFILE=profile_name添加到package.json文件中。这将只为该命令设置配置文件。如果您有多个具有不同帐户的项目,这是非常有用的。

例如:

代码语言:javascript
复制
"scripts": {
    "start": "AWS_PROFILE=claudia claudia create --name hello-world --region us-east-1 --handler main.handler",
    "test": "AWS_PROFILE=claudia claudia test-lambda",
    "deploy": "AWS_PROFILE=claudia claudia update"
},
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50832048

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档