Advertisement
Leo_rossi

Lambda aws

Dec 11th, 2019
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. ///// la fonction lambda pour describeVolumes dans EC2 en nodejs
  2.  
  3. var AWS = require('aws-sdk');
  4. AWS.config.update({region: 'us-east-2'});
  5. exports.handler= function(event, context) {
  6.  
  7. // Create EC2 service object
  8.  
  9. var ec2 = new AWS.EC2({apiVersion: '2016-11-15'});
  10.  
  11. const params = {};
  12.  
  13.  
  14. // Call EC2 to retrieve policy for selected bucket
  15. ec2.describeVolumes(params, function(err, data) {
  16. if (err) {
  17. console.log("Error", err.stack);
  18. } else {
  19. const id = data.Volumes[0].State;
  20. const state = data.Volumes[0].Size;
  21. console.log("Success", id , state);
  22. }
  23. });
  24.  
  25. };
  26.  
  27. ///// Résultat de la fonction :
  28.  
  29. START RequestId: 065a85bb-02cf-4cf2-bb36-8ce0f15de5b0 Version: $LATEST
  30. 2019-12-11T08:58:07.690Z 065a85bb-02cf-4cf2-bb36-8ce0f15de5b0
  31.  
  32. INFO Success available 2
  33. END
  34.  
  35. RequestId: 065a85bb-02cf-4cf2-bb36-8ce0f15de5b0
  36. REPORT RequestId: 065a85bb-02cf-4cf2-bb36-8ce0f15de5b0 Duration: 1659.26 ms Billed Duration: 1700 ms Memory Size: 128 MB Max Memory Used: 98 MB Init Duration: 301.62 ms
  37.  
  38. ////// Question :
  39. j'ai le bon résultat mais j'ai adapté le code pris sur le sdk lambda nodejs problème comme je suis novice je ne comprend pas bien la structure avec l'index[0]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement