Browse Source

Make IAMAWSProviderExample work again (#1037)

* docs: fix IAMAWSProvider example

* refactor: fix naming in AWSEnvironmentProviderExample

* style(cases): remove tabs from IAMAWSProviderExample
pull/1040/head
Daniel Dudda 1 year ago
committed by GitHub
parent
commit
2a9ca2a11a
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      Minio.Examples/Cases/AWSEnvironmentProviderExample.cs
  2. 12
      Minio.Examples/Cases/IAMAWSProviderExample.cs

4
Minio.Examples/Cases/AWSEnvironmentProviderExample.cs

@ -42,11 +42,11 @@ public static class AWSEnvironmentProviderExample
}
catch (MinioException me)
{
Console.WriteLine($"[Bucket] IAMAWSProviderExample example case encountered Exception: {me}");
Console.WriteLine($"[Bucket] AWSEnvironmentProviderExample example case encountered MinioException: {me}");
}
catch (Exception e)
{
Console.WriteLine($"[Bucket] IAMAWSProviderExample example case encountered Exception: {e}");
Console.WriteLine($"[Bucket] AWSEnvironmentProviderExample example case encountered Exception: {e}");
}
}
}

12
Minio.Examples/Cases/IAMAWSProviderExample.cs

@ -26,14 +26,16 @@ public static class IAMAWSProviderExample
// Establish Credentials with AWS IAM Credentials
public static async Task Run()
{
var provider = new IAMAWSProvider();
using var minioClient = new MinioClient()
var minioClient = new MinioClient()
.WithEndpoint("s3.amazonaws.com")
.WithSSL()
.WithCredentialsProvider(provider)
.WithCredentials("fake_access", "fake_secret") // still required, but can be set to any valid string
.WithRegion("us-west-2")
.Build();
provider = provider.WithMinioClient(minioClient);
// IAMAWSProvider should be assigned "after" the minio client has been build
minioClient = minioClient.WithCredentialsProvider(new IAMAWSProvider(minioClient.Config.Endpoint, minioClient));
try
{
var statObjectArgs = new StatObjectArgs()
@ -44,7 +46,7 @@ public static class IAMAWSProviderExample
}
catch (MinioException me)
{
Console.WriteLine($"[Bucket] IAMAWSProviderExample example case encountered Exception: {me}");
Console.WriteLine($"[Bucket] IAMAWSProviderExample example case encountered MinioException: {me}");
}
catch (Exception e)
{

Loading…
Cancel
Save