-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
904c913
commit a02d91f
Showing
83 changed files
with
4,653 additions
and
785 deletions.
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
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 @@ | ||
# Terraform code in this directory is used on docs as reference/assets. |
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,10 @@ | ||
module "kms_keyring" { | ||
source = "../../modules/ml_kms_keyring" | ||
|
||
keyring_admins = [ | ||
"serviceAccount:${local.projects_step_terraform_service_account_email}" | ||
] | ||
project_id = module.org_kms.project_id | ||
keyring_regions = var.keyring_regions | ||
keyring_name = var.keyring_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,67 @@ | ||
/** | ||
* 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_organization_policies" { | ||
source = "../../modules/ml-org-policies" | ||
|
||
org_id = local.organization_id | ||
folder_id = local.folder_id | ||
|
||
allowed_locations = [ | ||
"in:us-locations" | ||
] | ||
|
||
allowed_vertex_vpc_networks = { | ||
parent_type = "project" | ||
ids = [for instance in module.base_restricted_environment_network : instance.restricted_shared_vpc_project_id], | ||
} | ||
|
||
allowed_vertex_images = [ | ||
"ainotebooks-vm/deeplearning-platform-release/image-family/pytorch-1-13-cu113-notebooks", | ||
"ainotebooks-vm/deeplearning-platform-release/image-family/pytorch-1-13-cu113-notebooks", | ||
"ainotebooks-vm/deeplearning-platform-release/image-family/common-cu113-notebooks", | ||
"ainotebooks-vm/deeplearning-platform-release/image-family/common-cpu-notebooks", | ||
"ainotebooks-container/us-docker.pkg.dev/deeplearning-platform-release/gcr.io/base-cu113.py310", | ||
"ainotebooks-container/us-docker.pkg.dev/deeplearning-platform-release/gcr.io/base-cu113.py37", | ||
"ainotebooks-container/us-docker.pkg.dev/deeplearning-platform-release/gcr.io/base-cu110.py310", | ||
"ainotebooks-container/us-docker.pkg.dev/deeplearning-platform-release/gcr.io/tf2-cpu.2-12.py310", | ||
"ainotebooks-container/us-docker.pkg.dev/deeplearning-platform-release/gcr.io/tf2-gpu.2-12.py310" | ||
] | ||
|
||
restricted_services = [ | ||
"alloydb.googleapis.com" | ||
] | ||
|
||
allowed_integrations = [ | ||
"github.com", | ||
"source.developers.google.com" | ||
] | ||
|
||
restricted_tls_versions = [ | ||
"TLS_VERSION_1", | ||
"TLS_VERSION_1_1" | ||
] | ||
|
||
restricted_non_cmek_services = [ | ||
"bigquery.googleapis.com", | ||
"aiplatform.googleapis.com" | ||
] | ||
|
||
allowed_vertex_access_modes = [ | ||
"single-user", | ||
"service-account" | ||
] | ||
} |
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 @@ | ||
# Terraform code in this directory is used on docs as reference/assets. |
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,33 @@ | ||
/** | ||
* 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 { | ||
logging_key_name = module.env_logs.project_id | ||
} | ||
|
||
// Creates a keyring with logging key for each region (us-central1, us-east4) | ||
module "kms_keyring" { | ||
source = "../ml_kms_keyring" | ||
|
||
keyring_admins = [ | ||
"serviceAccount:${local.projects_step_terraform_service_account_email}" | ||
] | ||
project_id = module.env_kms.project_id | ||
keyring_regions = var.keyring_regions | ||
keyring_name = var.keyring_name | ||
keys = [local.logging_key_name] | ||
kms_prevent_destroy = var.kms_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
data "google_storage_project_service_account" "gcs_logging_account" { | ||
project = module.env_logs.project_id | ||
} | ||
|
||
/****************************************** | ||
Project for Environment Logging | ||
*****************************************/ | ||
|
||
module "env_logs" { | ||
source = "terraform-google-modules/project-factory/google" | ||
version = "~> 14.0" | ||
|
||
random_project_id = true | ||
random_project_id_length = 4 | ||
default_service_account = "deprivilege" | ||
name = "${local.project_prefix}-${var.environment_code}-logging" | ||
org_id = local.org_id | ||
billing_account = local.billing_account | ||
folder_id = google_folder.env.id | ||
activate_apis = ["logging.googleapis.com", "billingbudgets.googleapis.com", "storage.googleapis.com"] | ||
|
||
labels = { | ||
environment = var.env | ||
application_name = "env-logging" | ||
billing_code = "1234" | ||
primary_contact = "example1" | ||
secondary_contact = "example2" | ||
business_code = "abcd" | ||
env_code = var.environment_code | ||
} | ||
budget_alert_pubsub_topic = var.project_budget.logging_alert_pubsub_topic | ||
budget_alert_spent_percents = var.project_budget.logging_alert_spent_percents | ||
budget_amount = var.project_budget.logging_budget_amount | ||
budget_alert_spend_basis = var.project_budget.logging_budget_alert_spend_basis | ||
|
||
} | ||
|
||
// Create Bucket for this project | ||
resource "google_storage_bucket" "log_bucket" { | ||
name = "${var.gcs_bucket_prefix}-${module.env_logs.project_id}" | ||
location = var.gcs_logging_bucket_location | ||
project = module.env_logs.project_id | ||
uniform_bucket_level_access = true | ||
|
||
dynamic "retention_policy" { | ||
for_each = var.gcs_logging_retention_period != null ? [var.gcs_logging_retention_period] : [] | ||
content { | ||
is_locked = var.gcs_logging_retention_period.is_locked | ||
retention_period = var.gcs_logging_retention_period.retention_period_days * 24 * 60 * 60 | ||
} | ||
} | ||
|
||
encryption { | ||
default_kms_key_name = google_kms_crypto_key_iam_member.gcs_logging_key.crypto_key_id #module.kms_keyring.keys_by_region[var.gcs_logging_bucket_location][local.logging_key_name] | ||
} | ||
} | ||
|
||
/****************************************** | ||
Logging Bucket - IAM | ||
*****************************************/ | ||
# resource "google_storage_bucket_iam_member" "bucket_logging" { | ||
# bucket = google_storage_bucket.log_bucket.name | ||
# role = "roles/storage.objectCreator" | ||
# member = "group:[email protected]" | ||
# } | ||
|
||
resource "google_kms_crypto_key_iam_member" "gcs_logging_key" { | ||
crypto_key_id = module.kms_keyring.keys_by_region[var.gcs_logging_bucket_location][local.logging_key_name] | ||
role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" | ||
member = "serviceAccount:${data.google_storage_project_service_account.gcs_logging_account.email_address}" | ||
} |
29 changes: 29 additions & 0 deletions
29
docs/assets/terraform/3-networks-dual-svpc/ml_dns_notebooks.tf
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,29 @@ | ||
/** | ||
* 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_dns_vertex_ai" { | ||
source = "../ml_dns_notebooks" | ||
|
||
project_id = local.restricted_project_id | ||
private_service_connect_ip = var.restricted_private_service_connect_ip | ||
private_visibility_config_networks = [module.restricted_shared_vpc.network_self_link] | ||
zone_names = { | ||
kernels_googleusercontent_zone = "dz-${var.environment_code}-shared-restricted-kernels-googleusercontent" | ||
notebooks_googleusercontent_zone = "dz-${var.environment_code}-shared-restricted-notebooks-googleusercontent" | ||
notebooks_cloudgoogle_zone = "dz-${var.environment_code}-shared-restricted-notebooks" | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
docs/assets/terraform/4-projects/ml_business_unit/development/README.md
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,25 @@ | ||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| default\_region | Default region to create resources where applicable. | `string` | `"us-central1"` | no | | ||
| env | The environment this deployment belongs to (ie. development) | `string` | n/a | yes | | ||
| key\_rotation\_period | Rotation period in seconds to be used for KMS Key | `string` | `"7776000s"` | no | | ||
| location\_gcs | Case-Sensitive Location for GCS Bucket (Should be same region as the KMS Keyring) | `string` | `"US"` | no | | ||
| location\_kms | Case-Sensitive Location for KMS Keyring (Should be same region as the GCS Bucket) | `string` | `"us"` | no | | ||
| peering\_module\_depends\_on | List of modules or resources peering module depends on. | `list(any)` | `[]` | no | | ||
| project\_budget | Budget configuration.<br> budget\_amount: The amount to use as the budget.<br> alert\_spent\_percents: A list of percentages of the budget to alert on when threshold is exceeded.<br> alert\_pubsub\_topic: The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}`.<br> alert\_spend\_basis: The type of basis used to determine if spend has passed the threshold. Possible choices are `CURRENT_SPEND` or `FORECASTED_SPEND` (default). | <pre>object({<br> budget_amount = optional(number, 1000)<br> alert_spent_percents = optional(list(number), [1.2])<br> alert_pubsub_topic = optional(string, null)<br> alert_spend_basis = optional(string, "FORECASTED_SPEND")<br> })</pre> | `{}` | no | | ||
| remote\_state\_bucket | Backend bucket to load Terraform Remote State Data from previous steps. | `string` | n/a | yes | | ||
| tfc\_org\_name | Name of the TFC organization. | `string` | `""` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| enable\_cloudbuild\_deploy | Enable infra deployment using Cloud Build. | | ||
| machine\_learning\_kms\_keys | Key ID for the machine learning project. | | ||
| machine\_learning\_project\_id | Project machine learning project. | | ||
| machine\_learning\_project\_number | Project number of machine learning project. | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
22 changes: 22 additions & 0 deletions
22
docs/assets/terraform/4-projects/ml_business_unit/development/backend.tf
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,22 @@ | ||
/** | ||
* Copyright 2021 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. | ||
*/ | ||
|
||
terraform { | ||
backend "gcs" { | ||
bucket = "UPDATE_PROJECTS_BACKEND" | ||
prefix = "terraform/projects/ml_business_unit/development" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
docs/assets/terraform/4-projects/ml_business_unit/development/backend.tf.cloud.example
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,23 @@ | ||
/** | ||
* Copyright 2023 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. | ||
*/ | ||
|
||
terraform { | ||
cloud { | ||
workspaces { | ||
name = "4-ml-development" | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
docs/assets/terraform/4-projects/ml_business_unit/development/common.auto.tfvars
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 @@ | ||
../../common.auto.tfvars |
1 change: 1 addition & 0 deletions
1
docs/assets/terraform/4-projects/ml_business_unit/development/development.auto.tfvars
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 @@ | ||
../../development.auto.tfvars |
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
Oops, something went wrong.