Chapter 7. Configuring Stack Instances
Using a single stack code project makes it easier to maintain multiple consistent instances of infrastructure, as described in “Pattern: Reusable Stack”. However, you often need to customize different instances of a stack. For example, you might size a cluster with fewer servers in a development environment than in production.
Here is an example of stack code that defines a container hosting cluster with configurable minimum and maximum numbers of servers:
container_cluster
:
web_cluster-${environment}
min_size
:
${cluster_minimum}
max_size
:
${cluster_maximum}
You pass different parameter values to this code for each environment, as depicted in Figure 7-1.
Stack tools such as Terraform and CloudFormation support multiple ways of setting configuration parameter values. These typically include passing values on the command line, reading them from a file, and having the infrastructure code retrieve them from a key-value store.
Teams managing infrastructure need to decide how to use these features to manage and pass configuration values to their stack tool. It’s essential to ensure the values are defined and applied consistently to each environment.
Get Infrastructure as Code, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.