https://pulumi.com logo
Title
h

helpful-tent-95136

09/29/2021, 8:59 AM
Hi, I was wondering if anyone has had an issue with
gcp.compute.InstanceFromMachineImage
when using it across projects? For example:
const myInstance = new gcp.compute.InstanceFromMachineImage(
  `my-instance`,
  {
    zone: 'australia-southeast1-a',
    project: 'vm-project',
    sourceMachineImage: 'projects/image-project/global/machineImages/my-image',
    networkInterfaces: [{ network: vpcId, subnetwork: mySubnet }],
  }
);
when I do this, it tries to look up
sourceMachineImage
from
'projects/vm-project/global/machineImages/my-image'
which of course doesn't exist πŸ˜• Any ideas?
m

mysterious-pager-42871

09/29/2021, 10:38 PM
I had this issue with the same resource, and @steep-sunset-89396 ended up helping me to use the Instance resource instead:
instance = gcp.compute.Instance("example",
    name="example",
    project="example_project",
    machine_type="n1-standard-8",
    zone="example-zone"",
    boot_disk=gcp.compute.InstanceBootDiskArgs(
        initialize_params=gcp.compute.InstanceBootDiskInitializeParamsArgs(
            image="image-project/image-name"
        )),
    network_interfaces=[gcp.compute.InstanceNetworkInterfaceArgs(
        network="example_network",
        subnetwork="example_subnet",
        access_configs=[gcp.compute.InstanceNetworkInterfaceAccessConfigArgs(
            nat_ip="example_vm_ip"
        )],
    )],
    service_account=gcp.compute.InstanceServiceAccountArgs(
        scopes=["<https://www.googleapis.com/auth/cloud-platform>"],
    ),
    opts=pulumi.ResourceOptions(depends_on=[]))
I think there is some issue with the
gcp.compute.InstanceFromMachineImage
resource, I never did get it to work
h

helpful-tent-95136

09/30/2021, 3:47 AM
Hmm, now I'm getting
Error resolving image name  'image-project/image-name': Could not find image or image-project/image-name
I've tried both
image-project/image-name
as in your example, and
'projects/image-project/global/machineImages/image-name'
At least its looking in the right place, but still not finding it -- it uses my service account to look for the image right? Or do I need to ensure the service account attached to the instance has access? I'm actually able to use the same service account to deploy an instance in the
image-project
project πŸ˜•
m

mysterious-pager-42871

09/30/2021, 4:09 AM
I’m not really sure as the image I used was publicly available so I was able to access it just with the name of the project and the image name πŸ˜• sorry I can’t be more helpful!
h

helpful-tent-95136

10/01/2021, 4:15 AM
turned out i was trying to use a machine image for the disk image, WHOOPS πŸ˜… thanks for your help Stephanie!