Skip to content
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
4 changes: 2 additions & 2 deletions modules/gcp/core/gcs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
resource "google_storage_bucket" "terraform_state" {
name = "${var.project_id}-tfstate"
name = "${var.main_project_id}-tfstate"
location = var.location
project = var.project_id
project = var.main_project_id

versioning {
enabled = true
Expand Down
19 changes: 11 additions & 8 deletions modules/gcp/core/iam.tf
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
resource "google_service_account" "vault_kms_sa" {
project = var.project_id
account_id = "vault-kms-sa"
display_name = "Vault KMS Service Account"
}

resource "google_project_iam_custom_role" "vault_kms_custom_role" {
project = var.main_project_id
role_id = "vaultKmsRole"
title = "Vault KMS Custom Role"
description = "Custom role for Vault to use KMS for auto-unseal with minimal permissions"
project = var.project_id


permissions = [
"cloudkms.cryptoKeyVersions.useToEncrypt",
"cloudkms.cryptoKeyVersions.useToDecrypt",
"cloudkms.cryptoKeys.get",
]
}

resource "google_kms_crypto_key_iam_binding" "vault_kms_custom_binding" {
crypto_key_id = "projects/${var.main_project_id}/locations/${var.region}/keyRings/${google_kms_key_ring.vault_keyring.name}/cryptoKeys/${google_kms_crypto_key.vault_crypto_key.name}"
role = google_project_iam_custom_role.vault_kms_custom_role.id

members = [
"serviceAccount:vault-sa@${var.project_id}.iam.gserviceaccount.com"
]
}
4 changes: 3 additions & 1 deletion modules/gcp/core/kms.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
resource "google_kms_key_ring" "vault_keyring" {
name = "vault-keyring"
location = var.region
project = var.project_id
project = var.main_project_id

depends_on = [google_project_service.services]
}

resource "google_kms_crypto_key" "vault_crypto_key" {
Expand Down
5 changes: 3 additions & 2 deletions modules/gcp/core/service.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
locals {
services = toset([
"secretmanager.googleapis.com"
"secretmanager.googleapis.com",
"cloudkms.googleapis.com"
])
}

resource "google_project_service" "services" {
for_each = local.services

project = var.project_id
project = var.main_project_id
service = each.key

disable_dependent_services = true
Expand Down
13 changes: 7 additions & 6 deletions modules/gcp/core/variables.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
variable "project_id" {
type = string
description = "project id"
}

variable "location" {
type = string
variable "main_project_id" {
description = "main project id"
}

variable "region" {
type = string
description = "region"
}
variable "location" {
description = "location"
}
2 changes: 1 addition & 1 deletion modules/gcp/gke/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ variable "gke_disk_size_gb" {
}

variable "gke_version" {
default = "1.31.5-gke.1068000"
default = "1.31.5-gke.1169000"
}
11 changes: 6 additions & 5 deletions modules/gcp/iam/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,21 @@ resource "google_storage_bucket_iam_member" "terraform_state_access" {
*/

# for vault
data "google_service_account" "vault_kms_sa" {
account_id = "vault-kms-sa"
project = var.main_project_id
resource "google_service_account" "vault_sa" {
project = var.project_id
account_id = "vault-sa"
display_name = "Vault Service Account"
}

resource "google_service_account_iam_binding" "vault_workload_identity_binding" {
service_account_id = data.google_service_account.vault_kms_sa.name
service_account_id = google_service_account.vault_sa.name
role = "roles/iam.workloadIdentityUser"

members = [
"serviceAccount:${var.project_id}.svc.id.goog[vault/vault-sa]"
]

depends_on = [data.google_service_account.vault_kms_sa]
depends_on = [google_service_account.vault_sa]
}

# ƒor loki
Expand Down
3 changes: 2 additions & 1 deletion modules/gcp/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ locals {
"compute.googleapis.com",
"container.googleapis.com",
"storage.googleapis.com",
"secretmanager.googleapis.com"
"secretmanager.googleapis.com",
"cloudkms.googleapis.com",
])
}

Expand Down
1 change: 1 addition & 0 deletions modules/infra/vault/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ resource "helm_release" "vault" {

values = [templatefile("${path.module}/values.yaml", {
project_id = var.project_id
main_project_id = var.main_project_id
region = var.region
key_ring_name = var.key_ring_name
crypto_key_name = var.crypto_key_name
Expand Down
4 changes: 2 additions & 2 deletions modules/infra/vault/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ server:
# GKMS keys must already exist, and the cluster must have a service account
# that is authorized to access GCP KMS.
seal "gcpckms" {
project = "${project_id}"
project = "${main_project_id}"
region = "${region}"
key_ring = "${key_ring_name}"
crypto_key = "${crypto_key_name}"
Expand Down Expand Up @@ -1008,7 +1008,7 @@ server:
# YAML or a YAML-formatted multi-line templated string map of the
# annotations to apply to the serviceAccount.
annotations:
iam.gke.io/gcp-service-account: "vault-kms-sa@${project_id}.iam.gserviceaccount.com"
iam.gke.io/gcp-service-account: "vault-sa@${project_id}.iam.gserviceaccount.com"
# Extra labels to attach to the serviceAccount
# This should be a YAML map of the labels to apply to the serviceAccount
extraLabels: {}
Expand Down
4 changes: 4 additions & 0 deletions modules/infra/vault/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ variable "project_id" {
description = "The project ID"
}

variable "main_project_id" {
description = "The main project ID"
}

variable "region" {
description = "The region"
}
Expand Down
3 changes: 2 additions & 1 deletion projects/gcp/core/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ terraform {
module "core" {
source = "../../../modules/gcp/core"
project_id = var.project_id
location = var.location
main_project_id = var.main_project_id
region = var.region
location = var.location
}

module "acme" {
Expand Down
2 changes: 1 addition & 1 deletion projects/gcp/core/provider.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
provider "google" {
project = var.project_id
project = var.main_project_id
region = var.region
}

Expand Down
5 changes: 5 additions & 0 deletions projects/gcp/core/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Google Cloud Platform
project_id = "goboolean-452007"
main_project_id = "goboolean-450909"
region = "asia-northeast3"
location = "ASIA-NORTHEAST3"
13 changes: 7 additions & 6 deletions projects/gcp/core/variables.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
variable "project_id" {
type = string
description = "project id"
}

variable "location" {
type = string
variable "main_project_id" {
description = "main project id"
}

variable "region" {
type = string
description = "region"
}
variable "location" {
description = "location"
}
3 changes: 3 additions & 0 deletions projects/k8s/base/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Google Cloud Platform
project_id = "goboolean-450909"
region = "asia-northeast3"
1 change: 1 addition & 0 deletions projects/k8s/gateway/deployments/output.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
output "istio_gateway_ip" {
value = module.istio.istio_gateway_ip
sensitive = true
}
1 change: 1 addition & 0 deletions projects/k8s/vault/deployments/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ terraform {
module "vault" {
source = "../../../../modules/infra/vault"
project_id = var.project_id
main_project_id = var.main_project_id
region = var.region
key_ring_name = local.vault_kms_keyring_name
crypto_key_name = local.vault_kms_crypto_key_name
Expand Down
4 changes: 4 additions & 0 deletions projects/k8s/vault/deployments/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Google Cloud Platform
project_id = "goboolean-452007"
main_project_id = "goboolean-450909"
region = "asia-northeast3"
4 changes: 3 additions & 1 deletion projects/k8s/vault/deployments/variables.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
variable "project_id" {
description = "project id"
}

variable "main_project_id" {
description = "main project id"
}
variable "region" {
description = "region"
}