繁体   English   中英

无法从NodeJS中的任何提供程序加载凭据

[英]Could not load credentials from any providers in NodeJS

我使用的是AWSservices,因此我将“ aws-sdk”包用于nodeJS。 按照他们在官方网站上的说明,他们要求在您当前的用户配置文件中创建一个.aws文件夹,并在其中创建包含密钥和访问密钥的凭据文件。

AWS文档链接-

https://aws.amazon.com/developers/getting-started/nodejs/

我在Windows和Ubuntu上遵循相同的步骤。 在Windows中,AWS服务运行良好,但是当我将代码设置上传到AWS ubuntu实例时,它开始给我以下错误。

 { "message": "Missing credentials in config", "retryable": false, "time": "2019-05-13T12:34:45.834Z", "code": "CredentialsError", "originalError": { "message": "Could not load credentials from any providers", "retryable": false, "time": "2019-05-13T12:34:45.834Z", "code": "CredentialsError" } } 

这是我在JS文件中包含“ aws-sdk”的代码。

 const AWS = require('aws-sdk'); const { saveUserTokens, updateMigratedUser } = require('./databaseOperations'); const AWS_REGION = "us-west-2"; const CLIENT_ID = "5f70t79un9ep945645k5rooqocr4mfg"; const USER_POOL_ID = "us-west-2_xxxxx"; AWS.config.update({ region: AWS_REGION }); const cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider(); 

AWS.config对象的控制台日志-

 Config { credentials: SharedIniFileCredentials { expired: false, expireTime: null, refreshCallbacks: [], accessKeyId: 'XXXXXXXXXXXXXXX', sessionToken: undefined, filename: undefined, profile: 'default', disableAssumeRole: true, preferStaticCredentials: false, tokenCodeFn: null, httpOptions: null }, credentialProvider: CredentialProviderChain { providers: [ [Function], [Function], [Function], [Function], [Function], [Function] ], resolveCallbacks: [] }, region: 'us-west-2', logger: null, apiVersions: {}, apiVersion: null, endpoint: undefined, httpOptions: { timeout: 120000 }, maxRetries: undefined, maxRedirects: 10, paramValidation: true, sslEnabled: true, s3ForcePathStyle: false, s3BucketEndpoint: false, s3DisableBodySigning: true, computeChecksums: true, convertResponseTypes: true, correctClockSkew: false, customUserAgent: null, dynamoDbCrc32: true, systemClockOffset: 0, signatureVersion: null, signatureCache: true, retryDelayOptions: {}, useAccelerateEndpoint: false, clientSideMonitoring: false, endpointDiscoveryEnabled: false, endpointCacheSize: 1000, hostPrefixEnabled: true } 

问题已解决。 我删除了.aws /凭证。 再次以root用户身份使用AWS CLI创建它们。 这有两个障碍。

第一个是-我正在使用pm2运行我的节点服务器。 它以root用户以及另一个用户配置文件的身份运行服务器的多个实例。

其次可能与用户访问有关。 仍然不确定为什么它不从那里已经存在的文件中读取凭证。 我也创建了环境变量。 我已经有两个提供商了,但仍然没有从中选择密钥。

以下是面向与提供商相关的任何问题的任何人的doc链接。

https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html#cli-quick-configuration

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM