Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including aws-instance-metadata with all npm packages installed. Try it out:

var awsInstanceMetadata = require("aws-instance-metadata")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

aws-instance-metadata v2.1.2

A utility for retrieving the desired AWS EC2 instance metadata from a running instance


This module is used to retrieve a piece of metadata for a running AWS EC2 instance. It returns takes a callback in order to return the data.


$ npm install aws-instance-metadata


$ npm install aws-instance-metadata --save


When using raven.js, it's common to add server level information for debugging purposes. We can use aws-instance-metadata to do just that. In order to tag all future error messages with the instance ID, we could do:

const raven = require('raven').Client(/* configuration omitted */);
const awsInstanceMetadata = require('aws-instance-metadata');

awsInstanceMetadata.fetch('instance-id').then((instanceId) => {
    instanceId: instanceId
}, console.error);


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free