我有一个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