Search code examples
c#.net-corehealth-check

How to use AWS S3 health check method provided by AspNetCore.Diagnostics.HealthChecks library


AWS S3 health check is one of the built-in health check services provided by .NET Core. It is available in AspNetCore.HealthChecks.Aws nuget package and presumably can be used like the following code snippet:

public void ConfigureServices(IServiceCollection services)
{
  services.AddHealthChecks().AddS3("WHAT SHOULD GO HERE");
}

After searching a lot, I could not find an example or a sample displaying its usage, even on Microsoft's website.

This is a ASP.NET Core Web API project written in c#.


Solution

  • For starters, AspNetCore.HealthChecks.Aws is a third party library and certainly isn't provided by Microsoft.

    Looking at the code for the AddS3 extension method, it seems that you're expected to provide a configuration for S3BucketOptions:

    services.AddHealthChecks().AddS3(bucketOptions => 
    {
        bucketOptions.AccessKey = "hello";
        // etc
    });
    

    Source for S3BucketOptions