Sunday, 4 June 2017

AWS: How to get and use credentials for an IAM Role in NodeJS/ExpressJS

For my ExpressJS/NodeJS app server, which uses its own AWS account, I need to access resources in a different AWS account. I have set up an IAM Role that should allow my server to access this other AWS account.

But the AWS documentation on how to get the credentials using this IAM Role are a little thin.

It seems like I might want to use AWS.STS's assumeRole() to get back the credentials. Is that the best way to get credentials for this Role?

And if I use assumeRole(), then once I receive the credentials in its callback, how do make use of them so that subsequent calls to DynamoDB and S3, for example, will operate on this different AWS account? Would I set the credentials into AWS.config.credentials, for example?

Suggestions and code examples would be most welcome!

Thanks. -Allan



via lagouyn

No comments:

Post a Comment