Provisioning Freeform Configuration via AWS AppConfig & CloudFormation

Allan Chua
ITNEXT
Published in
5 min readApr 16, 2022

--

Freeform configuration is an alternative way of defining feature toggles for applications that require dynamic behavior switching at runtime. Compared to the explicit feature flag definitions, freeform configuration offers a more flexible and expressive way of defining configurations in popular file formats like text/plain, application/json, text/yaml which makes configuration definition easier for DevOps engineers.

In this article, we‘ll explore an automated approach to provisioning freeform configuration that could be used by applications to dynamically toggle machine learning routines.

We’ll use CloudFormation as a medium of expressing AppConfig resources. Do take note that CloudFormation is just one of several ways to automate provisioning of AWS AppConfig resources. Any of the resources that we’re going to provision in this article may also be provisioned through the use of other tools like Terraform, AWS CDK, AWS SDK, AWS CLI and etc.

Target Configuration

The ultimate goal of this provisioning tutorial is to produce a configuration scaffold that represents the diagram above. Basically, we’re aiming to create an AppConfig application resource that contains three environments (dev, uat and prd). Each will have their own freeform configuration profiles inside which will then be used for toggling machine learning inferencing routines.

Application

An AWS AppConfig application is an organizational construct that groups several related settings and environments that could be associated with either a bounded context, microservice or an entire application.

Environments

In the context of AWS AppConfig, environment constructs represent a logical grouping of related configurations for a single deployment environment. In our project, we will create three AppConfig environments which represents dev, uat and prd environments of our business application. All of them are linked to the parent AppConfig application via ApplicationId property.

Configuration Profiles

Configuration profiles are constructs used by AWS AppConfig to identify the location of our configuration data. In our example, we are informing AppConfig that our configuration data is hosted inside AppConfig itself.

We also have two configuration profiles in this example, each representing the enabled & disabled modes for ML inferencing functionality.

Hosted Configuration Versions

Hosted configuration versions are constructs used to define AppConfig hosted freeform configuration data. In our example, we are using application/json formatting but one should take note that its also possible to use text/plain & text/yaml formats.

A more advanced variant of freeform configuration would probably contain more metadata like version, type, algorithm, hyperparameter values, etc.

Custom Deployment Strategy

Deployment strategy constructs are used for defining the properties of a configuration deployment strategy like type, growth factors, total deployment times, baking time. We will be creating a custom one that immediately propagates the freeform configuration without the usage of baking time to keep things simpler.

AppConfig Deployments

The final construct included in our provisioning template is AWS AppConfig deployments (AWS::AppConfig::Deployment). This construct basically stiches up the previous resources defined in our template (applications, environments, configuration profiles, configuration versions and deployment strategies.) This construct is responsible for invoking configurations released to target environments.

Full CloudFormation Template

The full CloudFormation template could be found on this Github repository which contains additional information on how could one deploy this CloudFormation stack on your own AWS accounts.

Deploying the CloudFormation Stack

In order to deploy your CloudFormation stack, use the shell script above and replace the parameters according to your personal goals.

Final Results

As a result, an AWS AppConfig application was created according to the CloudFormation template that we’ve defined.

There are also three environments provisioned under this application. Each representing a logical grouping of configuration for each of our testing environments.

There are also two different profiles used for toggling ML inferencing capabilities of consuming applications.

We have also managed to create a custom deployment strategy on top of pre-configured ones provided by AWS.

As a final result, each of our environments now supports feature toggling via freeform configuration. It could be useful in altering our ML inferencing capabilities during runtime without exerting additional deployment efforts.

Impact on Application Management

Using freeform configuration-based feature toggling, engineering teams can now:

  • Pre-emptively deploy machine learning capabilities without disrupting existing application flow.
  • Dynamically alter machine learning inferencing functions during runtime without exerting effort for refactoring code and running another set of deployments.
  • Reduce risk associated with application downtime or faulty deployments by disabling broken modules.

What’s Next

Now that we have an automated way of provisioning freeform configuration-based feature toggles, we can start consuming this configurations inside NodeJS and Python environments.

Conclusion

Using CloudFormation, its possible to automate the provisioning of freeform configurations on top of AWS AppConfig. Dynamic feature toggling using this approach benefit engineering teams in ways that were previously hard to implement due to the effort required in managing applications.

--

--

CTO @ Premier Fiduciary, Loves AWS, AI, and Software Architecture