Hi, I was wondering if anyone has had an issue wit...
# google-cloud
h
Hi, I was wondering if anyone has had an issue with
gcp.compute.InstanceFromMachineImage
when using it across projects? For example:
Copy code
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
I had this issue with the same resource, and @steep-sunset-89396 ended up helping me to use the Instance resource instead:
Copy code
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
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
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
turned out i was trying to use a machine image for the disk image, WHOOPS ๐Ÿ˜… thanks for your help Stephanie!