AWS AppConfig deployment strategies, bake time and validators
An AppConfig deployment strategy sets how fast a configuration reaches its targets and how long AppConfig keeps watching afterwards. The AWS AppConfig User Guide says that if a CloudWatch alarm on the environment fires during the deployment or its bake time, AppConfig rolls the configuration back. Validators check the configuration data before it is deployed.
What does a deployment strategy define?
The deployment type is linear or exponential. Linear moves in equal increments of the step percentage, spread evenly over the deployment time. Exponential uses the formula G*(2^N), so a growth factor of 2 reaches 2 percent of targets, then 4 percent, then 8 percent, and so on.
Deployment time is the window over which AppConfig deploys in intervals. It is not a timeout. Bake time is how long AppConfig monitors CloudWatch alarms after the configuration has reached 100 percent of targets, before it treats the deployment as complete. An alarm during bake time triggers a rollback.
Which predefined strategy fits?
AppConfig.Linear20PercentEvery6Minutes deploys to 20 percent of targets every six minutes for 30 minutes, then monitors alarms for 30 minutes. AppConfig.Canary10Percent20Minutes deploys exponentially with a 10 percent growth factor over 20 minutes, then monitors for 10 minutes. AWS recommends both for production.
AppConfig.AllAtOnce deploys to all targets immediately and still monitors alarms for 10 minutes. AppConfig.Linear50PercentEvery30Seconds deploys to half of the targets every 30 seconds with a 1-minute bake time. AWS recommends it only for testing or demonstrations.
How do rollback and validation work?
Alarms are attached to the environment, which is a logical group of targets such as a Production environment. AppConfig needs an IAM role that lets it call cloudwatch:DescribeAlarms. If one of the listed alarms goes into the ALARM state during a deployment, AppConfig rolls the configuration back.
A configuration profile can have up to two validators. A JSON Schema validator is supported for free-form configurations. A Lambda function validator is supported for feature flags and free-form configurations, and receives the configuration content as a base64-encoded string.
AppConfig decides whether a Lambda validator failed by checking for the X-Amz-Function-Error header in the response. Lambda sets that header when the function throws an exception. A function that finishes normally counts as a successful validation, whatever it returns.
Where the exam catches people
Believing a Lambda validator fails a configuration by returning false: AppConfig looks for a function error, so the function must throw an exception.
Believing AppConfig.AllAtOnce has no rollback: it still monitors alarms for a 10-minute bake time.
Believing bake time starts when the deployment starts: it starts after the configuration has reached 100 percent of targets.
Believing deployment time is a timeout: it is the window over which the deployment is processed in steps.
Believing alarms are attached to the deployment strategy: they are configured on the environment, with an IAM role AppConfig can use to read them.