我尝试从 Lambda 函数调用 AWS 免费套餐 API,但收到此错误:
Inaccessible host: `freetier.us-east-1.amazonaws.com' at port `undefined'. This service may not be available in the `us-east-1' region.
免费层 API 文档:
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/FreeTier.html
我的代码:
const AWS = require('aws-sdk');
module.exports = {
getFreeTierUsage: async (awsCredential) => {
var freetier = new AWS.FreeTier({
accessKeyId: awsCredential.accessKeyId,
secretAccessKey: awsCredential.secretAccessKey
});
var params = {};
let result = await freetier.getFreeTierUsage(params).promise();
return result;
}
}
怎么了?
AWS 似乎正在更改其 API 的 URL 格式。
传统上它看起来像:
https://freetier.us-east-1.amazonaws.com
但是,类:AWS.FreeTier — AWS SDK for JavaScript文档将其显示为:
https://freetier.us-east-1.api.aws