{"record":{"id":"fcd30984b0a4a612","repo":"hashicorp/packer","slug":"cloud-provider-is-currently-a-required-field","errorCode":null,"errorMessage":"`cloud_provider` is currently a required field.","messagePattern":"`cloud_provider` is currently a required field\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"datasource/hcp-packer-image/data.go","lineNumber":94,"sourceCode":"\n\t// Ensure either channel or iteration_id are set, and not both at the same time\n\tif d.config.Channel == \"\" &&\n\t\td.config.IterationID == \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs, errors.New(\n\t\t\t\"The `iteration_id` or `channel` must be specified.\"))\n\t}\n\tif d.config.Channel != \"\" &&\n\t\td.config.IterationID != \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs, errors.New(\n\t\t\t\"`iteration_id` and `channel` cannot both be specified.\"))\n\t}\n\n\tif d.config.Region == \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs, fmt.Errorf(\"`region` is \"+\n\t\t\t\"currently a required field.\"))\n\t}\n\tif d.config.CloudProvider == \"\" {\n\t\terrs = packersdk.MultiErrorAppend(errs, fmt.Errorf(\"`cloud_provider` is \"+\n\t\t\t\"currently a required field.\"))\n\t}\n\n\tif errs != nil && len(errs.Errors) > 0 {\n\t\treturn errs\n\t}\n\treturn nil\n}\n\n// DatasourceOutput Information from []*hcpPackerDeprecatedModels.HashicorpCloudPackerImage with some information\n// from the parent []*hcpPackerDeprecatedModels.HashicorpCloudPackerBuild included where it seemed\n// like it might be relevant. Need to copy so we can generate\ntype DatasourceOutput struct {\n\t// The name of the cloud provider that the image exists in. For example,\n\t// \"aws\", \"azure\", or \"gce\".\n\tCloudProvider string `mapstructure:\"cloud_provider\"`\n\t// The specific Packer builder or post-processor used to create the image.\n\tComponentType string `mapstructure:\"component_type\"`","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/datasource/hcp-packer-image/data.go#L76-L112","documentation":"Validation error from Configure() of the hcp-packer-image datasource when d.config.CloudProvider is empty. cloud_provider (aws, azure, gce, ...) is required because builds are filtered by platform to select the matching image. Like the sibling checks, it is appended to a packersdk.MultiError and returned before any registry call is made.","triggerScenarios":"Configure() runs with no cloud_provider attribute in the data block, or the value interpolated into it is an empty string (unset variable, empty local, misnamed attribute).","commonSituations":"Forgetting cloud_provider when copying a single-provider template into a multi-provider codebase; a platform-specific variable unset for the current target; typos like 'cloudplatform' or 'provider'.","solutions":["Add cloud_provider = \"<platform>\" (e.g. \"aws\") to the data block.","Ensure the variable/local supplying it is set for the current build target.","Match the platform recorded in registry builds (e.g. 'aws', not 'amazon-ebs').","Migrate to hcp-packer-artifact; it uses an analogous platform field."],"exampleFix":"// before\ndata \"hcp-packer-image\" \"example\" {\n  bucket_name = \"my-bucket\"\n  channel = \"production\"\n  region = \"us-east-1\"\n}\n// after\ndata \"hcp-packer-image\" \"example\" {\n  bucket_name = \"my-bucket\"\n  channel = \"production\"\n  region = \"us-east-1\"\n  cloud_provider = \"aws\"\n}","handlingStrategy":"validation","validationCode":"locals {\n  hcp_provider = coalesce(var.hcp_provider, \"aws\")\n}\n# data \"hcp-packer-image\" \"example\" { cloud_provider = local.hcp_provider ... }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `packer validate` in CI to catch all required-field errors in one pass.","Use platform names matching registry build.Platform values (aws/azure/gce).","Avoid attribute typos like 'provider' — the field is cloud_provider."],"tags":["hcp-packer","config-validation","required-field","datasource"],"backgroundTag":"missing-required-config-field","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"}