Skip to content

Make IAMAWSProviderExample work again #1037

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 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading