【发布时间】:2019-10-01 02:56:38
【问题描述】:
我正在使用 AWSservices,所以我正在为 nodeJS 使用“aws-sdk”包。根据他们在官方网站上的说明,他们要求在您当前的用户配置文件中创建一个 .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/credentials? -
是的,这个文件在那里
标签: node.js ubuntu-16.04 aws-sdk