Created
July 27, 2016 14:30
-
-
Save nekojaxa/4a79e643650e136d573779466f6d70c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
console.log('Loading function'); | |
let AWS = require('aws-sdk'); | |
let ec2 = new AWS.EC2(); | |
function describeEC2(){ | |
var params = { | |
Filters: [ | |
{ | |
Name: 'availability-zone', | |
Values: [ | |
'ap-northeast-1a', | |
] | |
}, | |
] | |
}; | |
ec2.describeInstances().promise().then(function(data) { | |
// 成功 | |
console.log('InstanceId:', data.Reservations[0].Instances[0].InstanceId); | |
return data; | |
}).catch(function (error) { | |
// 失敗 | |
console.log(error); | |
}); | |
} | |
exports.handler = (event, context, callback) => { | |
console.log('[START]lambda function'); | |
var data = describeEC2(); | |
console.log('InstanceId2:', data.Reservations[0].Instances[0].InstanceId); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment