Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧹 Fix: no hard-coded project-id for service account in kms #50

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions hack-lab/container-escape/gcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@ This folder contains Terraform automation code to provision the following:
Essential Contacts Admin
Owner
```

- Create a `terraform.tfvars`` file with the following variables
```
project_id = "your-project-3" #your gcp project string
region = "us-central1"
zone = "us-central1-a"
project_number = "" #your gcp project number
gke_version = "1.25.15-gke.1083000" # built on GKE 1.25, might need to be updated
```

- [gcloud CLI](https://cloud.google.com/sdk/docs/install)

- make sure to install the [gke-gcloud-auth-plugin](https://cloud.google.com/blog/products/containers-kubernetes/kubectl-auth-changes-in-gke), usually via the command:
Expand Down
6 changes: 3 additions & 3 deletions hack-lab/container-escape/gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ resource "google_kms_crypto_key_iam_binding" "crypto_key" {
crypto_key_id = google_kms_crypto_key.key.id
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter"
members = [
"serviceAccount:lunalectric-${random_string.suffix.result}-node@manuel-development-3.iam.gserviceaccount.com",
"serviceAccount:lunalectric-${random_string.suffix.result}-node@${var.project_id}.iam.gserviceaccount.com",
"serviceAccount:service-${var.project_number}@container-engine-robot.iam.gserviceaccount.com",
]
depends_on = [
Expand Down Expand Up @@ -130,7 +130,7 @@ resource "google_compute_firewall" "default" {
# GKE Cluster -> create aks cluster
resource "google_container_cluster" "primary" {
provider = google-beta
node_version = "1.25.9-gke.2300"
node_version = var.gke_version
release_channel {
channel = "STABLE"
}
Expand All @@ -145,7 +145,7 @@ resource "google_container_cluster" "primary" {
enable_tpu = false
location = var.region
logging_service = "logging.googleapis.com/kubernetes"
min_master_version = "1.25.9-gke.2300"
min_master_version = var.gke_version
monitoring_service = "monitoring.googleapis.com/kubernetes"
name = "lunalectric-gke-cluster-${random_string.suffix.result}"
network = "lunalectric-gke-${random_string.suffix.result}"
Expand Down
7 changes: 6 additions & 1 deletion hack-lab/container-escape/gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ variable "project_id" {

variable "project_number" {
type = string
}
}

variable "gke_version" {
type = string
default = "1.25.15-gke.1083000"
}