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

Add programmatic credential provider for the EC2 client #14

Conversation

Arkatufus
Copy link
Contributor

No description provided.

public override AWSCredentials ClientCredentials { get; } = new AnonymousAWSCredentials();
}

public sealed class Ec2InstanceMetadataCredentialProvider : Ec2CredentialProvider
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this shouldn't be the default? Anonymous will almost always fail for these calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point, i'll change that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

Might want to rename the class too (i.e. change it to anonymous something something), just to clear it up, and add an XML-DOC comment indicating that the instance metadata is the default. Then we should be good to go.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the name of the class from "Default" to "Anonymous" to avoid confusion

Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

LGTM

public abstract AWSCredentials ClientCredentials { get; }
}

public sealed class AnonymousEc2CredentialProvider : Ec2CredentialProvider
Copy link
Member

Choose a reason for hiding this comment

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

LGTM

{
if (!EC2InstanceMetadata.IsIMDSEnabled)
{
_log.Warning("Could not obtain EC2 client credentials because instance metadata is disabled. Using anonymous credentials instead.");
Copy link
Member

Choose a reason for hiding this comment

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

LGTM

#### Ec2InstanceMetadataCredentialProvider
`Ec2InstanceMetadataCredentialProvider` will try its best to retrieve the correct session
credential provider using the AWS EC2 instance metadata API. It will return an `AnonymousAWSCredential`
if it fails to obtain a credential from the metadata API service.
Copy link
Member

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

Choose a reason for hiding this comment

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

We should probably add a link back to the relevant AWS documentation here though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its on the bottom of the readme

@Aaronontheweb Aaronontheweb merged commit 5d6d1b2 into akkadotnet:dev Aug 2, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants