Closed oleg31337 closed 3 years ago
This is tricky, at the moment the AWS service is initiated once per node, however passing the creds in this way would initiate it for every message.
Could potentially check for the existance of these three attributes in the message and re-initialise only if one (or more) are present.
Yeah that what I do in the code above, if it exists then re-set the region/key/secrets. I have tested it inside your code and it works. Though I'm not really great with Javascript and code must be beautifulized :-)
Turns out it only needed two lines of code (1 new, and one minor change).
Instead of making it credential specific, you can now pass an AWSConfig option which can include new credentials or other config items as needed.
Allow passing region and credentials with a message something like that:
var awsregion=node.region; var awskey=node.accessKey; var awssecret=node.secretKey; if (typeof msg.region !== 'undefined' && msg.region !== null && msg.region !== ""){ awsregion=msg.region.toLowerCase(); } if (typeof msg.awskey !== 'undefined' && msg.awskey !== null && msg.awskey !== "" && typeof msg.awssecret !== 'undefined' && msg.awssecret !== null && msg.awssecret !== ""){ awskey=msg.awskey; awssecret=msg.awssecret; } var awsService = new AWS.EC2( { 'region': awsregion, 'accessKeyId': awskey, 'secretAccessKey': awssecret } );