Skip to content

Feature/credential provider imds #26

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

Merged
merged 2 commits into from
Jun 27, 2017
Merged

Feature/credential provider imds #26

merged 2 commits into from
Jun 27, 2017

Conversation

jeskew
Copy link
Contributor

@jeskew jeskew commented Jun 14, 2017

Spun off from #5.

This PR adds credential providers that read from the IMDS on EC2 instances and ECS containers. These two providers are bundled together because most of the code pertains to HTTP/translating IMDS format to the SDK's credential format, and that logic does not change from EC2 to ECS.

@jeskew jeskew requested review from awood45 and chrisradek June 14, 2017 00:24
@jeskew jeskew mentioned this pull request Jun 14, 2017
5 tasks
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same general comments about setting target to ES5, and importHelpers: true if using ES2015 features like class/async

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the promises in the CredentialProvider interface, the only ES2015 features in use appeared in tests. I'll replace those with ES5-compatible structures.

@@ -0,0 +1,35 @@
export const DEFAULT_TIMEOUT = 1000;
// TODO I think this should be 0 (in line with other SDKs) and not 3 (in line with JS v2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we updated it to be 3 to combat the 'brownouts' we sometimes saw in EC2. To be fair, I think Joyce also added the logic to make sure we weren't making multiple calls to the metadata service in parallel at the same time, so retries might have been overkill.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The memoize function should have the same effect in V3, as a memoized credential provider will always return the same promise until the underlying credentials are within 5 minutes of their expiration time. Would you be OK with setting retries to 0 by default (but still leaving the code path in place)? Users would still be able to configure the number of retries if they wanted to, and we wouldn't need to push out a big code change (just a change to this constant) if we needed to reintroduce retries.


const chunks: Array<Buffer> = [];
res.on('readable', () => {
chunks.push(res.read());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling read() on a stream will return null when there's nothing else to read. With that in mind, we shouldn't push null onto the array of Buffers since Buffer.concat will throw an error if it encounters null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we don't see any benefit from using the read event here. I'll replace it with the data event.

Copy link
Contributor

@chrisradek chrisradek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@jeskew jeskew merged commit 885bf1b into aws:master Jun 27, 2017
@jeskew jeskew deleted the feature/credential-provider-imds branch June 27, 2017 19:27
trivikr referenced this pull request in trivikr/aws-sdk-js-v3 Dec 10, 2018
@lock
Copy link

lock bot commented Sep 26, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants