Skip to content

Commit

Permalink
Make IAMAWSProviderExample work again (#1037)
Browse files Browse the repository at this point in the history
* docs: fix IAMAWSProvider example

* refactor: fix naming in AWSEnvironmentProviderExample

* style(cases): remove tabs from IAMAWSProviderExample
  • Loading branch information
ddudda174 authored Mar 26, 2024
1 parent 922525b commit 2a9ca2a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Minio.Examples/Cases/AWSEnvironmentProviderExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public static async Task Run()
}
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 changes: 7 additions & 5 deletions Minio.Examples/Cases/IAMAWSProviderExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -44,7 +46,7 @@ public static async Task Run()
}
catch (MinioException me)
{
Console.WriteLine($"[Bucket] IAMAWSProviderExample example case encountered Exception: {me}");
Console.WriteLine($"[Bucket] IAMAWSProviderExample example case encountered MinioException: {me}");
}
catch (Exception e)
{
Expand Down

0 comments on commit 2a9ca2a

Please sign in to comment.