I am trying to use the aws-sdk/client-applicationcostprofiler so I could import data from S3 to cost profiler. But I keep getting the error
getaddrinfo ENOTFOUND application-cost-profiler.ap-southeast-1.amazonaws.com
This is what I did..
imported package:
const { ApplicationCostProfilerClient, ListReportDefinitionsCommand, ImportApplicationUsageCommand } = require("@aws-sdk/client-applicationcostprofiler");
the rest of the code:
const clientCP = new ApplicationCostProfilerClient({region: env.region});
const paramsCP = {
"sourceS3Location": {
"bucket": env.bucketname,
"key": env.key,
"region": env.region
}
}
const CommandCP = new ImportApplicationUsageCommand(paramsCP);
const dataCP = await clientCP.send(CommandCP);
CodePudding user response:
Found this buried deep in some documentation...
Service endpoints
Application Cost Profiler is a global service. All API calls must be made to the US East (N. Virginia) endpoint.
- US East (N. Virginia) –
application-cost-profiler.us-east-1.amazonaws.com
Ignore your env.region
and use a hard-coded us-east-1
...
const clientCP = new ApplicationCostProfilerClient({region: "us-east-1"});
I'd still raise an issue with the AWS team since their own code just doesn't make sense...
hostname: "application-cost-profiler.{region}.amazonaws.com",