我有一個Lambda函數來在EC2中創建快照。該函數的工作原理,但沒有返回值(即,我想要得到這個值data.SnapshotId
)。AWS Lambda aws.ec2()不返回值(NodeJS)
創建快照的EC2調用嵌套在對s3.getObject的調用中,並在調用s3.putObject之前嵌套。
s3.getObject(params, function(err, data) {
if (err) {
console.log(err);
console.log(message);
context.fail(message);
} else {
new aws.EC2().createSnapshot(params_snapshot, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else {
console.log(data.SnapshotId); // this is my concern
}
});
var params_new = {
Bucket: bucket,
Key: key,
Body: body
};
s3.putObject(params_new, function(err, data) {
if (err) {
console.log(err);
console.log(message);
context.fail(message);
} else {
console.log('CONTENT TYPE putObject:', data.ContentType);
context.succeed(data.ContentType);
}
});
}
});
我最關心的是在這裏
new aws.EC2().createSnapshot(params_snapshot, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else {
console.log(data.SnapshotId); // this is my concern
}
});
您有問題要問? – idbehold
是的,爲什麼我沒有收到來自aws.EC2的回調值() – Casper
'data.SnapshotId'沒有被記錄到控制檯? – idbehold