GCP Free Learning

How to add or remove network tags for a Compute Engine instance?

by

GCP Free Learning

Network tags in GCP are used to apply firewall rules and network routes to instances. To add or remove network tags for a Compute Engine instance, follow these steps:

1. Using GCP Console:

a. Go to the GCP Console: https://console.cloud.google.com/

b. Navigate to Compute Engine > VM instances.

c. Click on the instance for which you want to add or remove network tags.

d. Click on the “Edit” button at the top of the instance details page.

e. Scroll down to the “Network tags” section.

f. To add a network tag, type the tag name in the text box and press Enter.

g. To remove a network tag, click the “x” next to the tag name.

h. Click the “Save” button at the bottom of the page.

2. Using gcloud CLI:

First, make sure you have the Google Cloud SDK (https://cloud.google.com/sdk/docs/install) installed.

a. Open the terminal (Command Prompt or PowerShell on Windows, Terminal on macOS or Linux).

b. Authenticate with your Google Cloud account using the following command:

gcloud auth login

c. Set your GCP project:

gcloud config set project PROJECT_ID

Replace PROJECT_ID with your project ID.

d. To add a network tag, run the following command:

gcloud compute instances add-tags INSTANCE_NAME --tags TAG_NAME --zone ZONE

e. To remove a network tag, run the following command:

gcloud compute instances remove-tags INSTANCE_NAME --tags TAG_NAME --zone ZONE

Replace INSTANCE_NAME, TAG_NAME, and ZONE with appropriate values.

3. Using Terraform:

To add or remove network tags using Terraform, modify the tags attribute in the google_compute_instance resource block in your main.tf file:

resource "google_compute_instance" "example" {
  # ... other configuration ...

  tags = ["TAG1", "TAG2", "TAG3"]  # Add or remove tags as needed

  # ... other configuration ...
}

Replace TAG1, TAG2, TAG3 with your desired network tags.

After modifying the tags attribute, run the following commands:

a. Review the execution plan:

terraform plan

b. Apply the changes:

terraform apply

This will update the existing instance with the new network tags. Note that modifying network tags in Terraform may cause the instance to be recreated, depending on your configuration.

Glance and Google’s Next-Level Gaming Recommendation Engine

Collaborative Excellence: Glance and Google’s Next-Level Gaming Recommendation Engine Introduction: In the dynamic gaming industry, personalized recommendations are crucial for..

gcp_ml gcp_ml

Digits and Google Cloud ML

How Digits is Transforming the Accounting Landscape Using Google Cloud ML The finance and accounting industry is experiencing a significant..

GCP AI GCP AI

Google Cloud’s Vertex AI Model Garden and the Launch of Generative AI Studio

Google Cloud’s Vertex AI Model Garden and the Launch of Generative AI Studio Artificial Intelligence (AI) and Machine Learning (ML)..

GCP AI/ML GCP AI/ML

Google Cloud’s Pioneering AI Models and the Launch of Generative AI Studio

 Google Cloud’s Pioneering AI Models and the Launch of Generative AI Studio Artificial Intelligence (AI) continues to break new grounds,..

GCP App Engine GCP App Engine

How to scale an App Engine application in GCP?

Scaling an App Engine application involves configuring the scaling settings in the app.yaml file and deploying the changes. I’ll provide..

Leave a Reply

Your email address will not be published. Required fields are marked *