# Configuration

Config layers the standard ASP.NET Core way — `appsettings.json` for defaults and structure, `appsettings.<Env>.json` for per-environment overrides — plus one layer on top: the stage environment declared in your manifest. What differs from a hand-rolled AWS setup is *when* the Parameter Store and Secrets Manager values resolve.

```json
// appsettings.json — defaults and structure, committed to git
{
  "AppSettings": {
    "DatabaseNamespace": "prod",
    "AwsRegion": "eu-west-1",
    "EnableHighAvailabilityCache": true
  },
  "CognitoIdentityProviderSettings": {
    "Region": "eu-west-1",
    "ApplicationIdentitySchema": "AppIdentity",
    "UserPartitionKey": "user#"
  }
}
```

## Secrets resolve at deploy, not at cold-start

A stage `env` value is a plain string, a `param:` Parameter Store reference, or a `secret:` Secrets Manager reference. Kanject resolves every reference **once, at deploy**, and writes the result into the function's environment variables. Your service reads them through the ordinary environment-variable configuration provider — ASP.NET Core's `Section__Key` convention maps a flat env var onto a nested config key — so it never calls Parameter Store or Secrets Manager itself, and cold-starts stay fast.

```json
// stages/prod.json — environment values, resolved at deploy
{
  "env": {
    "ASPNETCORE_ENVIRONMENT": "Production",
    "CognitoIdentityProviderSettings__UserPoolId": "param:COGNITO_USER_POOL_ID",
    "CognitoIdentityProviderSettings__ClientId":   "secret:app/prod/cognito#clientId"
  }
}
```

> **No runtime config provider to add:** Because the resolved values are already environment variables at runtime, you do **not** wire a Parameter Store or Secrets Manager provider into `Program.cs` — the default `IConfiguration` already has them. Inspect exactly what a stage resolves to (masked) with `kanject env --env <stage>`.

Only the `param:` / `secret:` *reference* lives in the committed stage file — never the value. See [Core Concepts](https://www.kanject.com/docs/concepts/) for the three env forms and where each resolves, and the [Manifest Reference](https://www.kanject.com/docs/manifest/) for the stage-file schema.

---
_Source: https://www.kanject.com/docs/configuration/ · Kanject Docs_
