DOI: 10.5281/zenodo.14768039
title: IaC Cost Patterns

description: IaC Cost Patterns

This is a collection of patterns and antipatterns that support managing cost in Infrastructure as Code artifacts of cloud software deployments. It is intended to be a living catalog, open to community contributions.

The catalog is available at search-rug.github.io/iac-cost-patterns and is based on the patterns.yml file. The catalog includes references and occurrences in commits.

Catalog




Type
Name
Description


Pattern
Budget
Use budgets to receive alerts about charged and forecasted costs and control spending.


Pattern
Spot instances
Use spot instances to run interruptible workloads for significant cost savings compared to regular instances.


Pattern
Object storage lifecycle rules
Define lifecycle rules for object storage to move objects to cheaper storage or drop them entirely.


Pattern
Cost report
Cost report elements can be used to obtain information on the actual spendings over a period of time.                           


Pattern
Preventative Template
Templates with predefined configurations that enforce cost-optimizing methods can proactively manage and reduce future expenses.


Antipattern
Expensive instance
Compute instances are often overprovisioned even when a cheaper instance would suffice.


Antipattern
Old generation
Using newer resource generations gives similar performance for lower cost.


Antipattern
Expensive storage type
More expensive storage types are often used even when cheaper storage types would be sufficient.


Antipattern
Expensive network resource
Network resources like NAT gateways, elastic IP addresses and subnets tend to be expensive while not being strictly needed.


Antipattern
Overprovisioned resources
Resources like RAM, storage and CPU utilization are often overprovisioned even when lower values are acceptable.


Antipattern
AWS - Expensive DynamoDB
AWS DynamoDB tables often use features that carry cost but are not required,especially for infrequently accessed tables.


Antipattern
Expensive monitoring
Monitoring solutions are expensive and might not be needed.




Complete Dataset

The patterns and antipatterns were discovered through thematic analyses, as documented under Dataset History. The dataset consists mainly of:



patterns.yml - The final set of patterns and antipatterns.

codes.yml - The complete set of codes used in the analysis.

indicators.yml - The complete set of analyzed commits.


Dataset History

v1.0 - May 2024

The first set of patterns was extracted using Thematic Analysis on 499 cost-related commits that modify Terraform IaC files from 403 repositories. The set included commits up to 2022 and were collected as part of a prior study.

During the analysis, 128 codes were defined. One code is used to document "no cost change", while the remaining 127 codes indicate cost-saving or cost-increasing actions. Of the 499 commits, 342 contained at least one cost-related code, while 179 were coded with "no cost change".

After validation, 50 codes were integrated into 3 and 7 themes representing patterns and antipatterns respectively, while the remaining 67 codes were discarded due to lack of occurrences. In total, 237 out of 342 commits contain at least one occurrence of an (anti)pattern. The dataset did not include the commits that were coded with "no cost change" (fixed in v2.0).

v1.1 - July 2024

The set of analyzed Terraform commits was updated to include commits up to June 2024 from the previously analyzed repositories. As a result, 23 new commits (from 15 repositories) were identified as containing codes indicating cost-saving or cost-increasing actions. The new commits were analyzed using the same set of codes and themes as in v1.0. No new codes were necessary, and no new (anti)patterns were identified.

v2.0 - July 2024

The dataset and its format were updated to include more details, allowing to document commits that were coded with "no cost change", and to specify the IaC tool used in the commits. The main changes comprise: (a) addition of codes.yml, containing the documentation of defined codes; (b) addition of indicators.yml, containing the documentation of all analyzed commits (incl. coded with "no cost change"); and (c) revision of patterns.yml, to also specify the IaC technology of the commits (under occurrences).

v2.1 - July 2024

Thematic analysis was applied to a dataset of commits involving a different IaC tool. In total, 262 commits that modify AWS CloudFormation files and discuss cost considerations in their messages were collected. First, the original 128 codes were used to describe the code changes in the commits. We identified the cost-related codes 104 times in 93 commits from 86 repositories, while 56 commits from 47 repositories were coded "no cost change".

Next, due to changes not observed for Terraform, we defined 98 new codes, assigned to 133 commits from 109 repositories. Based on the codes, we further attempted to match each new commit with one of the ten Terraform (anti)patterns. If none were appropriate, we grouped the commits based on similarities. This processes resulted in the identification of two new patterns: Cost Report and Preventative Template.

v2.2 - November 2024

Refinement of the previous thematic analysis led to the identification of 6 occurrences of the Cost Report pattern in the Terraform dataset. The occurrences are spread around 6 commits of 5 different repositories.

In the refinement process, we also identified a special situation that we have labeled as a conscious cost increase. This situation is characterized by changes that directly and consciously contradict one or more of our identified patterns, trading off cost in favor of another factor (e.g., performance) as justified by the developer. We have identified 19 commits from 18 repositories with such changes. These commits are marked with the code conscious_cost_increase in the dataset.