Repository navigation
feat: assumed_count caveat for counts that rest on a data source placeholder - #105
Merged
Merged
Conversation
…eholder A resource whose count or for_each (its own, or its module's) is computed from a data source placeholder, such as one NAT gateway per data.aws_availability_zones zone, now carries an assumed_count caveat on each priced instance naming the value assumed. The parser records it as domain.Resource.AssumedCount; the calculator reports it only on resources with a non-zero cost. It renders in every format, counts toward caveat_count and fails --strict. The stderr warning for a resource or module count / for_each is now a debug line, since the caveat says the same thing next to the number. A dynamic block's for_each, which has no caveat, still warns.
andreacappelletti97
force-pushed
the
feat/assumed-count-caveat
branch
from
September 29, 2026 18:02
8a09601 to
faaab67
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A new caveat code,
assumed_count. When a resource'scount/for_each, or that of the module it sits in, is computed from a data source c3x gives a placeholder (data.aws_availability_zonesis three zones in the provider's region,aws_region,aws_caller_identity,google_client_config), every priced instance now says so:How
expandInstancesalready stripped placeholder marks from count/for_each; it now renders them (describePlaceholders) intoinstance.assumed.moduleEnv.assumedCountcarries a module instance's assumption down, so every resource under a placeholder-counted module inherits it (joined with the resource's own, deduplicated). The result lands in the newdomain.Resource.AssumedCount.assumedCountCaveatturns it into a resource-level caveat, only when the resource's subtotal is non-zero: a free subnet's count can't move the total.code: assumed_count), count towardcaveat_count, and fail--strict(exit 3). The--stricthelp text mentions the new case.dynamicblock's for_each over a placeholder has no caveat, so it still warns.Tests
AssumedCounton every instance; a literal count and no count record nothing; module count over the zones propagates to the module's resources, a literal module count doesn't. Existing placeholder tests now assert onAssumedCountinstead of the log.assumed_counton the per-AZ instances only (not the literal-count instances, not the free VPCs), text and markdown show it for the three priced instances,--strictreturns the caveat error and listsassumed_count.--offline, where every price is $0, so no resource gets the caveat.Demo (
c3x-demo/aws, live pricing)