Skip to content

Instantly share code, notes, and snippets.

@nekojaxa
Created July 27, 2016 14:30
Show Gist options
  • Save nekojaxa/4a79e643650e136d573779466f6d70c9 to your computer and use it in GitHub Desktop.
Save nekojaxa/4a79e643650e136d573779466f6d70c9 to your computer and use it in GitHub Desktop.
'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