hashicorp/packer · error
could not find a build result matching [region=%q, cloud_pro
Error message
could not find a build result matching [region=%q, cloud_provider=%q, component_type=%q]. Available: %v
What it means
After resolving a valid, non-revoked iteration, the hcp-packer-image datasource walks all builds and their images looking for one whose region, cloud provider, and optional component type match the datasource config. When no build/image matches, it throws this error listing the region/cloud combinations it actually found. The trailing 'Available:' map in the message is the key diagnostic.
Source
Thrown at datasource/hcp-packer-image/data.go:219
// This is the desired image.
output = DatasourceOutput{
CloudProvider: build.CloudProvider,
ComponentType: build.ComponentType,
CreatedAt: image.CreatedAt.String(),
BuildID: build.ID,
IterationID: build.IterationID,
ChannelID: channelID,
PackerRunUUID: build.PackerRunUUID,
ID: image.ImageID,
Region: image.Region,
Labels: build.Labels,
}
return hcl2helper.HCL2ValueFromConfig(output, d.OutputSpec()), nil
}
}
}
return cty.NullVal(cty.EmptyObject), fmt.Errorf("could not find a build result matching "+
"[region=%q, cloud_provider=%q, component_type=%q]. Available: %v ",
d.config.Region, d.config.CloudProvider, d.config.ComponentType, cloudAndRegions)
}
func filterBuildByComponentType(build *hcpPackerDeprecatedModels.HashicorpCloudPackerBuild, componentType string) bool {
// optional field is not specified, passthrough
if componentType == "" {
return true
}
// if specified, only the matched image metadata is returned by this effect
return build.ComponentType == componentType
}
View on GitHub (pinned to eb36e3c3e4)
Solutions
- Read the 'Available:' list in the error and set `region`/`cloud_provider` to one of the listed values.
- Verify the exact cloud_provider identifier the builder used (e.g. "aws", "azure", "gce").
- Remove or correct `component_type` if it filters out the only matching build.
- Rebuild and re-publish the iteration so it contains an image for the requested region.
- Cross-check the channel/iteration_id resolves to the iteration you expect.
Example fix
// before
datasource "hcp-packer-image" "image" {
bucket_name = "my-app"
channel = "prod"
cloud_provider = "amazon-ebs" // wrong: registry stores "aws"
region = "us-east-1"
}
// after
datasource "hcp-packer-image" "image" {
bucket_name = "my-app"
channel = "prod"
cloud_provider = "aws"
region = "us-east-1"
} Defensive patterns
Strategy: validation
Validate before calling
// Validate inputs against registry data before building:
// hcp packer iterations show <id> --bucket=my-app --format=json | jq '.builds[] | {cloud_provider: .cloud_provider, regions: [.images[].region]}'
// Compare your region/cloud_provider/component_type against this output. Try / catch
// Use the 'Available:' map in the error to self-correct in scripts: if ! out=$(packer build template.pkr.hcl 2>&1); then echo "$out" | grep -o 'Available: .*' && echo "Fix region/cloud_provider/component_type to a listed value" fi
Prevention
- Copy region and cloud_provider strings exactly from the builder's published metadata (e.g. "aws", not "amazon-ebs").
- Only set component_type when you intentionally filter to a specific build.
- Build images in every region you plan to consume, or derive region from a shared data source.
- Inspect the iteration's builds in HCP UI when template input values are uncertain.
When it happens
Trigger: Execute loops over iteration.Builds filtering on build.CloudProvider == d.config.CloudProvider and image.Region == d.config.Region with filterBuildByComponentType; no entry matches, so it returns this error with the accumulated cloudAndRegions map.
Common situations: Region name mismatch ("us-east-1" vs "use1" or "US East (N. Virginia)"); wrong cloud_provider string ("aws" vs "amazon-ebs" vs "azure" vs "azr"); component_type set to a builder label that no longer matches; the build for that region failed or the image metadata was pruned from the registry.
Related errors
- could not find a build result matching [region=%q, platform=
- error retrieving version from HCP Packer Registry: %s
- error retrieving channel from HCP Packer Registry: %s
- there is no version associated with the channel %s
- the version %s is revoked and can not be used on Packer buil
AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05).
Data as JSON: /api/errors/f02a673c7f4b585f.
Report an issue: GitHub.