AWS AppConfig and Environment-Specific Configuration
Overview
Applications need settings that change between environments (dev, test, prod) and sometimes at runtime: log levels, feature switches, rate limits, endpoint URLs. Baking these into code forces a redeploy for every change. AWS AppConfig, a capability of Systems Manager, lets you validate, deploy gradually and roll back configuration and feature flags without redeploying code.
Think of AppConfig as a dimmer switch with a safety fuse. You do not flip a light from off to full brightness for every user at once; you raise it slowly, watch for trouble and automatically drop it back if an alarm trips.
The exam compares AppConfig with Parameter Store, Secrets Manager and environment variables, and expects you to know how to deliver configuration to Lambda and containers safely.
Key Concepts
- An AppConfig application contains environments (dev, prod), configuration profiles (freeform or feature flags) and hosted or external configuration sources.
- Sources include the AppConfig hosted store, S3, Parameter Store, Secrets Manager, SSM documents and CodePipeline.
- Validators (JSON Schema or a Lambda function) reject bad configuration before deployment.
- Deployment strategies define growth and bake time: AllAtOnce, Linear (for example 20% every 6 minutes), Exponential, or custom.
- CloudWatch alarms attached to an environment trigger an automatic rollback during deployment.
- The AppConfig Agent / Lambda extension caches configuration locally and polls for updates so applications avoid API calls on each request.
- Feature flags support boolean toggles with attributes and multi-variants for targeted rollout.
- Parameter Store is for simple key-value configuration; Secrets Manager for rotating secrets; AppConfig for validated, gradually deployed config.
Detailed Notes
Choosing a configuration mechanism
| Option | Best for | Limits and notes |
|---|---|---|
| Environment variables | Static values per deployment | Redeploy to change; visible in console |
| SSM Parameter Store | Simple hierarchical config, SecureString | Standard 4 KB, advanced 8 KB; no gradual deployment |
| Secrets Manager | Credentials with rotation | Priced per secret |
| AppConfig | Runtime-changeable config and feature flags | Validators, rollout strategy, alarm rollback |
| Stage variables | API Gateway stage routing | Small values only |
Hierarchy in Parameter Store often follows /app/env/key, for example /orders/prod/db-url, and an IAM policy can limit each role to its environment path.
Creating AppConfig resources
aws appconfig create-application --name orders
aws appconfig create-environment --application-id abc123 --name prod \
--monitors AlarmArn=arn:aws:cloudwatch:eu-west-1:111122223333:alarm:orders-5xx,AlarmRoleArn=arn:aws:iam::111122223333:role/AppConfigMonitor
aws appconfig create-configuration-profile --application-id abc123 --name flags \
--location-uri hosted --type AWS.AppConfig.FeatureFlags
aws appconfig start-deployment --application-id abc123 --environment-id env1 \
--deployment-strategy-id strat1 --configuration-profile-id prof1 --configuration-version 3
A deployment pushes a numbered configuration version through the chosen strategy. If a monitored alarm goes into ALARM during the rollout or bake period, AppConfig rolls the deployment back.
Feature flag document
{
"version": "1",
"flags": {
"new-checkout": {
"name": "new-checkout",
"attributes": { "percentage": { "constraints": { "type": "number", "minimum": 0, "maximum": 100 } } }
}
},
"values": { "new-checkout": { "enabled": true, "percentage": 10 } }
}
Reading config from Lambda with the extension
Add the AWS AppConfig Lambda extension layer. It polls in the background and caches the result, so reads are a fast local HTTP call.
import json, urllib.request
def get_flags():
url = "http://localhost:2772/applications/orders/environments/prod/configurations/flags"
return json.loads(urllib.request.urlopen(url).read())
def handler(event, context):
flags = get_flags()
if flags["new-checkout"]["enabled"]:
return new_flow(event)
return old_flow(event)
The function role needs appconfig:StartConfigurationSession and appconfig:GetLatestConfiguration. Outside Lambda (ECS, EC2) use the AppConfig Agent sidecar or the appconfigdata API directly with a configuration token and the poll interval it returns.
Per-environment configuration with IaC
Keep one template and inject differences through parameters or mappings. With SAM:
Parameters:
Env: { Type: String, AllowedValues: [dev, test, prod] }
Mappings:
Sizing:
dev: { Memory: 256, Concurrency: 5 }
prod: { Memory: 1024, Concurrency: 100 }
Resources:
Fn:
Type: AWS::Serverless::Function
Properties:
MemorySize: !FindInMap [Sizing, !Ref Env, Memory]
Environment:
Variables:
CONFIG_PATH: !Sub "/orders/${Env}/"
Deploy with sam deploy --config-env prod, where samconfig.toml holds per-environment parameter overrides. Use separate accounts for production when possible and pass the environment name, never hard-coded endpoints.
Rollouts and rollback
For risk-sensitive changes use a linear strategy with bake time, for example 10 percent every 10 minutes then 10 minutes baking, with an alarm on error rate. Because configuration updates do not touch code, you can disable a feature in minutes by deploying a new version with the flag off, without a code rollback.
Combining with Parameter Store
Many teams store secrets in Secrets Manager, plain settings in Parameter Store, and feature toggles in AppConfig. AppConfig can also use a Parameter Store or Secrets Manager parameter as its source, adding validation and phased rollout on top.
Real World Example
A streaming service wanted to roll out a new recommendation algorithm. They stored a feature flag in AppConfig, validated it with a JSON Schema, and deployed it with a linear strategy (10 percent every 10 minutes) while a CloudWatch alarm on playback errors guarded the rollout. When latency crept up at 40 percent, AppConfig rolled back automatically, and no code release or redeploy was required.
Architecture Diagram
AppConfig validates, rolls out in steps and rolls back on alarm.
- 1A new configuration version is validated against a schema.
- 2AppConfig deploys it gradually using the deployment strategy.
- 3Applications fetch it through the local extension cache.
- 4A firing alarm stops the rollout and rolls back.
Best Practices
- ✓Use AppConfig for runtime feature flags and validated configuration changes.
- ✓Attach CloudWatch alarms to environments so bad config rolls back automatically.
- ✓Fetch config through the extension or agent to reduce API calls and latency.
- ✓Use parameters and mappings so one template serves all environments.
- ✓Scope IAM per environment path (
/app/prod/*) and keep secrets in Secrets Manager.
Common Interview Questions
Exam Tips
DVA-C02 focus
- 'Roll out a configuration change gradually with rollback' means AWS AppConfig.
- 'Feature flags without redeploy' also points to AppConfig.
- Hierarchical plain settings (
/app/env/key) means Parameter Store. - Per-environment values in IaC come from parameters, mappings and samconfig environments.
Finished this lesson?
0 of 46 lessons done · 0% of the course

