I am trying to using AWS-SDK For JavaScript to generate a monthly report of EC2 Instance for own use. I want to get the last month usage data by using CloudWatchClient and EC2Client.
const getEC2Instances = async (regions) => {
const EC2Clients = new EC2Client(myClient(regions));
const EC2Command = new DescribeInstancesCommand({});
const EC2Data = await EC2Clients.send(EC2Command);
return EC2Data;
}
let InstancesList = new Array();
for(let i=0;i<AWSRegion.length;i++){
try{
let EC2Data = await getEC2Instances(AWSRegion[i]);
InstancesList.push(EC2Data);
}catch(err){
console.log(err);
}
}
it will return some instance result for me, but i want to get the instance which is running in last months. maybe this month the instance will be terminate or deleted, i still want to get the list of instance. is there any methods to get it? thanks
as i noticed that, without cloudtrail, it is impossible to do this things.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.