1.0.2 • Public • Published


Signs an http(s) request options object with AWS Signature Version 4 headers and returns them

Sample Usage

Use the signAWS function provided by the module to add the appropriate cryptographically secure headers to an http or https request options object. This function accepts an options object as the first parameter and a callback as the second parameter. checkout repo npm install

let signAWS = require('./aws-sigv4-ec2metadata/index.js');
let https = require('https');

let deleteOpts = {
    host: '',
    path: '/api/configs/1',
    method: 'DELETE'

signAWS(deleteOpts, (signedOpts) => {
    let req = https.request(signedOpts, (res) => {
        let body = [];
        res.on('data', (d) => {
        res.on('end', () => console.log(body.join('')));
    req.on('error', console.error);

Testing Locally

To test locally, use the aws-mock-metadata library to simulate an ec2 instance profile environment.

Steps to Install on OSX

  1. Boto dependency
    1. sudo easy_install pip
    2. sudo pip install boto
  2. Clone
  3. Configure aws-mock-metadata
    1. Create a server.conf file in the root of the aws-mock-metadata folder (see server.conf.sample for an example of this)
    2. Replace the **** values in this file with your AWS user access key and secret key
  4. Start the mock metadata server by running ./bin/server-macos
  5. Verify the server is running and configured correctly by hitting the metadata url in your local browser

Note that your user account and/or ec2 instance profile role must have the execute-api policy for a given resource in order to query AWS_IAM protected API methods.

Package Sidebar


npm i aws-sigv4-ec2meta

Weekly Downloads






Last publish


  • ben.balentine