2020IP / TwentyTwenty.Storage

A cross-cloud storage abstraction
Other
100 stars 26 forks source link

Added fallback in case of IAM Roles on AWS #22

Closed imperugo closed 5 years ago

imperugo commented 5 years ago

If you are hosting your application into AWS cloud (ECS, EC2 ...) you don't need to add the credentials in order to work with S3 because the permission is managed by IAM Roles (here more info https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html).

Right now the library work with this flow:

1) Profile 2) Key + Secret 3) Environment Variables

I've added another step (latest one) for IAM Role, so the new flow is this:

1) Profile 2) Key + Secret 3) Environment Variables 4) Fallback to CredentialFactory

Let me know if there is something you don't like or any doubt (personally I don't like the try/catch for the Environment variables but I didn't find a better solution).

Thanks

ericgreenmix commented 5 years ago

@imperugo You could actually remove the code for the EnvironmentVariablesAWSCredentials all together. The FallbackCredentialsFactory.GetCredentials() implicitly fallsback with that.

https://github.com/aws/aws-sdk-net/blob/master/sdk/src/Core/Amazon.Runtime/Credentials/FallbackCredentialsFactory.cs#L54

imperugo commented 5 years ago

Hi @ericgreenmix Just pushed an update.

ericgreenmix commented 5 years ago

@imperugo TwentyTwenty.Storage 2.10.0 is published to Nuget. Will probably be a minute before it gets indexed by them. Thanks for your contribution!

imperugo commented 5 years ago

Thanks.

Superfast!