Failed to get `iam` related data
musmanalibaloch opened this issue · 8 comments
I am trying to get data against IAM , I used different actions(getUsers etc) but its not working, although its working for rest of services( ec2,s3) but not for iam
I am getting this issue
path: '/?Action=GetCredentialReport&Version=2010-05-08',
headers:
{ Host: 'iam.amazonaws.com',
'X-Amz-Date': '20200205T122225Z',
Authorization:
'AWS4-HMAC-SHA256 Credential=AKIAUVX76JZQL3WPHP53/20200205/us-east-1/iam/aws4_request, SignedHeaders=host;x-amz-date, Signature=7282883e62297c362ad7e22a9478f11b42726f8d3fa4773e54d02cfc25bdc64e' } } '<<<<'
events.js:174
throw er; // Unhandled 'error' event
^
Error: connect ETIMEDOUT 54.239.22.207:80
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
Emitted 'error' event at:
at Socket.socketErrorListener (_http_client.js:392:9)
at Socket.emit (events.js:198:13)```
That's not an AWS signing error – that's a connection error. Nothing to do with aws4
@mhart it works for all other services, and also the important thing to mention, it works in postman, but it does not work with aws4, I should have mentioned this early, sorry for that.
Can you show me the code you're using?
I am away from system, I will paste my code here tomorrow morning.
This is my code.
try {
const service = argv.service || 'ec2';
const action = argv.action || 'DescribeSubnets';
if (argv.access_key && argv.secret_key && (argv.service || service) && (argv.action || action) && (argv.region) && argv.version) {
let opts = (argv.service === 'iam'
? { host: `${argv.service || service}.amazonaws.com`, path: `/?Action=${argv.action || action}&Version=${argv.version}` }
: { host: `${argv.service || service}.${argv.region}.amazonaws.com`, path: `/?Action=${argv.action || action}&Version=${argv.version}` }
)
const res = await request(
aws4.sign(opts,
{
accessKeyId: argv.access_key,
secretAccessKey: argv.secret_key
})
)
process.send({ data: res, status: true });
} else {
process.send({
status: false
})
}
} catch (error) {
process.send({
status: false
})
}
}
Works fine for me using the code from this repository's README:
const https = require('https')
const aws4 = require('aws4')
const opts = { service: 'iam', path: '/?Action=GetCredentialReport&Version=2010-05-08' }
https.request(aws4.sign(opts), res => res.pipe(process.stdout)).end()
Must be an issue with one of the libraries you're using. (You sure you're using https?)
Let me try and get back to you, thanks for the help @mhart.