{"record":{"id":"f02a673c7f4b585f","repo":"hashicorp/packer","slug":"could-not-find-a-build-result-matching-region-q-f02a67","errorCode":null,"errorMessage":"could not find a build result matching [region=%q, cloud_provider=%q, component_type=%q]. Available: %v ","messagePattern":"could not find a build result matching \\[region=%q, cloud_provider=%q, component_type=%q\\]\\. Available: (.+?) ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"datasource/hcp-packer-image/data.go","lineNumber":219,"sourceCode":"\t\t\t\t// This is the desired image.\n\t\t\t\toutput = DatasourceOutput{\n\t\t\t\t\tCloudProvider: build.CloudProvider,\n\t\t\t\t\tComponentType: build.ComponentType,\n\t\t\t\t\tCreatedAt:     image.CreatedAt.String(),\n\t\t\t\t\tBuildID:       build.ID,\n\t\t\t\t\tIterationID:   build.IterationID,\n\t\t\t\t\tChannelID:     channelID,\n\t\t\t\t\tPackerRunUUID: build.PackerRunUUID,\n\t\t\t\t\tID:            image.ImageID,\n\t\t\t\t\tRegion:        image.Region,\n\t\t\t\t\tLabels:        build.Labels,\n\t\t\t\t}\n\t\t\t\treturn hcl2helper.HCL2ValueFromConfig(output, d.OutputSpec()), nil\n\t\t\t}\n\t\t}\n\t}\n\n\treturn cty.NullVal(cty.EmptyObject), fmt.Errorf(\"could not find a build result matching \"+\n\t\t\"[region=%q, cloud_provider=%q, component_type=%q]. Available: %v \",\n\t\td.config.Region, d.config.CloudProvider, d.config.ComponentType, cloudAndRegions)\n}\n\nfunc filterBuildByComponentType(build *hcpPackerDeprecatedModels.HashicorpCloudPackerBuild, componentType string) bool {\n\t// optional field is not specified, passthrough\n\tif componentType == \"\" {\n\t\treturn true\n\t}\n\t// if specified, only the matched image metadata is returned by this effect\n\treturn build.ComponentType == componentType\n}\n","sourceCodeStart":201,"sourceCodeEnd":232,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/datasource/hcp-packer-image/data.go#L201-L232","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ndatasource \"hcp-packer-image\" \"image\" {\n  bucket_name     = \"my-app\"\n  channel         = \"prod\"\n  cloud_provider  = \"amazon-ebs\"  // wrong: registry stores \"aws\"\n  region          = \"us-east-1\"\n}\n// after\ndatasource \"hcp-packer-image\" \"image\" {\n  bucket_name     = \"my-app\"\n  channel         = \"prod\"\n  cloud_provider  = \"aws\"\n  region          = \"us-east-1\"\n}","handlingStrategy":"validation","validationCode":"// Validate inputs against registry data before building:\n// hcp packer iterations show <id> --bucket=my-app --format=json | jq '.builds[] | {cloud_provider: .cloud_provider, regions: [.images[].region]}'\n// Compare your region/cloud_provider/component_type against this output.","typeGuard":null,"tryCatchPattern":"// Use the 'Available:' map in the error to self-correct in scripts:\nif ! out=$(packer build template.pkr.hcl 2>&1); then\n  echo \"$out\" | grep -o 'Available: .*' && echo \"Fix region/cloud_provider/component_type to a listed value\"\nfi","preventionTips":["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."],"tags":["hcp-packer","datasource","config-mismatch","region"],"backgroundTag":"build-result-not-found","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}