Skip to content

Instantly share code, notes, and snippets.

@venkatperi
Created August 17, 2015 18:29
Show Gist options
  • Save venkatperi/8164fafa71b0c316231c to your computer and use it in GitHub Desktop.
Save venkatperi/8164fafa71b0c316231c to your computer and use it in GitHub Desktop.
REST acess AWS ApiGatetwy in nodejs. Uses "private" AWS v4 signer.
AWS = require "aws-sdk"
https = require "https"
creds =
accessKeyId: "<<ACCESS KEY ID>>"
secretAccessKey: "<<SECRET ACCESS KEY>>"
opts =
method: "GET"
pathname: -> '/restapis'
path: "/restapis"
search: -> ""
region: "us-east-1"
headers :
host : "apigateway.us-east-1.amazonaws.com"
"presigned-expires": false
signer = new AWS.Signers.V4(opts, "apigateway")
signer.addAuthorization creds, new Date()
console.log JSON.stringify(opts, null, 2)
opts.host = "apigateway.us-east-1.amazonaws.com"
req = https.request opts, (res) ->
console.log 'statusCode: ', res.statusCode
console.log 'headers: ', res.headers
res.on 'data', (d) ->
process.stdout.write d
req.end()
req.on 'error', (e) -> console.error e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment