Project: SPIRE (Provisioning / Key Management)
File: plugin_server_nodeattestor_gcp_iit.md

Must be used in conjunction with the agent-side gcp_iit plugin The `gcp_iit` plugin automatically attests instances using the . It also allows an operator to use GCP Instance IDs when defining SPIFFE ID attestation policies. Agents attested by the gcpiit attestor will be issued a SPIFFE ID like `spiffe://TRUSTDOMAIN/spire/agent/gcpiit/PROJECTID/INSTANCE_ID` This plugin requires an allow list of ProjectID from which nodes can be attested. This also means that you shouldn't run multiple trust domains from the same GCP project. | Configuration | Description | Default | ||--|--| | `projectidallowlist` | List of ProjectIDs from which nodes can be attested. | | | `useinstancemetadata` | If true, instance metadata is fetched from the Google Compute Engine API and used to augment the node selectors produced by the plugin. | false | | `serviceaccountfile` | Path to the service account file used to authenticate with the Google Compute Engine API | | | `allowedlabelkeys` | Instance label keys considered for selectors | | | `allowedmetadatakeys` | Instance metadata keys considered for selectors | | | `maxmetadatavalue_size` | Sets the maximum metadata value size considered by the plugin for selectors | 128 | | `agentpathtemplate` | A URL path portion format of Agent's SPIFFE ID. Describe in text/template format. | `"/{{ .PluginName }}/{{ .ProjectID }}/{{ .InstanceID }}"` | A sample configuration: ```hcl NodeAttestor "gcp_iit" { plugin_data { projectidallowlist = ["project-123"] } } ``` This plugin generates the following selectors based on information contained in the Instance Identity Token: | Selector | Example | Description | |-|-|-| | `gcpiit:project-id` | `gcpiit:project-id:big-kahuna-123456` | ID of the project containing the instance | | `gcpiit:zone` | `gcpiit:zone:us-west1-b` | Zone containing the instance | | `gcpiit:instance-name` | `gcpiit:instance-name:blog-server` | Name of the instance | If `useinstancemetadata` is true, then the Google Compute Engine API is queried for instance metadata which is used to populate these additional selectors: | Selector | Example | Description | |--|--|--| | `gcpiit:tag` | `gcpiit:tag:blog-server` | Instance tag (one selector per) | | `gcpiit:sa` | `gcpiit:sa:123456789-compute@developer.gserviceaccount.com` | Service account (one selector per) | | `gcpiit:label` | `gcpiit:label:key:value` | Instance label | | `gcpiit:metadata` | `gcpiit:metadata:key:value` | Instance metadata (see caveat below) | Not all instance label and metadata values are useful for node selection. To prevent the creation of large amounts of useless selectors, labels and metadata are not used by default. To opt-in to use a specific label or metadata value, specify the key in the `allowedlabelkeys` or `allowedmetadatakeys` configurable. Instance metadata can hold large values up to

To prevent pushing large amounts of data into the datastore, a maximum metadata value size limit is enforced. If an allowed (i.e. key specified in `allowedmetadatakeys`) metadata value is encountered that exceeds the limit then attestation will fail. Metadata and label values are optional. If the value isn't present, the corresponding selector will still have a trailing colon (i.e. `gcpiit:label:<key>:`, `gcpiit:metadata:<key>:`) The plugin uses the Application Default Credentials to authenticate with the Google Compute Engine API, as documented by . When SPIRE Server is running inside GCP, it will use the default service account credentials available to the instance it is running under. When running outside GCP, or if non-default credentials are needed, the path to the service account file containing the credentials may be specified using the `GOOGLEAPPLICATIONCREDENTIALS` environment variable or the `serviceaccountfile` configurable (see Configuration). The service account must have IAM permissions and Authorization Scopes granting access to the following APIs: The agent path template is a way of customizing the format of generated SPIFFE IDs for agents. The template formatter is using Golang text/template conventions, it can reference values provided by the plugin or in a . Some useful values are: | Value | Description | |-|| | .PluginName | The name of the plugin | | .ProjectID | The ID for the project where the instance was created | | .InstanceID | The unique ID for the instance to which this token belongs. | | .ProjectNumber | The unique number for the project where you created the instance | | .Zone | The zone where the instance is located | | .InstanceCreationTimestamp | A Unix timestamp indicating when you created the instance. | The Instance Identity Token, which this attestor leverages to prove node identity, is available to any process running on the node by default. As a result, it is possible for non-agent code running on a node to attest to the SPIRE Server, allowing it to obtain any workload identity that the node is authorized to run. While many operators choose to configure their systems to block access to the Instance Identity Token, the SPIRE project cannot guarantee this posture. To mitigate the associated risk, the `gcp_iit` node attestor implements Trust On First Use (or TOFU) semantics. For any given node, attestation may occur only once. Subsequent attestation attempts will be rejected. It is still possible for non-agent code to complete node attestation before SPIRE Agent can, however this condition is easily and quickly detectable as SPIRE Agent will fail to start, and both SPIRE Agent and SPIRE Server will log the occurrence. Such cases should be investigated as possible security incidents.