This module includes a Bolt plugin to generate targets from Google Cloud compute engine instances.
- A service account with the
compute.instances.list
permission - Compute engine instances with either the
compute
orcompute.readonly
access scope - A credentials file for the service account
The plugin generates targets from a list of compute engine instances for a specific project and zone. It supports the following fields:
Option | Type | Description |
---|---|---|
credentials |
String |
A path to the service account credentials file. Accepts either an absolute path or a path relative to the Bolt project directory. Optional. |
client_email |
String |
The Google Cloud client email to use. Optional. |
token_uri |
String |
The Google Cloud token uri to use. Optional. |
private_key |
String |
The Google Cloud private key to use. Optional. |
project |
String |
The name of the project to lookup instances from. Required. |
target_mapping |
Hash |
A hash of target attributes to populate with resource values. Must include either name or uri . Required. |
zone |
String |
The name of the zone to lookup instances from. Required. |
The plugin supports loading a credentials file from a path specified in either the credentials
option
or the GOOGLE_APPLICATION_CREDENTIALS
environment variable. A path specified in the credentials
ption or credentials specified in the client_email
, token_uri
and private_key
fields will take
precedence over a path specified in the GOOGLE_APPLICATION_CREDENTIALS
environment variable. If a
credentials file is not specified, or the path does not point to a valid credentials file, the plugin
will error.
The credentials file must contain a JSON object with at least the following fields:
client_email
private_key
token_uri
The target_mapping
field accepts a hash of target attributes to populate with
resource values.
The hash of target attributes is formatted similarly to a target specification in an
inventory file. Resource
values are accessed using dot notation. For example, you can access an instance's public IP address
using networkInterfaces.0.accessConfigs.0.natIP
.
---
# inventory.yaml
group:
- name: google
targets:
_plugin: gcloud_inventory
project: my_project
zone: us-west1-b
credentials: ~/.google/credentials.json
target_mapping:
name: name
uri: networkInterfaces.0.accessConfigs.0.natIP
vars: labels