fuzzi
fuzzi

Reputation: 2277

How can a non-default service account be set in GKE using Terraform?

I am trying to set a non-default Service Account to the node pool that I am creating.

However, every time with the following code, the node pool shows as using the default service account.

resource "google_container_node_pool" "node_pool" {
...
service_account = "myserviceaccount@<id>.iam.gserviceaccount.com"
    oauth_scopes = [
      "https://www.googleapis.com/auth/cloud-platform"
    ]
}

When I check on the GKE console it shows the Service Account as default rather than my specified account.

I have confirmed in the console, that a node group can be manually created with myserviceaccount set as the Service Account for the node group. It is only with Terraform this is not working.

How do I set my own service account when creating the node pool?

Any help on this would be greatly appreciated!

Upvotes: 0

Views: 631

Answers (1)

DazWilkin
DazWilkin

Reputation: 40091

It's unclear from your question whether your service_account is, as required, part of the node_config which is part of resource.

See example

Upvotes: 3

Related Questions