Skip to content
ENExplore Calculators

Terraform State Size Calculator

Estimate Terraform state file size based on managed resource count and attributes.

About Terraform State Size Calculator

Terraform serializes all managed resource attributes plus module metadata into a single JSON state file: size ≈ resources × avg_attributes × bytes_per_attribute + modules × module_overhead. As infrastructure grows, state file size grows roughly linearly with resource count, which directly impacts `terraform plan`/`apply` performance and remote backend costs.

Formula

stateSize = (resources × avgAttributes × bytesPerAttribute) + (modules × moduleOverhead)

R
Number of managed resources
A
Average attributes per resource
B
Bytes per attribute
M
Number of module instances
O_m
Overhead bytes per module
S
Total state file size in bytes

Worked example

With the default values below, Terraform State Size Calculator returns Estimated State Size of 349.1. Change any input above and every figure here is recalculated in your browser.

Inputs used

Resource Countaccepts 0–1,000,000 resources
250 resources
Avg Attributes per Resourceaccepts 1–2,000 attributes
40 attributes
Bytes per Attributeaccepts 1–2,000 bytes
35 bytes
Module Countaccepts 0–100,000 modules
15 modules
Overhead per Moduleaccepts 0–100,000 bytes
500 bytes

Results

Estimated State Size
349.1 KB
Estimated State Size
0.341 MB
Resource Data Size
350,000 bytes
Module Overhead
7,500 bytes
Avg Bytes per Resource
1,430 bytes

Step by step

  1. 1Resource bytes: resources × attrs × bytes/attr= 350,000 bytes
  2. 2Module overhead bytes= 7,500 bytes
  3. 3Total state size= 349.1 KB

Assumptions and limits

  • The result is derived only from the 5 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 3 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

Why does state file size matter?

Larger state files take longer to read, lock, and refresh on every plan/apply, and some remote backends charge per-request or per-GB, so state growth directly affects both performance and cost.

How can I reduce Terraform state size?

Split large monoliths into smaller state files per service/environment using workspaces or separate root modules, and use `terraform state rm` to remove resources that no longer need tracking.

Does resource count grow linearly with state size?

Approximately yes, assuming similar resource types. Resources with large embedded data (e.g. IAM policy JSON, big user_data scripts) will skew the average attribute size higher than typical resources.

What's a reasonable bytes-per-attribute estimate?

20-50 bytes is typical for simple string/number attributes; complex nested blocks (e.g. security group rules, IAM policies) can push individual resources well above the average.

Terraform State Size Calculator | Calcrivo