私は自分の問題を解決することができた。ここで
ec2.describeInstances(function(err, result) {
if (err)
console.log(err);
var inst_id = '-';
for (var i = 0; i < result.Reservations.length; i++) {
var res = result.Reservations[i];
var instances = res.Instances;
for (var j = 0; j < instances.length; j++) {
var tagArr = instances[j].Tags[0];
console.log(tagArr);
}
}
});
は私が得る結果です。 :)
ec2.describeInstances(function(err, result) {
if (err)
console.log(err); // Logs error message.
var inst_id = '-';
for (var i = 0; i < result.Reservations.length; i++) {
var res = result.Reservations[i];
var instances = res.Instances;
for (var j = 0; j < instances.length; j++) {
var instanceID = instances[j].InstanceId;
var tags = instances[j].Tags;
for (var k = 0; k < tags.length; k++) {
if (tags[k].Key == 'Name') {
var params = {
InstanceId: instanceID, /* required */
Name: tags[k].Value, /* required */
Description: 'Testing AMI Node3',
DryRun: false,
NoReboot: true
};
ec2.createImage(params, function(err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});
}
}
}
}
});