gpt4 book ai didi

node.js - 无法从 NodeJS 中的任何提供者加载凭据

转载 作者:太空宇宙 更新时间:2023-11-03 22:20:38 24 4
gpt4 key购买 nike

我正在使用AWSservices,所以我使用nodeJS的“aws-sdk”包。根据官方网站上的说明,他们要求在您当前的用户配置文件中创建一个 .aws 文件夹,并在其中创建包含 secret 和访问 key 的凭证文件。

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/credentials。再次以 root 用户身份使用 AWS CLI 创建它们。这有两个障碍。

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

第二个可能与用户访问有关。仍然不确定为什么它不从已经存在的文件中读取凭据。我也创建了环境变量。我已经有两个提供商,但仍然没有从他们那里获取 key ......

下面是任何遇到与提供商相关的问题的人的文档链接。

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

关于node.js - 无法从 NodeJS 中的任何提供者加载凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56124351/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com