---
layout: docs
page_title: 'Autoscaling Plugins: GCE MIG'
description: The "gcp-mig" target plugin scales a Google Cloud Engine Managed Instance Group.
---

# Google Cloud Engine Managed Instance Groups Target

The `gce-mig` target plugin allows for the scaling of the Nomad cluster clients
via manipulating [Google Cloud Engine Managed Instance Groups][gce_migs]. The
plugin supports both regional and zonal groups.

## Agent Configuration Options

The plugin uses the official Google Cloud Golang SDK. This means it supports
the common ways of [providing credentials to Google Cloud][gcp_credentials].

It is recommended, if possible to use the [Vault GCP Secrets
engine][vault_gcp_backend] for supplying access credentials to the plugin.

Credentials should be injected into the configuration via a template rather
than as environment variables. This ensures the credentials are passed only to
the plugin, rather than being available for all plugins and the agent process.

```hcl
target "gce-mig" {
  driver = "gce-mig"
  config = {
    credentials = "local/creds.json"
  }
}
```

- `credentials` `(string: "")` - This is specified as the path to a Google Cloud
  credentials file, typically for a service account.

### Nomad ACL

When using a Nomad cluster with ACLs enabled, the plugin will require an ACL token
which provides the following permissions:

```hcl
node {
  policy = "write"
}
```

## Policy Configuration Options

```hcl
check "hashistack-allocated-cpu" {
  # ...
  target "gce-mig" {
    project             = "hashistack-demo"
    region              = "us-west1"
    mig_name            = "nomad-client-hashistack"
    node_class          = "hashistack"
    node_drain_deadline = "5m"
    node_purge          = "true"
  }
  # ...
}
```

- `project` `(string: <required>)` - The [Google Cloud Platform project
  ID][gcp_projects] within which the managed instance group is running.

- `region` `(string: "")` - The GCP region where the Managed Instance Group
  resides. Providing this parameter indicates the MIG is regional. Conflicts
  with `zone`.

- `zone` `(string: "")` - The GCP zone where the Managed Instance Group
  resides. Providing this parameter indicates the MIG is zonal. Conflicts with
  `region`.

- `mig_name` `(string: <required>)` - The name of the GCE Managed Instance
  Group to interact with when performing scaling actions.

- `datacenter` `(string: "")` - The Nomad client [datacenter][nomad_datacenter]
  identifier used to group nodes into a pool of resource.

- `node_class` `(string: "")` - The Nomad [client node class][nomad_node_class]
  identifier used to group nodes into a pool of resource.

- `node_drain_deadline` `(duration: "15m")` The Nomad [drain
  deadline][nomad_node_drain_deadline] to use when performing node draining
  actions. **Note that the default value for this setting differs from Nomad's
  default of 1h.**

- `node_drain_ignore_system_jobs` `(bool: "false")` A boolean flag used to
  control if system jobs should be stopped when performing node draining
  actions.

- `node_purge` `(bool: "false")` A boolean flag to determine whether Nomad
  clients should be [purged][nomad_node_purge] when performing scale in
  actions.

- `node_selector_strategy` `(string: "least_busy")` The strategy to use when
  selecting nodes for termination. Refer to the [node selector
  strategy][node_selector_strategy] documentation for more information.

[gcp_credentials]: https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application

[gcp_projects]: https://cloud.google.com/resource-manager/docs/creating-managing-projects

[gce_migs]: https://cloud.google.com/compute/docs/instance-groups/

[nomad_datacenter]: /nomad/docs/configuration#datacenter

[nomad_node_class]: /nomad/docs/configuration/client#node_class

[nomad_node_drain_deadline]: /nomad/api-docs/nodes#deadline

[nomad_node_purge]: /nomad/api-docs/nodes#purge-node

[node_selector_strategy]: /nomad/tools/autoscaling/internals/node-selector-strategy

[vault_gcp_backend]: /vault/docs/secrets/gcp
