AWS Lambda .NET Core ENV variables naming

Viewed 86

I have a .NET Core AWS Lambda function and I need to specify log level for specific classes or namespaces and I need to do it via Environment Variable: Logging__LogLevel__Out.Internal.Class with Value debug

However, I am getting an validation error:

The key must start with a letter and can only contain letters, numbers, and underscores.

Is there any workaroung?

Thanks

1 Answers

As an alternative you can load the configuration from a service like AWS Parameter Store. That way you can store your application configuration as a string (or JSON if you multiple properties) and retrieve it once in your function initialization. It will have a small impact on cold start performance, but it will be negligible.

The added benefit of this, is that you can update your configuration without changing your function code.

If you're using standard parameters and standard throughput it's also completely free.

https://aws.amazon.com/systems-manager/pricing/ https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html https://www.rahulpnath.com/blog/aws-parameter-store/

There's also AWS AppConfig if you want a slightly more advanced use case (CICD for your configuration, feature flags) but for simple use cases parameter store is great.

Related