Skip to content

Generate aws signature v4 for API Gateway (execute-api) using AWS Signature version 4

Notifications You must be signed in to change notification settings

thinhle-agilityio/aws-v4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

aws-v4

A small utility to generate AWS Signature V4 using vanilla nodejs.

Use case is especially for AWS API GATEWAY (excute-api) service.

Installation

npm install aws-v4

Example

Below example is using post request, you can also use other request such as: get, put, delete

const axios  = require('axios');
const awsV4 = require('aws-v4');

// Sign your request
// This example is post request, you can 
const signedRequest = awsV4.newClient({
    accessKey: <AWS_ACCESS_KEY_ID>,
    secretKey: <AWS_SECRET_KEY>,
    // sessionToken is required if you run this on AWS lambda
    // sessionToken: <AWS_SESSION_TOKEN>,
    region: <AWS_REGION>,
    endpoint: <AWS_API_GATEWAY_ENDPOINT>
  }).signRequest({
    method: 'post',
    path: '/example/path',
    headers: {
      'Content-Type': 'application/json'
    },
    queryParams: {},
    body: {}
  });

// Make http request with your signed request
const options = {
  url: signedRequest.url,
  method: 'post',
  headers: signedRequest.headers,
  data: {}
}

axios(options)
  .then(res => console.log(res))
  .catch(err => console.log(err))

About

Generate aws signature v4 for API Gateway (execute-api) using AWS Signature version 4

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published