Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ec2-info

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ec2-info - npm Package Compare versions

Comparing version 0.0.1 to 1.0.0

4

cli.js

@@ -28,3 +28,3 @@ const ec2Info = require('./index')

ec2Info(keys, (err, info) => {
ec2Info(keys, ec2InfoOptions, (err, info) => {
if (err) {

@@ -47,3 +47,3 @@ return console.error(err)

throw new Error('invalid format')
}, ec2InfoOptions)
})
}

@@ -50,0 +50,0 @@

@@ -14,14 +14,14 @@ 'use strict'

* @param {array} properties - names of properties to fetch
* @param {function} callback - callback function for results, `(err, info) => { // info is an es6 map }`
* @param {object} options - tweaking options
* @param {string} [options.dataURL='http://169.254.169.254/latest/'] - change the url to fetch data from
* @param {boolean} [options.testIsEc2Machine=true] - disabled is-ec2-machine test
* @param {function} callback - callback function for results, `(err, info) => { // info is an es6 map }`
*
* @public
*/
module.exports = (properties, callback, options) => {
module.exports = (properties, options, callback) => {
if (typeof(properties) === 'function') {
options = callback
callback = properties
properties = undefined
if (typeof(options) === 'function') {
callback = options
options = undefined
}

@@ -28,0 +28,0 @@

{
"name": "ec2-info",
"version": "0.0.1",
"description": "Extract ec2 metadata information from the local http interface on an ec2 instance",
"license": "MIT",
"author": {
"name": "Yaniv Kessler",
"email": "yaniv@ironsrc.com"
},
"scripts": {
"test": "mocha test.js"
},
"bin": {
"ec2-info": "cli.js",
"ec2info": "cli.js"
},
"dependencies": {
"async": "^2.6.0",
"commander": "^2.12.2",
"concat-stream": "^1.6.0",
"debug": "^3.1.0",
"is-ec2-machine": "^1.0.0"
},
"devDependencies": {
"chai": "^4.1.2",
"mocha": "~4.0.1"
},
"keywords": [
"aws",
"ec2"
],
"engines": {
"node": ">=7.0.0",
"npm": ">=2.0.0"
}
}
"name": "ec2-info",
"version": "1.0.0",
"description": "Extract ec2 metadata information from the local http interface on an ec2 instance",
"license": "MIT",
"author": {
"name": "Yaniv Kessler",
"email": "yaniv@ironsrc.com"
},
"scripts": {
"test": "mocha test.js"
},
"bin": {
"ec2-info": "cli.js",
"ec2info": "cli.js"
},
"dependencies": {
"async": "^2.6.0",
"commander": "^2.12.2",
"concat-stream": "^1.6.0",
"debug": "^3.1.0",
"is-ec2-machine": "^1.0.0"
},
"devDependencies": {
"chai": "^4.1.2",
"mocha": "~4.0.1"
},
"keywords": [
"aws",
"ec2"
],
"engines": {
"node": ">=7.0.0",
"npm": ">=2.0.0"
}
}

@@ -6,6 +6,7 @@ # ec2-info

[![npm status](http://img.shields.io/npm/v/ec2-info.svg?style=flat-square)](https://www.npmjs.org/package/ec2-info)
[![Build Status](https://secure.travis-ci.org/ironSource/ec2-info.png?branch=master)](http://travis-ci.org/ironSource/ec2-info)
This module can be consumed programmatically or as a command line tool
Click [here](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html#instancedata-data-categories) for complete reference about ec2 metadata information
Click [here](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html#instancedata-data-categories) for complete reference about ec2 metadata information or better yet, use this module's cli to get an index of properties.

@@ -21,12 +22,16 @@ Beware, though, when traversing the ec2 metadata information tree! There are some "traps" one is ought to know of in advance, if one is to save precious time... this is discussed [here](rant.md)

ec2Info((err, info) => {
let properties = ['meta-data/instance-id', 'meta-data/instance-type']
// fetch these properties
ec2Info(properties, (err, info) => {
if (err) return console.error(err)
// prints: Map { 'instance-id' => 'foofoofoo', 'public-ipv4' => '1.2.3.4' }
// prints: Map { 'meta-data/instance-id' => 'foofoofoo', 'meta-data/instance-type' => 'm4-large' }
console.log(info)
})
// custom properties
ec2Info(['instance-id', 'instance-type'], (err, info) => {
// custom data url
let options = { dataURL: 'http://localhost:8080/latest/' }
ec2Info(properties, options, (err, info) => {
if (err) return console.error(err)
// prints: Map { 'instance-id' => 'foofoofoo', 'instance-type' => 'm4-large' }
// prints: Map { 'meta-data/instance-id' => 'foofoofoo', 'meta-data/instance-type' => 'm4-large' }
console.log(info)

@@ -38,7 +43,11 @@ })

### `ec2Info([properties,] callback)`
Fetch the default set of properties or the one specified in properties and return them in the callback inside an ES6 Map object.
### `ec2Info(properties, callback [, options])`
Fetch the specified set of properties and return them in the callback inside an ES6 Map object.
If used on anything other than an ec2 instance as determined by [is-ec2-machine](https://github.com/ironsource/is-ec2-machine) the module will still work without an error but all the property values will be `not an ec2 machine`.
You can disable that check by specifying the option `{ testIsEc2Machine: false }`
You can also change the default url `http://169.254.169.254/latest/` to something else by specifying the option `{ dataURL: 'http://localhost:8080/latest' }`. This is helpful in testing or if you're using the package on your machine but want to port foward to an ec2 instance, e.g: `ssh -f ec2-user@<ec2 host address> -L 8080:169.254.169.254:80 -N`'
## command line tool

@@ -57,4 +66,7 @@ `npm i -g ec2-info`

## debug
uses [debug](https://github.com/visionmedia/debug) with namespace `ec2-info`
## license
[MIT](http://opensource.org/licenses/MIT) © ironSource ltd

@@ -21,3 +21,3 @@ const ec2Info = require('./index')

let properties = ['meta-data/ami-id', '/meta-data/instance-id', 'made-up']
ec2Info(properties, (err, info) => {
ec2Info(properties, testOptions, (err, info) => {
if (err) return done(err)

@@ -29,3 +29,3 @@ expect(info.size).to.equal(3)

done()
}, testOptions)
})
})

@@ -60,3 +60,5 @@

let properties = ['meta-data/services/partition', '/meta-data/services/domain']
ec2Info(properties, (err, info) => {
let options = { dataURL: 'http://localhost:8080/latest/' }
ec2Info(properties, options, (err, info) => {
if (err) return done(err)

@@ -67,3 +69,3 @@ expect(info.size).to.equal(2)

done()
}, { dataURL: 'http://localhost:8080/latest/' })
})
})

@@ -70,0 +72,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc