packer and GCloud integration

31 views
Skip to first unread message

Dimitar Dimov

unread,
Jan 9, 2020, 11:21:53 AM1/9/20
to Packer

I've been using the tools from HashiCorp (Packer and Terraform) to create images and then build VMs by using Jenkins on AWS. Now I have a project that is on GCloud and I have successfully configured Terraform to create a VM but when I try to run packer I get the following error root@packer packer]# packer build createImage.json

googlecompute output will be in this color.

==> googlecompute: Checking image does not exist...
==> googlecompute: Creating temporary SSH key for instance...
==> googlecompute: Error getting source image for instance creation: Could not find image, centos-7, in projects, [persuasive-axe-264518 centos-cloud coreos-cloud debian-cloud google-containers opensuse-cloud rhel-cloud suse-cloud ubuntu-os-cloud windows-cloud gce-nvme]: 11 error(s) occurred:
==> googlecompute: 
==> googlecompute: * googleapi: got HTTP response code 400 with body: 
==> googlecompute: * googleapi: got HTTP response code 400 with body: 
==> googlecompute: * googleapi: got HTTP response code 400 with body: 
==> googlecompute: * googleapi: got HTTP response code 400 with body: 
==> googlecompute: * googleapi: got HTTP response code 400 with body: 
==> googlecompute: * googleapi: got HTTP response code 400 with body: 
==> googlecompute: * googleapi: got HTTP response code 400 with body: 
==> googlecompute: * googleapi: got HTTP response code 400 with body: 
==> googlecompute: * googleapi: got HTTP response code 400 with body: 
==> googlecompute: * googleapi: got HTTP response code 400 with body: 
==> googlecompute: * googleapi: got HTTP response code 400 with body:
Build 'googlecompute' errored: Error getting source image for instance creation: Could not find image, centos-7, in projects, [persuasive-axe-264518 centos-cloud coreos-cloud debian-cloud google-containers opensuse-cloud rhel-cloud suse-cloud ubuntu-os-cloud windows-cloud gce-nvme]: 11 error(s) occurred:

* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 

==> Some builds didn't complete successfully and had errors:
--> googlecompute: Error getting source image for instance creation: Could not find image, centos-7, in projects, [persuasive-axe-264518 centos-cloud coreos-cloud debian-cloud google-containers opensuse-cloud rhel-cloud suse-cloud ubuntu-os-cloud windows-cloud gce-nvme]: 11 error(s) occurred:

* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 
* googleapi: got HTTP response code 400 with body: 

==> Builds finished but no artifacts were created.

This is my createImage.json

{
 "variables": {
    "project_id": "persuasive-axe-264518"
  },
 "builders": [
    {
      "type": "googlecompute",
      "region": "europe-west1",
      "zone": "europe-west1-b",
      "project_id": "{{user `project_id`}}",
      "source_image_family": "centos-7",
      "image_name": "My-Test-Image",
      "disk_size": 10,
      "machine_type": "f1-micro",
      "ssh_username": "centos"
    }
  ]
}

I should mention that the service account that I am using is even given a owner permission just to be sure that I have no issues with the permissions. Does anybody has any idea why I have this issue while on AWS it works great.

Rickard von Essen

unread,
Jan 10, 2020, 4:32:54 AM1/10/20
to packe...@googlegroups.com
Try using source_image instead of source_image_family and point out the exact image. Also verify that you can launch an instance from that image with the gcloud command on the same host running Packer with the same credentials. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/31c87536-32d5-4744-8ac5-1d03fca1fcaf%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages