I'm new to GCP.

I've created 2 projects. In each project, I created a compute engine VM instance. The instances have different names but are located in the same region and loc.

When I go into gcloud shell and connect to 1 of my projects, I see the files in that instance that I created in the other instance in the other project.

I would have thought that the 2 projects would not share the same filesystem. Am I mistaken? Is this the default behavior if I create the instances in the same region and zone?

I connect to my projects by opening a gcloud shell and using the “gcloud config [priject-id]” command.

Is there a way to create instances in different projects that do not share the same filesystem?

  • If you create a file in one of them, this file appears in the other? Sep 18 '20 at 23:59
  • 1
    You probably logged into the same VM from both cloud shells. Try logging in directly from your workstation. Sep 19 '20 at 1:28
  • From the terminal, I login using: "gcloud config set project my-project-python-005". I close that terminal and open a new one and login using: "gcloud config set project my-project-tutorial-005". These are 2 separate projects using 2 different VMs, yet I see the same filesystem. Could it be how I set up the VM instances? Sep 20 '20 at 18:03

It is not possible for two instances to share the same file system.

You can attach the same disk to two different VM's but not at the same time. In order to attach the disk (containing mentioned filesystem) to another machine first you need to detach it from the current one.

You'r impression of a "shared" filesystem must be false and you got confused (logged in twice to the same machine).

But - assuming there's some but (which may never be ruled out completely) you can check which disk is attached to which VM by running these commands in the cloud shell:

gcloud config set project my-project-name-1
gcloud compute instances describe instance1 | grep disk

Your output should be something similar:

wb@cloudshell:~ (wb)$ gcloud compute instances describe instaince111 | grep disk
Did you mean zone [europe-west4-b] for instance: [log1] (Y/n)?  n

No zone specified. Using zone [europe-west3-c] for instance: [instance111].
  diskSizeGb: '10'
  source: https://www.googleapis.com/compute/v1/projects/xxxxxx/zones/europe-west3-c/disks/isntance111

Then select another project and run the describe command again.

----- UPDATE ------

Cloud shell is your personam VM that doesn't belong to any of the projects and is not in your default VPC. It's just created and preconfigured with gcloud for your convinience. If you want to log in to specific VM it's best to use SSH button next to the VM specs in the cloud console vm list or [gcloud compute ssh][3] command.

If you just select another project in your cloud shell VM you're still logged in to this VM and it only tells gcloud utility that any commands issued after gcloud config set project my-proj-name will affect the project my-proj-name.

  • I used cloud shell. For project my-project-python-005, the output was: diskSizeGb: '10' source: googleapis.com/compute/v1/projects/my-project-python-005/zones/… For project my-project-tutorial-005, the output was: diskSizeGb: '10' source: googleapis.com/compute/v1/projects/my-project-tutorial-005/… I touch a file, XYZ, in my y-project-tutorial-005. I exited the shell and opened a shell for my-project-python-005. When I issued the command "ls", the file XYZ was there, too,. Sep 22 '20 at 18:23
  • Can you provide exact commands you used and their output ? Please update your question with those details.
    – Wojtek_B
    Sep 23 '20 at 10:58
  • GCP Commands   On a Chromebook: Opened cloudshell   Issued command:  joei0005@cloudshell:~$ gcloud config set project my-project-tutorial-005 Output:  Updated property [core/project  ]. Issued command:  Touch ABC   Exited cloudshell by quitting window   Opened cloudshell   Issued command:   joei0005@cloudshell:~$ gcloud config set project my-project-python-005 Output:  Updated property [core/project]. Issued commend:  joei0005@cloudshell:~ (my-project-python-005)$ ls Output:  ABC README-cloudshell.txt Sep 25 '20 at 1:39
  • 1
    Cloud shell is just your personal machine (separate from your VM's in your projects) and doesn't belong to any of them. Have a look at the Cloud Shell Documentation.
    – Wojtek_B
    Sep 25 '20 at 8:14
  • Okay. Thank you so much. I reviewed the documentation in the link you provided. It cleared some things up for me. Should I use the SSH dropdown for the instance to connect to the individual VM instances? Sep 26 '20 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.