Google Cloud Platform: Create Compute Engine Instances with CLI

Create Compute Engine Instances with CLI

Question

You have one GCP account running in your default region and zone and another account running in a non-default region and zone.

You want to start a new Compute Engine instance in these two Google Cloud Platform accounts using the command line interface.

What should you do?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

A.

The correct answer is A. Create two configurations using gcloud config configurations create [NAME]. Run gcloud config configurations activate [NAME] to switch between accounts when running the commands to start the Compute Engine instances.

Explanation: To create a new Compute Engine instance in two different GCP accounts, we need to use the gcloud command-line interface. However, before we can issue any commands, we need to make sure that we have set up the configurations correctly. Configurations are a way to manage multiple GCP accounts and switch between them easily.

To create two configurations, one for each account, we can use the following command:

lua
gcloud config configurations create [NAME]

Here, [NAME] is the name we want to give to our configuration. We should create two configurations, one for each account.

Once we have created the configurations, we can activate them using the following command:

css
gcloud config configurations activate [NAME]

Here, [NAME] is the name of the configuration we want to activate. We should activate the configuration corresponding to the account we want to use to start the Compute Engine instance.

Once we have activated the correct configuration, we can use the gcloud command-line interface to start the Compute Engine instance in that account. We can use the following command to create a new Compute Engine instance:

css
gcloud compute instances create [INSTANCE_NAME] --zone=[ZONE]

Here, [INSTANCE_NAME] is the name we want to give to our instance, and [ZONE] is the zone where we want to create the instance. We should specify the correct zone for each account.

In summary, we need to create two configurations, activate the correct configuration before issuing the gcloud command to start the Compute Engine instance in the correct account. Therefore, the correct answer is A.