Returns information about the AWS Instance that calls it


000.2.03 years ago4 years agoMinified + gzip package size for @everymundo/aws-instance-identity in KB



Returns information about the AWS Instance that calls it


npm install @everymundo/aws-instance-identity


With promise

const { getIdentityDocument } = require('@everymundo/aws-instance-identity');
  .then((result) => {
  .catch((err) => {

With async/await

const { getIdentityDocument } = require('@everymundo/aws-instance-identity');

const init = async() => {
  try {
    const result = getIdentityDocument();
  } catch (e) {

Running outside AWS servers

When running locally it will fail the request since that request is done to an endpoint that only works inside the aws infrastructure.

With Socks Proxy

If you really want to get a document you can do so by running a socks proxy with an AWS instance via ssh. The connection can be stablished by running the following command:

# You should replace your-instance-address by your instance address
ssh -ND 8157 your-instance-address &> /dev/null & PID=$! && echo $PID

After that you can just set the environment variable SOCKS_PROXY=socks:// and run your aplication.

You can try that out in a node console

SOCKS_PROXY=socks:// node -e "require('@everymundo/aws-instance-identity').getIdentityDocument().then(console.log)"

The output would be similar to this:

  privateIp: '',
  devpayProductCodes: null,
  availabilityZone: 'us-west-1a',
  version: '2010-08-31',
  instanceId: 'i-2093840273489',
  billingProducts: null,
  instanceType: 'm4.xlarge',
  accountId: '98237498273984',
  architecture: 'x86_64',
  kernelId: null,
  ramdiskId: null,
  imageId: 'ami-34cb443',
  pendingTime: '2017-10-20T20:41:03Z',
  region: 'us-west-1'

Without Socks Proxy

This should bring you an error

node -e "require('@everymundo/aws-instance-identity').getIdentityDocument().catch(console.error)"

The error message would be something similar to this:

{ code: 599,
  start: 2018-03-21T04:35:54.692Z,
  end: 1521606957775,
   { Error: connect EHOSTUNREACH
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1170:14)
     errno: 'EHOSTUNREACH',
     code: 'EHOSTUNREACH',
     syscall: 'connect',
     address: '',
     port: 80 },
  attempt: 1,
  endpoint: '' }

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.