Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support use of IAM roles on EC2 instance to avoid passing credentials #262

Open
boutell opened this issue Dec 10, 2014 · 16 comments
Open

Support use of IAM roles on EC2 instance to avoid passing credentials #262

boutell opened this issue Dec 10, 2014 · 16 comments

Comments

@boutell
Copy link
Contributor

boutell commented Dec 10, 2014

The key and secret are currently hard requirements, but AWS also supports configuring an EC2 instance to be trusted automatically. Here's how it is done with the official AWS SDK for node:

http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html

It would be helpful to have this feature in knox as well.

@dancet
Copy link

dancet commented Dec 17, 2014

I'd love to see this also.

@makered
Copy link

makered commented Feb 3, 2015

yes please!

@russel1237
Copy link

👍

1 similar comment
@markstos
Copy link

+1

@domenic
Copy link
Contributor

domenic commented Mar 14, 2015

Pull requests welcome, +1s discouraged.

@boutell
Copy link
Contributor Author

boutell commented Mar 16, 2015

It would be very helpful to have a response to this question before investing too much coding time at this point:

#263

@boutell
Copy link
Contributor Author

boutell commented Mar 16, 2015

(I don't mean to be obnoxious. I greatly appreciate knox and the value I've received from it.)

@garrettheel
Copy link

+1

@tonymet
Copy link

tonymet commented Mar 16, 2017

I created a wrapper knox-ec2-role to fetch the creds & secure token from EC2 metadata. You can use your existing knox code just call the authenticate method beforehand.

e.g.

knoxec2.authenticate({bucket: 'my-bucket'}, {timeout: 5000})
  .then(function(client){
    var object = { foo: "bar" };
    var string = JSON.stringify(object);
    var req = client.put('/test/obj.json', {
        'Content-Length': Buffer.byteLength(string)
      , 'Content-Type': 'application/json'
    });
    req.on('response', function(res){
      if (200 == res.statusCode) {
        console.log('saved to %s', req.url);
      }
    });
    req.end(string);
  })

@markstos
Copy link

@tonymet Thanks! Maybe the knox developers can merge a version of your code.

@markstos
Copy link

@mattbriancon Good tip. This seems worth adding to the Knox documentation. Knox users may also be interested to now about the resolvePromise() method which provides a Promise-based API as an alternative to the callback API: https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CredentialProviderChain.html#resolvePromise-property

@mattbriancon
Copy link

@markstos removed my post because I spoke too soon 🤐. The credentials were accepted but I was fooled by a different request to S3. The access keys only work with an accompanying session token but knox won't accept it anymore. Switching everything over to use the aws-sdk.

@markstos
Copy link

@mattbriancon From reviewing my own package.json, it looks we switched from Knox to aws-sdk some time ago as well. I'm going to unsubscribe from this thread.

@boutell
Copy link
Contributor Author

boutell commented Oct 26, 2018

Unsubscribed as well, uploadfs switched to the aws-sdk a while back. Others seem interested though so I won't close the ticket.

@markstos
Copy link

Oh Hello, @boutell I was a Wusage customer (via Summersault) years ago. I'm surprised it's missing from the list of things you are known for: https://punkave.com/about/tom-boutell 😉 Our hosting accounts often used for disk space for Wusage stats then the actual content, but we loved the graphs.

@boutell
Copy link
Contributor Author

boutell commented Oct 29, 2018

Thanks for the blast from the past (:

As to those wondering what to do after knox, for what it's worth the AWS SDK has been trouble-free in uploadfs. Which is itself worth looking at if it covers your use case, since it also has drivers for local file storage and azure built in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants