Skip to content

Instantly share code, notes, and snippets.

Created June 9, 2020 23:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save iann0036/d8883ed3b22967c9f8a22c2fcace9349 to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
const request = require('request');
const aws4 = require('aws4');
const AWS = require('aws-sdk');
let chain = new AWS.CredentialProviderChain();
chain.resolve((err, awscreds) => {
let awsreq = aws4.sign({
service: 'sts',
region: 'us-east-1',
method: 'POST',
path: '/?Action=GetSessionToken&Version=2011-06-15',
headers: {
'Content-Type': 'application/x-amz-json-1.1'
//'X-Amz-Target': 'STS.GetSessionToken'
body: JSON.stringify({})
}, {
secretAccessKey: awscreds.secretAccessKey,
accessKeyId: awscreds.accessKeyId
url: 'https://' + awsreq.hostname + awsreq.path,
headers: awsreq.headers,
body: awsreq.body
}, function(err, httpResponse, body) {
if (err) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment