Skip to content

Ability to reload AWSOptions after ASP.NET Core Lambda Startup #210

@IgorPietraszko

Description

@IgorPietraszko

The Question

I am enhancing an existing ASP.NET Core Lambda solution to add multi-tenant support. Our multitenant setup would use the same codebase (front-end, ANguar, oaded from S3 buckets and back-end, .NET Lambdas) but separate database (either by schema, physical database or physical cluster - depnding on the client).

Per tenant requests would be recognized by incoming host since each client would have their own domain (or be mapped to one of our tenant-specific subdomains). Configuration for our application resides in AWS Parameter Store and would be composed of a Common section (/myapplication/Commmon) which would contain mappings between Hosts and Logical Tenant Names. In addition, there would be tenant-specific sections, for each configured tenant, that would contain tenant-specific application configuration values (/myapplication/tenantA/, /myapplication/tenantB/).

Processing piepeline in the ASP.NET Core 3.1 application would contain custom middleware which would do the initial mapping of Host to Tenant and then load the appropriate tenant specific configuration section.
I have tried it out in a local environment and al works great. Next step is to install in in AWS and make it work which I doubt should be an issue.

One problem I have noticed is that AWSOptions are loaded in the ConfigureServices section of my ASP.NET Core app while our middleware does not run until the next Configure section. AWSOptions are loaded from "the base" configuration "key (e.g. /myapplication/AWS/UserPoolClientId) and while I have tried to reload it from a tenant-specific section using this construct:

configuration.Bind($"{tenantName}:AWS", awsOptions.Value);

But it does not seem to work.

My general question is whether there is a way to reload AWSOptions to support different Congito (and other AWS service) on a per-client/tenant basis rather than relying on the AWSOptions configured at the "base" level. Alternatively, is there a way to lazily configure Congito (or other AWS Services) to delay configuration until the client is known.

Environment

  • Build Version: 2.2.2
  • OS Info: Compiled on Ubuntu 20.04, runtime set to linux-x64
  • Build Environment: Azure pipelines (pool Ubuntu 20.04, runtime set to linux-x64)
  • Targeted .NET Platform: ASP.NET Core 3.1

This is a ❓ general question

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions