> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/action-center/google-cloud/set-instance-network-tags.md).

# Set Instance Network Tags

Replaces the network tags on the Google Cloud Compute Engine instances that the previous nodes collected. Firewall rules that are bound to a tag apply to the instance as soon as the tag is set, so a tag such as `quarantine` can isolate an instance. It runs once per workflow run and handles all collected assets in a loop.

### Before you begin

* **Google Cloud shared prerequisite:** a Google Cloud service account JSON key. Paste its content into **Service Account Key**. The service account must have the required IAM roles on the target projects. The job exchanges the key for an access token with the `compute` scope.
* Defaults: **Service Account Key** and **Request Timeout** can be saved once for all Google Cloud jobs per job tab in **Action Center** > **Settings**. See [Action Center Settings](broken://pages/6306359e6377f00e48df629ca98133a235c0c194).
* Asset type: `device` only (`allowed_asset_types`). Select that inventory in the job node.
* Required column: `Specifics.google-cloud-compute-engine.selfLink`. Assets without a Compute Engine `selfLink` are skipped.
* Put a condition that collects the instances you want to isolate before this node. A job node acts on the assets that earlier nodes collected, see [About Action Center](broken://pages/987129312fbd840280d072e1a5c81630e5a361de).

{% hint style="warning" %}
Because the tags are replaced, tags that other firewall rules rely on are removed too. Include every tag the instance must keep.
{% endhint %}

### Settings

| Setting             | Type             | Required | Default | Description                                                                                                                                                                   |
| ------------------- | ---------------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Service Account Key | Text (sensitive) | Yes      | None    | Content of the Google Cloud service account JSON key file. The service account must have the required IAM roles on the target projects. Masked as ten asterisks after saving. |
| Request Timeout     | Number           | No       | 30      | Timeout in seconds for API requests (also used for the token request).                                                                                                        |
| Network Tags        | JSON list        | Yes      | None    | Network tags to set on the instances as a JSON list. Example: `["quarantine"]`. Existing tags are replaced; an empty list removes all tags.                                   |

### How it works

1. The job parses **Network Tags**. If the value is not valid JSON, or not a JSON list, the job fails with `Network tags must be a JSON list.` (or `Network tags is not valid JSON: ...`) before any instance is touched.
2. It requests a Google token with the Compute Engine scope (`compute`) from your service account key.
3. For each instance it reads the instance (`GET` on the `selfLink`) to get the current tags fingerprint, then sends your list to `setTags`.
4. Existing tags are replaced, not merged. An empty list removes all tags.

Failure handling: a problem with one asset does not stop the others. Each request runs inside its own error handler that writes the error to the workflow log and continues with the next asset. An HTTP error status from Google (4xx or 5xx) is also written to the log but does not fail the node, so check the log if an expected change did not happen. The node fails only when the job cannot start, for example when the service account key is not valid JSON or Google does not return a token.

The job does not change the assets. After it finishes, the node passes on all the assets it received, including those it skipped.

### Example

A workflow that runs on a schedule, checks the instances you want to isolate, and then runs this job:

| Setting                | Value                                                         |
| ---------------------- | ------------------------------------------------------------- |
| Inventory (asset type) | Device                                                        |
| Service Account Key    | `YOUR_SERVICE_ACCOUNT_KEY_JSON` (the content of the key file) |
| Request Timeout        | `30`                                                          |
| Network Tags           | `["quarantine"]`                                              |

After the run, each collected instance has only the tag `quarantine`. A firewall rule that targets that tag now applies to it.

### What's next?

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>About Action Center</strong></td><td>Workflows, triggers, conditions and job nodes.</td><td><a href="broken://pages/987129312fbd840280d072e1a5c81630e5a361de">Broken link</a></td></tr><tr><td><strong>Action Center Settings</strong></td><td>Save Google Cloud defaults once.</td><td><a href="broken://pages/6306359e6377f00e48df629ca98133a235c0c194">Broken link</a></td></tr><tr><td><strong>Set Instance Labels</strong></td><td>A sibling job of the same product.</td><td><a href="broken://pages/05c85b085b235d1b728cb95b24e2709a370446d0">Broken link</a></td></tr></tbody></table>

{% hint style="info" %}
Available starting from version 6.7.2.
{% endhint %}
