<commit_before>---
layout: "google"
page_title: "Google: google_service_account"
sidebar_current: "docs-google-datasource-service-account"
description: |-
  Get the service account from a project.
---

# google\_service\_account

Get the service account from a project. For more information see
the official [API](https://cloud.google.com/compute/docs/access/service-accounts) documentation.

## Example Usage

```hcl
data "google_service_account" "object_viewer" {
  account_id = "object-viewer"
}
```

## Example Usage, save key in Kubernetes secret
```hcl
data "google_service_account" "myaccount" {
  account_id = "myaccount-id"
}

resource "google_service_account_key" "mykey" {
  service_account_id = "${data.google_service_account.myaccount.name}"
}

resource "kubernetes_secret" "google-application-credentials" {
  metadata = {
    name = "google-application-credentials"
  }
  data {
    credentials.json = "${base64decode(google_service_account_key.mykey.private_key)}"
  }<commit_msg>Add a missing closing bracket in  a resource block (#3465)<commit_after>---
layout: "google"
page_title: "Google: google_service_account"
sidebar_current: "docs-google-datasource-service-account"
description: |-
  Get the service account from a project.
---

# google\_service\_account

Get the service account from a project. For more information see
the official [API](https://cloud.google.com/compute/docs/access/service-accounts) documentation.

## Example Usage

```hcl
data "google_service_account" "object_viewer" {
  account_id = "object-viewer"
}
```

## Example Usage, save key in Kubernetes secret
```hcl
data "google_service_account" "myaccount" {
  account_id = "myaccount-id"
}

resource "google_service_account_key" "mykey" {
  service_account_id = "${data.google_service_account.myaccount.name}"
}

resource "kubernetes_secret" "google-application-credentials" {
  metadata = {
    name = "google-application-credentials"
  }
  data {
    credentials.json = "${base64decode(google_service_account_key.mykey.private_key)}"
  }
}
{'fraction_non_alphanumeric': 0.12260912211868563, 'fraction_numerical': 0.00392349190779794, 'mean_word_length': 5.257668711656442, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '980364', 'n_tokens_mistral': 656, 'n_tokens_neox': 633, 'n_words': 143}