Skip to content

Instantly share code, notes, and snippets.

@bharatmicrosystems
Last active July 18, 2021 06:53
Show Gist options
  • Save bharatmicrosystems/fc630cb5bbe69a06553c73eec9a3eb11 to your computer and use it in GitHub Desktop.
Save bharatmicrosystems/fc630cb5bbe69a06553c73eec9a3eb11 to your computer and use it in GitHub Desktop.
provider "google" {
project = var.project_id
region = var.region
zone = var.location
}
resource "google_service_account" "main" {
account_id = "${var.cluster_name}-sa"
display_name = "GKE Cluster ${var.cluster_name} Service Account"
}
resource "google_container_cluster" "main" {
name = "${var.cluster_name}"
location = var.location
initial_node_count = 3
node_config {
service_account = google_service_account.main.email
oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform"
]
}
timeouts {
create = "30m"
update = "40m"
}
}
resource "time_sleep" "wait_30_seconds" {
depends_on = [google_container_cluster.main]
create_duration = "30s"
}
module "gke_auth" {
depends_on = [time_sleep.wait_30_seconds]
source = "terraform-google-modules/kubernetes-engine/google//modules/auth"
project_id = var.project_id
cluster_name = google_container_cluster.main.name
location = var.location
use_private_endpoint = false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment