Kanject.Core.Api.Aws.Extensions
4.0.1
Prefix Reserved
See the version list below for details.
dotnet add package Kanject.Core.Api.Aws.Extensions --version 4.0.1
NuGet\Install-Package Kanject.Core.Api.Aws.Extensions -Version 4.0.1
<PackageReference Include="Kanject.Core.Api.Aws.Extensions" Version="4.0.1" />
<PackageVersion Include="Kanject.Core.Api.Aws.Extensions" Version="4.0.1" />
<PackageReference Include="Kanject.Core.Api.Aws.Extensions" />
paket add Kanject.Core.Api.Aws.Extensions --version 4.0.1
#r "nuget: Kanject.Core.Api.Aws.Extensions, 4.0.1"
#:package Kanject.Core.Api.Aws.Extensions@4.0.1
#addin nuget:?package=Kanject.Core.Api.Aws.Extensions&version=4.0.1
#tool nuget:?package=Kanject.Core.Api.Aws.Extensions&version=4.0.1
Kanject.Core.Api.Aws.Extensions
Kanject.Core.Api.Aws.Extensions adds AWS-specific plumbing for ASP.NET Core services and Lambda functions: loading configuration from AWS Systems Manager Parameter Store, turning PrintInConsole output into single-line JSON that CloudWatch Logs Insights can query, and reading the caller's country code from CDN headers.
Installation
dotnet add package Kanject.Core.Api.Aws.Extensions
Targets .NET 9, .NET 10 and .NET 11. It depends on Amazon.Extensions.Configuration.SystemsManager, AWSSDK.SimpleSystemsManagement and Kanject.Core.Api.Abstractions.
Quick start
using Kanject.Core.Api.Aws.Extensions.PrintInConsole;
using Kanject.Core.Api.Aws.Extensions.Vault.ParameterStore;
var builder = WebApplication.CreateBuilder(args);
#if DEBUG
// Local: path, profile and region come from appsettings (AppSettings section).
builder.AddAwsSystemManagerParameterStore(fetchSecretPathFromAppSettings: true);
#else
// Deployed: path comes from the SECRET_PARAMETER_PATHNAME environment variable.
builder.AddAwsSystemManagerParameterStore();
#endif
builder.Services.AddPrintInConsoleCloudWatch(options => options.ServiceName = "orders-api");
var app = builder.Build();
app.Run();
Parameter Store configuration
AddAwsSystemManagerParameterStore loads every parameter under a path into IConfiguration using Amazon.Extensions.Configuration.SystemsManager. The path prefix is stripped and the remaining / segments become :, so /orders-api/prod/Database/ConnectionString under the path /orders-api/prod/ is read as configuration["Database:ConnectionString"].
Each form exists on both WebApplicationBuilder and IConfigurationBuilder (use the latter in Lambda functions that build configuration without a web host):
| Call | Parameter path from | Credentials and region |
|---|---|---|
AddAwsSystemManagerParameterStore() |
SECRET_PARAMETER_PATHNAME environment variable |
AWS SDK defaults (for example, the Lambda execution role) |
AddAwsSystemManagerParameterStore(fetchSecretPathFromAppSettings: true) |
AppSettings:SecretParameterPathName |
Named profile AppSettings:AwsProfile, region AppSettings:AwsRegion |
AddAwsSystemManagerParameterStore(parameterPath, profile, region) |
The parameterPath argument |
The named profile, and region as a system name such as eu-west-2 |
For the app-settings form, the values are read from the configuration built so far; pass an IConfiguration as the second argument to read them from somewhere else:
{
"AppSettings": {
"SecretParameterPathName": "/orders-api/dev/",
"AwsProfile": "dev",
"AwsRegion": "eu-west-2"
}
}
The app-settings and explicit forms require a named AWS profile, which makes them a fit for local development; in Lambda or containers use the environment-variable form so the SDK's default credential chain applies. The app-settings and explicit forms throw at startup when a required value is missing; the environment-variable form does not check the variable itself, so make sure it is set.
CloudWatch-friendly PrintInConsole
PrintInConsole (from Kanject.Core) writes plain text by default. AddPrintInConsoleCloudWatch() routes it through a handler that writes one JSON object per line — the format CloudWatch Logs Insights discovers fields from automatically — so existing call sites need no changes.
1. Enable the interceptor in the project that makes the calls
<PropertyGroup>
<EnablePrintInConsoleInterceptor>true</EnablePrintInConsoleInterceptor>
</PropertyGroup>
The routing is done by a compile-time interceptor generator from Kanject.Core.Annotations. Only PrintInConsole calls compiled in a project with this property set are routed; calls compiled elsewhere keep the default console output.
2. Register the handler
using Kanject.Core.Api.Aws.Extensions.PrintInConsole;
builder.Services.AddPrintInConsoleCloudWatch(options =>
{
options.ServiceName = "payment-api"; // added to every entry
options.IncludeData = true; // set false to drop the data array
});
The handler is installed by a hosted service when the host starts and removed when it stops; calls made before startup (for example while building configuration) use the default output.
Output
using Kanject.Core.SystemConsole.Extensions;
"Cache performance".PrintInConsole(tag: "Performance", data: new object[] { new { HitRate = 0.94 } });
{"timestamp":"2026-03-20T10:30:02.0000000Z","level":"Information","message":"Cache performance","tag":"Performance","service":"payment-api","data":[{"hitRate":0.94}]}
| Field | Present | Content |
|---|---|---|
timestamp |
Always | UTC, ISO 8601 round-trip format |
level |
Always | Trace, Debug, Information, Warning, Error or Critical |
message |
Always | ToString() of the printed value |
tag |
When a tag is passed | The tag argument |
service |
When ServiceName is set |
The configured service name |
data |
When extra data is passed and IncludeData is true |
The data array, serialized with camel-case property names |
Severity
The interceptor generator infers level at compile time: calls inside a catch block or with an Exception argument become Error, and error/warning/debug keywords in the tag or string literal select the matching level; everything else is Information. Pass a level explicitly to override the inference:
using Kanject.Core.SystemConsole;
using Kanject.Core.SystemConsole.Extensions;
"Error code lookup table loaded".PrintInConsole(ConsolePrintLogLevel.Information);
Example Logs Insights queries
fields @timestamp, level, message, tag, service
| filter level = "Error"
| sort @timestamp desc
| limit 50
stats count(*) as errorCount by service
| filter level = "Error"
| sort errorCount desc
ILogger bridge or CloudWatch JSON?
Kanject.Core also offers services.AddPrintInConsoleLogging(), which forwards PrintInConsole to ILogger. Use that when the application already has logging providers configured; use AddPrintInConsoleCloudWatch() for Lambda functions that write straight to CloudWatch without a logging framework. Don't register both — each replaces the same static handler, and the last one to start wins.
Client country code
using Kanject.Core.Api.Aws.Extensions.Controller;
var country = this.GetClientCountryCode(); // inside a controller action
GetClientCountryCode() returns the first header present among X-Country, CloudFront-Viewer-Country and CF-IPCountry, or null. These headers are only trustworthy when your CDN or load balancer sets or overwrites them — a client can send any of them directly.
Public surface at a glance
| Type or member | Namespace | Purpose |
|---|---|---|
AddAwsSystemManagerParameterStore(...) |
Kanject.Core.Api.Aws.Extensions.Vault.ParameterStore |
Adds Parameter Store as a configuration source |
AddPrintInConsoleCloudWatch(configure) |
Kanject.Core.Api.Aws.Extensions.PrintInConsole |
Routes PrintInConsole to single-line JSON |
PrintInConsoleCloudWatchOptions |
Kanject.Core.Api.Aws.Extensions.PrintInConsole |
ServiceName (default null), IncludeData (default true) |
GetClientCountryCode() |
Kanject.Core.Api.Aws.Extensions.Controller |
Country code from CDN headers, on any ControllerBase |
Related packages
| Package | Role | Availability |
|---|---|---|
Kanject.Core |
PrintInConsole, ConsolePrintLogLevel and the ILogger bridge (AddPrintInConsoleLogging) |
nuget.org |
Kanject.Core.Annotations |
The compile-time PrintInConsole interceptor generator |
nuget.org |
Kanject.Core.Api.Abstractions |
Response models and exceptions (dependency of this package) | nuget.org |
Kanject.Core.Api |
Controllers, exception and tenant middleware (Kanject envelope errors) | nuget.org |
Kanject.Core.ApiV2 |
Controllers, exception and tenant middleware (Problem Details errors) | nuget.org |
License
Licensed under the Kanject Code Libraries License Agreement (KCLLA); the full text ships in this package as LICENSE.md. Organizations whose trailing-twelve-month gross revenue and total funding raised are each below US$250,000 may use it at no cost under the Free Tier. At or above either threshold a commercial license is required — contact commercial@kanjectbusiness.com.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- Amazon.Extensions.Configuration.SystemsManager (>= 7.1.1)
- AWSSDK.SimpleSystemsManagement (>= 4.1.0)
- Kanject.Core.Api.Abstractions (>= 4.0.0)
-
net11.0
- Amazon.Extensions.Configuration.SystemsManager (>= 7.1.1)
- AWSSDK.SimpleSystemsManagement (>= 4.1.0)
- Kanject.Core.Api.Abstractions (>= 4.0.0)
-
net9.0
- Amazon.Extensions.Configuration.SystemsManager (>= 7.1.1)
- AWSSDK.SimpleSystemsManagement (>= 4.1.0)
- Kanject.Core.Api.Abstractions (>= 4.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.3 | 0 | 11/21/2026 |
| 4.0.2 | 78 | 11/18/2026 |
| 4.0.1 | 102 | 11/12/2026 |
| 4.0.0 | 88 | 11/11/2026 |
| 3.13.0 | 127 | 11/5/2026 |
| 3.12.0 | 101 | 11/4/2026 |
| 3.11.0 | 125 | 11/2/2026 |
| 3.10.2 | 173 | 10/22/2026 |
| 3.10.1 | 271 | 10/9/2026 |
| 3.10.0 | 121 | 10/5/2026 |
| 3.9.0 | 119 | 10/2/2026 |
| 3.8.3 | 106 | 10/1/2026 |
| 3.8.2 | 114 | 9/29/2026 |
| 3.8.1 | 126 | 9/27/2026 |
| 3.8.0 | 115 | 9/27/2026 |
| 3.7.7 | 118 | 9/26/2026 |
| 3.7.6 | 146 | 9/7/2026 |
| 3.7.5 | 124 | 8/27/2026 |
| 3.7.4 | 129 | 8/22/2026 |
| 3.7.3 | 143 | 8/10/2026 |
- Requires AWS SDK for .NET 4.1; on net9.0 its System.IO.Hashing 11.0.0 dependency warns that net9.0 is untested.