AWS SystemManager and MassTransit

I am configuring my IConfiguration like this:

var configuration = new ConfigurationBuilder()
    .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
    .AddJsonFile($"appsettings.{HostingEnvironment}.json", optional: true)
    .AddEnvironmentVariables()
    .AddSystemsManager("myapp/development") <--- AWS secrets
    .AddUserSecrets<Program>()
    .Build();

The secrets discovered by the systems manager are hidden from ‘normal’ configuration providers, so I can’t access the secrets directly.

How do I configure MassTransit to use these AWS settings during configuration? It should work locally as well as running on the server.

bus.UsingAmazonSqs((context, cfg) => 
{
    cfg.Host("eu-west-2", h => ????? );
  • .NET6
  • MassTransit 8.1.2

Leave a Comment