hashicorp / packer-plugin-googlecompute

Packer plugin for Google Compute Builder
https://www.packer.io/docs/builders/googlecompute
Mozilla Public License 2.0
23 stars 53 forks source link

packer validate fails when using google_compute_image data source #125

Closed rhyas closed 1 year ago

rhyas commented 1 year ago

Overview of the Issue

When trying to use the google_compute_image data source to lookup an image family, a packer validate fails saying it doesn't understand the data type:

packer validate test.pkr.hcl
Error: Unknown data type google_compute_image

  on test.pkr.hcl line 10:
  (source code not available)

known data sources: [hcp-packer-image hcp-packer-iteration http null amazon-ami
amazon-parameterstore amazon-secretsmanager]

Reproduction Steps

Sample HCL:

packer {
  required_plugins {
    googlecompute = {
      version = ">= 1.0.16"
      source  = "github.com/hashicorp/googlecompute"
    }
  }
}

data "google_compute_image" "ubuntu_1804" {
  family  = "ubuntu-1804-lts"
  project = "debian-cloud"
}

packer validate test.pkr.hcl

Plugin and Packer version

Packer v1.8.3 Google Plugin: packer-plugin-googlecompute_v1.0.16_x5.0_darwin_arm64

Operating system and Environment details

M1 Macbook Pro

nywilken commented 1 year ago

Hi @rhyas there is no data source for the Google plugin. If you are using a custom built version or the plugin I can see this failing. As Packer does not execute data sources during validation.

In Packer 1.8.5 we released an update to the validate command that allows users to execute data sources as part of the validation command. You can achieve this by running packer validate --evaluate-datasources test.pkr.hcl

If interested in learning a little more about the command flag you can refer to the documentation here

I'm going to close this issue as it has been resolved.