I have a requirement to expose a Web API using Autofac as the IoC container in the AWS Lambda serverless environment.
The issue is that is seems there is no way to use Autofac as AWS expose the IWebHostBuilder in their preconfigured entry point (the LambdaEntryPoint class): -
protected override void Init(IWebHostBuilder builder)
{
builder.UseStartup<Startup>();
}
Testing locally works fine as the LocalEntryPoint class looks like this: -
public class LocalEntryPoint
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.UseStartup<Startup>();
});
}
}
Notice the use of IHostBuilder using the methods described here https://autofaccn.readthedocs.io/en/latest/integration/aspnetcore.html#asp-net-core-3-0-and-generic-hosting
Can anyone suggest a way round this?