Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/validate-pr-title.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
ci
github
core
docs
requireScope: false
subjectPattern: ^[a-z].*
subjectPatternError: Subject must start with lowercase letter
37 changes: 31 additions & 6 deletions docs/guides/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,37 @@ shutdown windows, serializer choices, etc.). This guide covers both layers.

## How Configuration Is Built

`LambdaApplication.CreateBuilder()` wires up the standard .NET defaults:

1. `appsettings.json` (optional) in the application root.
2. `appsettings.{Environment}.json` (optional) based on `DOTNET_ENVIRONMENT`/`ASPNETCORE_ENVIRONMENT`.
3. User secrets (Development only).
4. Environment variables (`AWS_`, `DOTNET_`, and general variables).
`LambdaApplication.CreateBuilder()` wires up the standard .NET defaults unless you pass
`new LambdaApplicationOptions { DisableDefaults = true }`. When defaults are enabled, configuration
providers are added in the following order (later entries override earlier ones):

1. Environment variables prefixed with `AWS_` (Lambda metadata such as `AWS_LAMBDA_FUNCTION_NAME`).
2. Environment variables prefixed with `DOTNET_` (host defaults such as `DOTNET_ENVIRONMENT` or `DOTNET_CONTENTROOT`).
3. `appsettings.json` (optional) in the application root.
4. `appsettings.{Environment}.json` (optional) based on `DOTNET_ENVIRONMENT`.
5. User secrets (Development only, resolved from the entry assembly).
6. All remaining environment variables (no prefix filter).

!!! warning "`ASPNETCORE_` Prefixed Environment Variable"
Enviroment variables with the `ASPNETCORE_` prefix are not automatically loaded by `CreateBuilder()` and must be added manually. As such, the enviroment cannot be set using the `ASPNETCORE_ENVIRONMENT` environment variable.

To load environment variables prefixed with `ASPNETCORE_` after calling `CreateBuilder()`, you can add the following code:

```csharp
var builder = LambdaApplication.CreateBuilder();
builder.Configuration.AddEnvironmentVariables("ASPNETCORE_");
```

If you need to use `ASPNETCORE_` prefixed environment variables when creating the `LambdaApplicationBuilder`, you can add the following code:

```csharp
var configuration = new ConfigurationManager();
configuration.AddEnvironmentVariables("ASPNETCORE_");

var builder = LambdaApplication.CreateBuilder(
new LambdaApplicationOptions { Configuration = configuration }
);
```

The builder also binds the `AwsLambdaHost` section (from JSON or environment variables) into
`LambdaHostOptions` so framework settings can live next to your app configuration.
Expand Down
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
title: ""
---

# Build AWS Lambda Functions with .NET Hosting Patterns

[![Main Build](https://github.com/j-d-ha/aws-lambda-host/actions/workflows/main-build.yaml/badge.svg)](https://github.com/j-d-ha/aws-lambda-host/actions/workflows/main-build.yaml)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"commandName": "Project",
"environmentVariables": {
"AWS_LAMBDA_RUNTIME_API": "localhost:5050",
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"AWS_LAMBDA_LOG_FORMAT": "JSON",
"AWS_LAMBDA_LOG_LEVEL": "DEBUG"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"commandName": "Project",
"environmentVariables": {
"AWS_LAMBDA_RUNTIME_API": "localhost:5050",
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"AWS_LAMBDA_LOG_FORMAT": "JSON",
"AWS_LAMBDA_LOG_LEVEL": "DEBUG"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"commandName": "Project",
"environmentVariables": {
"AWS_LAMBDA_RUNTIME_API": "localhost:5050",
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"AWS_LAMBDA_LOG_FORMAT": "JSON",
"AWS_LAMBDA_LOG_LEVEL": "DEBUG"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"commandName": "Project",
"environmentVariables": {
"AWS_LAMBDA_RUNTIME_API": "localhost:5050",
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"AWS_LAMBDA_LOG_FORMAT": "JSON",
"AWS_LAMBDA_LOG_LEVEL": "DEBUG"
}
Expand Down
3 changes: 3 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ markdown_extensions:
- def_list
- pymdownx.tasklist:
custom_checkbox: true
- toc:
permalink: true
permalink_title: Anchor link to this section for reference

watch:
- ./docs/
Expand Down
9 changes: 8 additions & 1 deletion tasks/LocalDevTasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,11 @@ tasks:
desc: Start the AWS Lambda test tool
silent: true
cmds:
- dotnet lambda-test-tool start --lambda-emulator-port 5050
- dotnet lambda-test-tool start --lambda-emulator-port 5050

run-docs:
desc: Run MKDocs server locally
silent: true
cmds:
- uv sync
- uv run mkdocs serve --livereload
Loading