Skip to content

Commit

Permalink
add env kms project id as variable
Browse files Browse the repository at this point in the history
  • Loading branch information
caetano-colin committed May 14, 2024
1 parent a3bab22 commit 8676a28
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 13 deletions.
1 change: 1 addition & 0 deletions 4-projects/business_unit_3/shared/ml_infra_projects.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ module "ml_infra_project" {
remote_state_bucket = var.remote_state_bucket
artifacts_infra_pipeline_sa = module.infra_pipelines[0].terraform_service_accounts["bu3-artifact-publish"]
service_catalog_infra_pipeline_sa = module.infra_pipelines[0].terraform_service_accounts["bu3-service-catalog"]
environment_kms_project_id = ""
}
13 changes: 7 additions & 6 deletions 4-projects/modules/ml_infra_projects/artifacts_project.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ module "app_infra_artifacts_project" {
"sourcerepo.googleapis.com",
]
# Metadata
project_suffix = "artifacts"
application_name = "app-infra-artifacts"
billing_code = var.billing_code
primary_contact = var.primary_contact
secondary_contact = var.secondary_contact
business_code = var.business_code
project_suffix = "artifacts"
application_name = "app-infra-artifacts"
billing_code = var.billing_code
primary_contact = var.primary_contact
secondary_contact = var.secondary_contact
business_code = var.business_code
environment_kms_project_id = var.environment_kms_project_id
}

resource "google_kms_crypto_key_iam_member" "ml_key" {
Expand Down
13 changes: 7 additions & 6 deletions 4-projects/modules/ml_infra_projects/service_catalog_project.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ module "app_service_catalog_project" {
"sourcerepo.googleapis.com",
]
# Metadata
project_suffix = "service-catalog"
application_name = "app-infra-ml"
billing_code = var.billing_code
primary_contact = var.primary_contact
secondary_contact = var.secondary_contact
business_code = var.business_code
project_suffix = "service-catalog"
application_name = "app-infra-ml"
billing_code = var.billing_code
primary_contact = var.primary_contact
secondary_contact = var.secondary_contact
business_code = var.business_code
environment_kms_project_id = var.environment_kms_project_id
}

resource "google_kms_crypto_key_iam_member" "sc_key" {
Expand Down
5 changes: 5 additions & 0 deletions 4-projects/modules/ml_infra_projects/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,8 @@ variable "service_catalog_infra_pipeline_sa" {
description = "Service Catalog SA to be used by the Infra Pipeline CloudBuild trigger"
type = string
}

variable "environment_kms_project_id" {
description = "Environment level KMS Project ID."
type = string
}
2 changes: 1 addition & 1 deletion 4-projects/modules/ml_single_project/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ resource "google_kms_crypto_key" "kms_keys" {
// Add crypto key viewer role to kms environment project
resource "google_project_iam_member" "kms_viewer" {
for_each = var.environment != "common" ? toset(local.pipeline_kms_sas) : toset([])
project = local.environment_kms_project_id
project = var.environment_kms_project_id
role = "roles/cloudkms.viewer"
member = "serviceAccount:${each.key}"
}
5 changes: 5 additions & 0 deletions 4-projects/modules/ml_single_project/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ variable "remote_state_bucket" {

variable "default_service_account" {
description = "Project default service account setting: can be one of `delete`, `depriviledge`, or `keep`."
type = string
default = "disable"
}

variable "environment_kms_project_id" {
description = "Environment level KMS Project ID."
type = string
}

0 comments on commit 8676a28

Please sign in to comment.