-
Notifications
You must be signed in to change notification settings - Fork 14
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
feat(module): Add ML Infra Projects Module and 4-projects refactor #40
Merged
sleighton2022
merged 40 commits into
GoogleCloudPlatform:main
from
caetano-colin:refactor/ml-infra-projects
May 22, 2024
Merged
Changes from 36 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
427fb23
first commit
caetano-colin 7b6da01
restore files
caetano-colin f81d4cf
add new files
caetano-colin 0cd451f
add copies
caetano-colin 29e6e70
remove old files
caetano-colin 5c13ce8
add sa
caetano-colin 03cc68e
add newline to EOF
caetano-colin b5b1cf1
add outputs.tf
caetano-colin a3bab22
remove remote.tff from inside module
caetano-colin ca7c7d2
chore(format): terraform fmt on dns module
caetano-colin 8676a28
add env kms project id as variable
caetano-colin ba35d53
Merge branch 'main' of github.com:caetano-colin/terraform-google-ente…
caetano-colin 0d4f692
generate docs
caetano-colin be0ba50
Merge branch 'format/fmt-dns-module' into refactor/ml-infra-projects
caetano-colin 38069e2
Revert "Merge branch 'format/fmt-dns-module' into refactor/ml-infra-p…
caetano-colin b6c863c
update to 2024
caetano-colin 56eceb0
add title and description to ml single project
caetano-colin 2902891
add project_name as variable on ml_single_project
caetano-colin 3742d5b
add missing locals.tf
caetano-colin 5e42646
feat: parametrize prevent_destroy for project key
caetano-colin 7ffece7
Update 4-projects/modules/ml_single_project/outputs.tf
caetano-colin 82f73eb
Update 4-projects/modules/ml_single_project/outputs.tf
caetano-colin 8e861fd
Update 4-projects/modules/ml_infra_projects/variables.tf
caetano-colin 87cbc5f
chore: enabled_apis to locals
caetano-colin 4bb5f13
Merge branch 'refactor/ml-infra-projects' of github.com:caetano-colin…
caetano-colin 6f81967
add space
caetano-colin caafacb
Update 4-projects/modules/ml_single_project/outputs.tf
caetano-colin e6d031b
Update 4-projects/modules/ml_single_project/variables.tf
caetano-colin 8d263ae
Update 4-projects/modules/ml_single_project/variables.tf
caetano-colin e6735c1
Update 4-projects/modules/ml_single_project/variables.tf
caetano-colin 30e67f7
update description
caetano-colin 98b598f
Merge branch 'refactor/ml-infra-projects' of github.com:caetano-colin…
caetano-colin 32ba9ac
chore: add trailing dots to where missing
caetano-colin 83346f5
remove default value
caetano-colin bea34fa
restore dns file
caetano-colin a15a1c8
Merge branch 'main' of github.com:caetano-colin/terraform-google-ente…
caetano-colin a963b03
externalize project suffixes
caetano-colin e30ae29
externalize application name
caetano-colin 5ba54de
add files again
caetano-colin 2955195
remove files again
caetano-colin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
module "ml_infra_project" { | ||
source = "../../modules/ml_infra_projects" | ||
|
||
org_id = local.org_id | ||
folder_id = local.common_folder_name | ||
billing_account = local.billing_account | ||
environment = "common" | ||
key_rings = local.shared_kms_key_ring | ||
business_code = "bu3" | ||
billing_code = "1234" | ||
primary_contact = "[email protected]" | ||
secondary_contact = "[email protected]" | ||
cloud_source_artifacts_repo_name = var.cloud_source_artifacts_repo_name | ||
cloud_source_service_catalog_repo_name = var.cloud_source_service_catalog_repo_name | ||
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 = "" | ||
caetano-colin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
prevent_destroy = var.prevent_destroy | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/** | ||
* Copyright 2021 Google LLC | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
|
@@ -15,6 +15,7 @@ | |
*/ | ||
|
||
locals { | ||
artifacts_project_suffix = "artifacts" | ||
caetano-colin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
artifact_tf_sa_roles = [ | ||
"roles/artifactregistry.admin", | ||
"roles/cloudbuild.builds.editor", | ||
|
@@ -27,16 +28,15 @@ locals { | |
|
||
} | ||
module "app_infra_artifacts_project" { | ||
source = "../../modules/single_project" | ||
# count = local.enable_cloudbuild_deploy ? 1 : 0 | ||
source = "../ml_single_project" | ||
|
||
org_id = local.org_id | ||
billing_account = local.billing_account | ||
folder_id = local.common_folder_name | ||
environment = "common" | ||
org_id = var.org_id | ||
billing_account = var.billing_account | ||
folder_id = var.folder_id | ||
environment = var.environment | ||
project_budget = var.project_budget | ||
project_prefix = local.project_prefix | ||
key_rings = local.shared_kms_key_ring | ||
project_prefix = var.project_prefix | ||
key_rings = var.key_rings | ||
remote_state_bucket = var.remote_state_bucket | ||
activate_apis = [ | ||
"artifactregistry.googleapis.com", | ||
|
@@ -49,48 +49,40 @@ module "app_infra_artifacts_project" { | |
"sourcerepo.googleapis.com", | ||
] | ||
# Metadata | ||
project_suffix = "artifacts" | ||
application_name = "app-infra-artifacts" | ||
billing_code = "1234" | ||
primary_contact = "[email protected]" | ||
secondary_contact = "[email protected]" | ||
business_code = "bu3" | ||
project_suffix = local.artifacts_project_suffix | ||
application_name = "app-infra-artifacts" | ||
caetano-colin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 | ||
project_name = "${var.project_prefix}-${local.env_code}-${var.business_code}${local.artifacts_project_suffix}" | ||
prevent_destroy = var.prevent_destroy | ||
} | ||
|
||
# resource "google_kms_crypto_key" "ml_key" { | ||
# for_each = toset(local.shared_kms_key_ring) | ||
# name = module.app_infra_artifacts_project[0].project_name | ||
# key_ring = each.key | ||
# rotation_period = var.key_rotation_period | ||
# lifecycle { | ||
# prevent_destroy = false | ||
# } | ||
# } | ||
|
||
resource "google_kms_crypto_key_iam_member" "ml_key" { | ||
for_each = module.app_infra_cloudbuild_project[0].kms_keys | ||
for_each = module.app_infra_artifacts_project.kms_keys | ||
crypto_key_id = each.value.id | ||
role = "roles/cloudkms.admin" | ||
member = "serviceAccount:${module.infra_pipelines[0].terraform_service_accounts["bu3-artifact-publish"]}" | ||
member = "serviceAccount:${var.artifacts_infra_pipeline_sa}" | ||
} | ||
|
||
resource "google_project_iam_member" "artifact_tf_sa_roles" { | ||
for_each = toset(local.artifact_tf_sa_roles) | ||
project = module.app_infra_artifacts_project[0].project_id | ||
project = module.app_infra_artifacts_project.project_id | ||
role = each.key | ||
member = "serviceAccount:${module.infra_pipelines[0].terraform_service_accounts["bu3-artifact-publish"]}" | ||
member = "serviceAccount:${var.artifacts_infra_pipeline_sa}" | ||
} | ||
|
||
// Add Service Agent for Cloud Build | ||
resource "google_project_iam_member" "artifact_cloudbuild_agent" { | ||
project = module.app_infra_artifacts_project[0].project_id | ||
project = module.app_infra_artifacts_project.project_id | ||
role = "roles/secretmanager.secretAccessor" | ||
member = "serviceAccount:${module.app_infra_artifacts_project[0].project_number}@cloudbuild.gserviceaccount.com" | ||
member = "serviceAccount:${module.app_infra_artifacts_project.project_number}@cloudbuild.gserviceaccount.com" | ||
} | ||
|
||
// Add Repository for Artifact repo | ||
|
||
resource "google_sourcerepo_repository" "artifact_repo" { | ||
project = module.app_infra_artifacts_project[0].project_id | ||
project = module.app_infra_artifacts_project.project_id | ||
name = var.cloud_source_artifacts_repo_name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
locals { | ||
env_code = element(split("", var.environment), 0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright 2024 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
output "service_catalog_project_id" { | ||
description = "Service Catalog Project ID." | ||
value = try(module.app_service_catalog_project.project_id, "") | ||
} | ||
|
||
output "common_artifacts_project_id" { | ||
description = "App Infra Artifacts Project ID." | ||
value = try(module.app_infra_artifacts_project.project_id, "") | ||
} | ||
|
||
output "service_catalog_repo_name" { | ||
description = "The name of the Service Catalog repository." | ||
value = google_sourcerepo_repository.service_catalog.name | ||
} | ||
|
||
output "service_catalog_repo_id" { | ||
description = "ID of the Service Catalog repository." | ||
value = google_sourcerepo_repository.service_catalog.id | ||
} | ||
|
||
output "artifacts_repo_name" { | ||
description = "The name of the Artifacts repository." | ||
value = google_sourcerepo_repository.artifact_repo.name | ||
} | ||
|
||
output "artifacts_repo_id" { | ||
description = "ID of the Artifacts repository." | ||
value = google_sourcerepo_repository.artifact_repo.id | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change this to ml_infra_projects