From e95edf344709a430bc30d889bbb42fbfb21a661e Mon Sep 17 00:00:00 2001 From: Caetano Colin <164910343+caetano-colin@users.noreply.github.com> Date: Wed, 19 Jun 2024 13:52:35 -0300 Subject: [PATCH] feat(docs): Add 5-appinfra instructions to deploy on foundation docs (#49) * adding 5-appinfra * add key * update * update service catalog files * add more details * update docs * add more info * remove trailing whitespace --- README.md | 74 ++-- .../ml_business_unit/shared/outputs.tf | 5 + .../4-projects/shared.auto.example.tfvars | 2 +- .../common.auto.example.tfvars | 19 + .../ml_business_unit/shared/README.md | 15 + .../ml_business_unit/shared/backend.tf | 22 ++ .../shared/common.auto.tfvars | 1 + .../ml_business_unit/shared/locals.tf | 20 + .../ml_business_unit/shared/outputs.tf | 34 ++ .../shared/publish_artifacts.tf | 47 +++ .../ml_business_unit/shared/remote.tf | 31 ++ .../ml_business_unit/shared/variables.tf | 25 ++ .../ml_business_unit/shared/versions.tf | 43 +++ .../5-appinfra/artifacts-pipeline/README.md | 2 + .../images/tf2-cpu.2-13:0.1/Dockerfile | 17 + .../images/tf2-cpu.2-8:01/Dockerfile | 16 + .../images/tf2-gpu.2-13:0.1/Dockerfile | 16 + .../images/vertexpipeline:v2/Dockerfile | 16 + .../modules/publish_artifacts/data.tf | 19 + .../modules/publish_artifacts/locals.tf | 33 ++ .../modules/publish_artifacts/main.tf | 163 ++++++++ .../modules/publish_artifacts/outputs.tf | 20 + .../modules/publish_artifacts/variables.tf | 76 ++++ .../modules/publish_artifacts/versions.tf | 46 +++ .../modules/service_catalog/data.tf | 19 + .../modules/service_catalog/locals.tf | 41 ++ .../modules/service_catalog/main.tf | 145 +++++++ .../modules/service_catalog/outputs.tf | 25 ++ .../modules/service_catalog/variables.tf | 54 +++ .../service-catalog-infra-repo/README.md | 0 .../common.auto.example.tfvars | 28 ++ .../ml_business_unit/shared/README.md | 16 + .../ml_business_unit/shared/backend.tf | 22 ++ .../shared/common.auto.tfvars | 1 + .../ml_business_unit/shared/locals.tf | 21 + .../ml_business_unit/shared/outputs.tf | 25 ++ .../ml_business_unit/shared/remote.tf | 40 ++ .../shared/service_catalog.tf | 36 ++ .../ml_business_unit/shared/variables.tf | 30 ++ .../ml_business_unit/shared/versions.tf | 43 +++ .../service-catalog-pipeline/README.md | 135 +++++++ .../service-catalog-pipeline/img/workflow.png | Bin 0 -> 87776 bytes .../modules/artifact_registry/README.md | 74 ++++ .../modules/artifact_registry/data.tf | 34 ++ .../modules/artifact_registry/locals.tf | 23 ++ .../modules/artifact_registry/main.tf | 64 +++ .../terraform.tfvars.example | 43 +++ .../modules/artifact_registry/variables.tf | 86 +++++ .../modules/bigquery/README.md | 76 ++++ .../modules/bigquery/data.tf | 34 ++ .../modules/bigquery/locals.tf | 21 + .../modules/bigquery/main.tf | 24 ++ .../modules/bigquery/variables.tf | 66 ++++ .../modules/bucket/README.md | 149 +++++++ .../modules/bucket/data.tf | 38 ++ .../modules/bucket/locals.tf | 20 + .../modules/bucket/main.tf | 148 +++++++ .../modules/bucket/outputs.tf | 20 + .../modules/bucket/variables.tf | 186 +++++++++ .../modules/composer/README.md | 129 +++++++ .../modules/composer/data.tf | 66 ++++ .../modules/composer/locals.tf | 74 ++++ .../modules/composer/main.tf | 93 +++++ .../modules/composer/outputs.tf | 40 ++ .../modules/composer/pipeline.tf | 121 ++++++ .../modules/composer/terraform.tfvars.example | 29 ++ .../modules/composer/variables.tf | 138 +++++++ .../modules/composer/vpc.tf | 288 ++++++++++++++ .../modules/metadata/README.md | 70 ++++ .../modules/metadata/data.tf | 34 ++ .../modules/metadata/locals.tf | 19 + .../modules/metadata/main.tf | 26 ++ .../modules/metadata/outputs.tf | 20 + .../modules/metadata/variables.tf | 37 ++ .../modules/notebook/README.md | 137 +++++++ .../modules/notebook/data.tf | 65 ++++ .../modules/notebook/locals.tf | 20 + .../modules/notebook/main.tf | 95 +++++ .../modules/notebook/outputs.tf | 50 +++ .../modules/notebook/variables.tf | 150 ++++++++ .../modules/pubsub/README.md | 82 ++++ .../modules/pubsub/data.tf | 35 ++ .../modules/pubsub/locals.tf | 20 + .../modules/pubsub/main.tf | 39 ++ .../modules/pubsub/outputs.tf | 20 + .../modules/pubsub/variables.tf | 52 +++ .../modules/secrets/README.md | 79 ++++ .../modules/secrets/data.tf | 39 ++ .../modules/secrets/locals.tf | 20 + .../modules/secrets/main.tf | 56 +++ .../modules/secrets/outputs.tf | 20 + .../modules/secrets/variables.tf | 36 ++ .../modules/tensorboard/README.md | 69 ++++ .../modules/tensorboard/data.tf | 36 ++ .../modules/tensorboard/locals.tf | 19 + .../modules/tensorboard/main.tf | 26 ++ .../modules/tensorboard/outputs.tf | 20 + .../modules/tensorboard/variables.tf | 37 ++ docs/deploy_on_foundation_v4.0.0.md | 364 +++++++++++++++++- 99 files changed, 5283 insertions(+), 36 deletions(-) create mode 100644 docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/common.auto.example.tfvars create mode 100644 docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/README.md create mode 100644 docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/backend.tf create mode 120000 docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/common.auto.tfvars create mode 100644 docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/outputs.tf create mode 100644 docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/publish_artifacts.tf create mode 100644 docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/remote.tf create mode 100644 docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/variables.tf create mode 100644 docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/versions.tf create mode 100644 docs/assets/terraform/5-appinfra/artifacts-pipeline/README.md create mode 100644 docs/assets/terraform/5-appinfra/artifacts-pipeline/images/tf2-cpu.2-13:0.1/Dockerfile create mode 100644 docs/assets/terraform/5-appinfra/artifacts-pipeline/images/tf2-cpu.2-8:01/Dockerfile create mode 100644 docs/assets/terraform/5-appinfra/artifacts-pipeline/images/tf2-gpu.2-13:0.1/Dockerfile create mode 100644 docs/assets/terraform/5-appinfra/artifacts-pipeline/images/vertexpipeline:v2/Dockerfile create mode 100644 docs/assets/terraform/5-appinfra/modules/publish_artifacts/data.tf create mode 100644 docs/assets/terraform/5-appinfra/modules/publish_artifacts/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/modules/publish_artifacts/main.tf create mode 100644 docs/assets/terraform/5-appinfra/modules/publish_artifacts/outputs.tf create mode 100644 docs/assets/terraform/5-appinfra/modules/publish_artifacts/variables.tf create mode 100644 docs/assets/terraform/5-appinfra/modules/publish_artifacts/versions.tf create mode 100644 docs/assets/terraform/5-appinfra/modules/service_catalog/data.tf create mode 100644 docs/assets/terraform/5-appinfra/modules/service_catalog/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/modules/service_catalog/main.tf create mode 100644 docs/assets/terraform/5-appinfra/modules/service_catalog/outputs.tf create mode 100644 docs/assets/terraform/5-appinfra/modules/service_catalog/variables.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-infra-repo/README.md create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-infra-repo/common.auto.example.tfvars create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/README.md create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/backend.tf create mode 120000 docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/common.auto.tfvars create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/outputs.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/remote.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/service_catalog.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/variables.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/versions.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/README.md create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/img/workflow.png create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/artifact_registry/README.md create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/artifact_registry/data.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/artifact_registry/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/artifact_registry/main.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/artifact_registry/terraform.tfvars.example create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/artifact_registry/variables.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/bigquery/README.md create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/bigquery/data.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/bigquery/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/bigquery/main.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/bigquery/variables.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/bucket/README.md create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/bucket/data.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/bucket/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/bucket/main.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/bucket/outputs.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/bucket/variables.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/composer/README.md create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/composer/data.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/composer/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/composer/main.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/composer/outputs.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/composer/pipeline.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/composer/terraform.tfvars.example create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/composer/variables.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/composer/vpc.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/metadata/README.md create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/metadata/data.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/metadata/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/metadata/main.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/metadata/outputs.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/metadata/variables.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/notebook/README.md create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/notebook/data.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/notebook/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/notebook/main.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/notebook/outputs.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/notebook/variables.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/pubsub/README.md create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/pubsub/data.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/pubsub/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/pubsub/main.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/pubsub/outputs.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/pubsub/variables.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/secrets/README.md create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/secrets/data.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/secrets/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/secrets/main.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/secrets/outputs.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/secrets/variables.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/tensorboard/README.md create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/tensorboard/data.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/tensorboard/locals.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/tensorboard/main.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/tensorboard/outputs.tf create mode 100644 docs/assets/terraform/5-appinfra/service-catalog-pipeline/modules/tensorboard/variables.tf diff --git a/README.md b/README.md index 8f063b27..e045d440 100644 --- a/README.md +++ b/README.md @@ -2,36 +2,44 @@ ## Overview -This repository serves as a example for configuring an environment for the development and deployment of Machine Learning applications using the Vertex AI platform on Google Cloud. It seamlessly integrates the Cloud Foundation Toolkit (CFT) and implements robust security measures, drawing heavily from the [terraform-google-enterprise-genai](https://github.com/terraform-google-modules/terraform-google-enterprise-genai/tree/v4.0.0) codebase. - -The repo is separated in distinct Terraform projects, each within their own directory that must be applied separately, but in sequence, for more information about each step, please refer to [terraform-google-enterprise-genai](https://github.com/terraform-google-modules/terraform-google-enterprise-genai/tree/v4.0.0). Comparing to the foundation repository, the key differences from the steps in foundation to steps in these repository are: - -Alternatively, the user can follow steps on [`docs/deploy_on_foundation_v4.0.0.md`](./docs/deploy_on_foundation_v4.0.0.md), to deploy the codebase on top of an existing foundation instance. - -* [1. org](./1-org/) - * Specific to this repository, it will also configure Machine Learning Organization Policies. -* [2. environments](./2-environments/) - * This repository will also establish organization and environment-level Cloud Key Management Service (KMS) keyrings during this stage. -* [3. networks-dual-svpc](./3-networks-dual-svpc/) - * On this repository, it will also configure a private DNS zone for workbench instances to use either `private.googleapis.com` or `restricted.googleapis.com`. -* [4. projects](./4-projects/) - * Instead of creating `business_unit_1` and `business_unit_2`, this repository exclusively creates `business_unit_3`. - * Additionally, it will establish a Service Catalog project capable of hosting terraform solutions and an artifacts project. - * Will create a Machine Learning project for each environment. -* [5. app-infra](./5-app-infra/) - * The purpose of this step is to execute a series of steps necessary to deploy and run a Machine Learning Application. - -Additional steps were added to provide an example Machine Learning application: - -* [machine-learning-pipeline](./examples/machine-learning-pipeline) - * This additional step, adds an interactive coding and experimentation, deploying the Vertex Workbench for data scientists. - * The step will guide you through creating a ML pipeline using a notebook on Google Vertex AI Workbench Instance. - * After promoting the ML pipeline, it is triggered by Cloud Build upon staging branch merges, trains and deploys a model using the census income dataset. - * Model deployment and monitoring occur in the prod environment. - * Following successful pipeline runs, a new model version is deployed for A/B testing. - -* [7. composer](./7-composer/) - * Used for code reference. - -* [7. vertexpipeline](./7-vertexpipeline/) - * Used for code reference, will be used for creating the Machine Learning pipeline. +This repository serves as a example for configuring an environment for the development and deployment of Machine Learning applications using the Vertex AI platform on Google Cloud. It seamlessly integrates the Cloud Foundation Toolkit (CFT) and implements robust security measures, drawing heavily from the [terraform-example-foundation v4.0.0](https://github.com/terraform-google-modules/terraform-example-foundation/tree/v4.0.0) codebase. + +The repository is divided into distinct Terraform projects, each located in its own directory. These projects must be applied separately but in sequence. For detailed information about each step, please refer to [terraform-example-foundation v4.0.0](https://github.com/terraform-google-modules/terraform-example-foundation/tree/v4.0.0). The user has two options when deploying this codebase: + +- Following the individual project steps as outlined in this repository, under `0-bootstrap` to `5-appinfra` directories. +- Deploy the codebase on top of an existing Enterprise Foundations Blueprint instance by following the steps detailed in [`docs/deploy_on_foundation_v4.0.0.md`](./docs/deploy_on_foundation_v4.0.0.md). + > NOTE: If the user currently does not have a Enterprise Foundations Blueprint deployed, he can follow the steps outlined in [terraform-example-foundation v4.0.0](https://github.com/terraform-google-modules/terraform-example-foundation/tree/v4.0.0) to deploy it. + +## Main Modifications made to Enterprise Foundations Blueprint + +- [1. org](./1-org/) + - Specific to this repository, it will also configure Machine Learning Organization Policies. + - Create Organization Level Keyring. +- [2. environments](./2-environments/) + - This repository will also establish organization and environment-level Cloud Key Management Service (KMS) keyrings during this stage. + - Create support for environment-level logging. +- [3. networks-dual-svpc](./3-networks-dual-svpc/) + - On this repository, it will also configure a private DNS zone for workbench instances to use either `private.googleapis.com` or `restricted.googleapis.com`. + - Custom Firewall Rules (`allow_all_ingress_ranges` and `allow_all_egress_ranges`). + - Enable Cloud NAT. + - Attach Environment-level Logging Project and Environment-level KMS Project to VPC-SC Perimeter. +- [4. projects](./4-projects/) + - Instead of creating `business_unit_1` and `business_unit_2`, this repository will create `ml_business_unit`. + - Additionally, it will establish a Service Catalog project capable of hosting terraform solutions and an Artifacts project, both under the `common` folder. + - Will create a Machine Learning project for each environment, that is inside a VPC-SC Perimeter and can be used for deploying Machine Learning Workloads. +- [5. app-infra](./5-app-infra/) + - Deploys a Service Catalog Pipeline, that can be used for packaging terraform modules. + - Creates an Artifacts Pipeline, that can be used to create organization-wide custom docker images. + +## Examples + +- [genai-rag-multimodal](./examples/genai-rag-multimodal) + - Multimodal RAG by performing Q&A over a financial document filled with both text and images. + - Use RAGAS for RAG chain evaluation. + +- [machine-learning-pipeline](./examples/machine-learning-pipeline) + - This example, adds an interactive coding and experimentation, deploying the Vertex Workbench for data scientists. + - The step will guide you through creating a ML pipeline using a notebook on Google Vertex AI Workbench Instance. + - After promoting the ML pipeline, it is triggered by Cloud Build upon staging branch merges, trains and deploys a model using the census income dataset. + - Model deployment and monitoring occur in the prod environment. + - Following successful pipeline runs, a new model version is deployed for A/B testing. diff --git a/docs/assets/terraform/4-projects/ml_business_unit/shared/outputs.tf b/docs/assets/terraform/4-projects/ml_business_unit/shared/outputs.tf index 88c5d34c..ccd45012 100644 --- a/docs/assets/terraform/4-projects/ml_business_unit/shared/outputs.tf +++ b/docs/assets/terraform/4-projects/ml_business_unit/shared/outputs.tf @@ -92,3 +92,8 @@ output "artifacts_repo_id" { description = "ID of the Artifacts repository" value = module.ml_infra_projects.artifacts_repo_id } + +output "shared_level_keyrings" { + description = "Keyrings used on shared level project creation" + value = local.shared_kms_key_ring +} diff --git a/docs/assets/terraform/4-projects/shared.auto.example.tfvars b/docs/assets/terraform/4-projects/shared.auto.example.tfvars index 4ecf95cf..7e6d1ada 100644 --- a/docs/assets/terraform/4-projects/shared.auto.example.tfvars +++ b/docs/assets/terraform/4-projects/shared.auto.example.tfvars @@ -17,6 +17,6 @@ # We suggest you to use the same region from the 0-bootstrap step default_region = "us-central1" -cloud_source_service_catalog_repo_name = "svc-catalog" +cloud_source_service_catalog_repo_name = "service-catalog" cloud_source_artifacts_repo_name = "publish-artifacts" diff --git a/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/common.auto.example.tfvars b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/common.auto.example.tfvars new file mode 100644 index 00000000..7f83f05b --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/common.auto.example.tfvars @@ -0,0 +1,19 @@ +/** + * 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. + */ + +instance_region = "us-central1" // should be one of the regions used to create network on step 3-networks + +remote_state_bucket = "REMOTE_STATE_BUCKET" diff --git a/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/README.md b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/README.md new file mode 100644 index 00000000..c255b2ef --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/README.md @@ -0,0 +1,15 @@ + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| instance\_region | The region where compute instance will be created. A subnetwork must exists in the instance region. | `string` | n/a | yes | +| remote\_state\_bucket | Backend bucket to load remote state information from previous steps. | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| cloudbuild\_trigger\_id | n/a | + + diff --git a/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/backend.tf b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/backend.tf new file mode 100644 index 00000000..0b671313 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/backend.tf @@ -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_APP_INFRA_BUCKET" + prefix = "terraform/app-infra/ml_business_unit/shared" + } +} diff --git a/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/common.auto.tfvars b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/common.auto.tfvars new file mode 120000 index 00000000..39aaa462 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/common.auto.tfvars @@ -0,0 +1 @@ +../../common.auto.tfvars \ No newline at end of file diff --git a/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/locals.tf b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/locals.tf new file mode 100644 index 00000000..d049424c --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/locals.tf @@ -0,0 +1,20 @@ +/** + * 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. + */ + +locals { + business_unit = "ml_business_unit" + environment = "common" +} diff --git a/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/outputs.tf b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/outputs.tf new file mode 100644 index 00000000..11e2aade --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/outputs.tf @@ -0,0 +1,34 @@ +/** + * 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. + */ + +# output "trigger_sa_account_id" { +# description = "Account id of service account cloudbuild." +# value = module.artifact_pipeline.trigger_sa_account_id +# } + +# output "cloudbuild_v2_repo_id" { +# description = "Repository ID of cloudbuild repository" +# value = module.artifact_pipeline.cloudbuild_v2_repo_id +# } + +# output "kms_key_id" { +# description = "Projects Key ID for encrytion" +# value = module.artifact_pipeline.kms_key_id +# } + +output "cloudbuild_trigger_id" { + value = module.artifact_publish.cloudbuild_trigger_id +} diff --git a/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/publish_artifacts.tf b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/publish_artifacts.tf new file mode 100644 index 00000000..2d535968 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/publish_artifacts.tf @@ -0,0 +1,47 @@ +/** + * 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. + */ + +locals { + region_kms_keyring = [for i in local.shared_keyrings : i if split("/", i)[3] == var.instance_region] +} + +data "google_project" "common_artifacts" { + project_id = local.common_artifacts_project_id +} + +module "artifact_publish" { + source = "../../modules/publish_artifacts" + + environment = local.environment + description = "Publish Artifacts for ML Projects" + project_id = local.common_artifacts_project_id + name = local.artifacts_repo_name + format = "DOCKER" + region = var.instance_region + cleanup_policies = [{ + id = "keep-tagged-release" + action = "KEEP" + condition = [ + { + tag_state = "TAGGED", + tag_prefixes = ["release"], + package_name_prefixes = ["webapp", "mobile"] + } + ] + }] + + kms_crypto_key = "${one(local.region_kms_keyring)}/cryptoKeys/${data.google_project.common_artifacts.name}" +} diff --git a/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/remote.tf b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/remote.tf new file mode 100644 index 00000000..c98f85b7 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/remote.tf @@ -0,0 +1,31 @@ +/** + * 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. + */ + +locals { + common_artifacts_project_id = data.terraform_remote_state.projects_shared.outputs.common_artifacts_project_id + service_catalog_project_id = data.terraform_remote_state.projects_shared.outputs.service_catalog_project_id + artifacts_repo_name = data.terraform_remote_state.projects_shared.outputs.artifacts_repo_name + shared_keyrings = data.terraform_remote_state.projects_shared.outputs.shared_level_keyrings +} + +data "terraform_remote_state" "projects_shared" { + backend = "gcs" + + config = { + bucket = var.remote_state_bucket + prefix = "terraform/projects/${local.business_unit}/shared" + } +} diff --git a/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/variables.tf b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/variables.tf new file mode 100644 index 00000000..8e9bafd0 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/variables.tf @@ -0,0 +1,25 @@ +/** + * 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. + */ + +variable "instance_region" { + description = "The region where compute instance will be created. A subnetwork must exists in the instance region." + type = string +} + +variable "remote_state_bucket" { + description = "Backend bucket to load remote state information from previous steps." + type = string +} diff --git a/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/versions.tf b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/versions.tf new file mode 100644 index 00000000..baa38abb --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifact-publish-infra-repo/ml_business_unit/shared/versions.tf @@ -0,0 +1,43 @@ +/** + * Copyright 2022 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 { + required_version = ">= 0.13" + + required_providers { + + google = { + source = "hashicorp/google" + version = ">= 3.77, < 6" + } + + google-beta = { + source = "hashicorp/google-beta" + version = ">= 3.77, < 6" + } + + null = { + source = "hashicorp/null" + version = "~> 3.0" + } + + random = { + source = "hashicorp/random" + version = "~> 3.1" + } + + } +} diff --git a/docs/assets/terraform/5-appinfra/artifacts-pipeline/README.md b/docs/assets/terraform/5-appinfra/artifacts-pipeline/README.md new file mode 100644 index 00000000..365d29e8 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifacts-pipeline/README.md @@ -0,0 +1,2 @@ +# ml-foundations-docker +Dockerfile repository for ml-foundations artifacts project diff --git a/docs/assets/terraform/5-appinfra/artifacts-pipeline/images/tf2-cpu.2-13:0.1/Dockerfile b/docs/assets/terraform/5-appinfra/artifacts-pipeline/images/tf2-cpu.2-13:0.1/Dockerfile new file mode 100644 index 00000000..731a8e02 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifacts-pipeline/images/tf2-cpu.2-13:0.1/Dockerfile @@ -0,0 +1,17 @@ +# 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 +# +# https://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. +# +FROM us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-13:latest +RUN echo "Hello World" > helloworld.txt + diff --git a/docs/assets/terraform/5-appinfra/artifacts-pipeline/images/tf2-cpu.2-8:01/Dockerfile b/docs/assets/terraform/5-appinfra/artifacts-pipeline/images/tf2-cpu.2-8:01/Dockerfile new file mode 100644 index 00000000..d1d7fc14 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifacts-pipeline/images/tf2-cpu.2-8:01/Dockerfile @@ -0,0 +1,16 @@ +# 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 +# +# https://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. +# +FROM us-docker.pkg.dev/cloud-aiplatform/prediction/tf2-cpu.2-8:cmle_op_images_20240312_0210_RC00 + diff --git a/docs/assets/terraform/5-appinfra/artifacts-pipeline/images/tf2-gpu.2-13:0.1/Dockerfile b/docs/assets/terraform/5-appinfra/artifacts-pipeline/images/tf2-gpu.2-13:0.1/Dockerfile new file mode 100644 index 00000000..d8015e53 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifacts-pipeline/images/tf2-gpu.2-13:0.1/Dockerfile @@ -0,0 +1,16 @@ +# 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 +# +# https://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. +# +FROM us-docker.pkg.dev/vertex-ai/prediction/tf2-gpu.2-13:latest +RUN echo "Hello World" > helloworld.txt diff --git a/docs/assets/terraform/5-appinfra/artifacts-pipeline/images/vertexpipeline:v2/Dockerfile b/docs/assets/terraform/5-appinfra/artifacts-pipeline/images/vertexpipeline:v2/Dockerfile new file mode 100644 index 00000000..b466e248 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/artifacts-pipeline/images/vertexpipeline:v2/Dockerfile @@ -0,0 +1,16 @@ +# 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 +# +# https://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. +# +FROM tensorflow/tensorflow:2.8.0 +RUN pip install tensorflow-io==0.25.0 protobuf==3.20.0 google-cloud-bigquery==3.13.0 pandas==2.0.3 db-dtypes==1.2.0 google-cloud-aiplatform==1.36.0 google-cloud-storage==2.14.0 kfp google-cloud-pipeline-components diff --git a/docs/assets/terraform/5-appinfra/modules/publish_artifacts/data.tf b/docs/assets/terraform/5-appinfra/modules/publish_artifacts/data.tf new file mode 100644 index 00000000..4671af93 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/modules/publish_artifacts/data.tf @@ -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. + */ + +data "google_project" "project" { + project_id = var.project_id +} diff --git a/docs/assets/terraform/5-appinfra/modules/publish_artifacts/locals.tf b/docs/assets/terraform/5-appinfra/modules/publish_artifacts/locals.tf new file mode 100644 index 00000000..2e394621 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/modules/publish_artifacts/locals.tf @@ -0,0 +1,33 @@ +/** + * 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. + */ + +locals { + env_code = substr(var.environment, 0, 1) + name_var = format("%s-%s", local.env_code, var.name) + # key_ring_var = "projects/${var.cmek_project_id}/locations/${var.region}/keyRings/sample-keyring" + region_short_code = { + "us-central1" = "usc1" + "us-east4" = "use4" + } + # github_owner = split("/", split("https://github.com/", var.github_remote_uri)[1])[0] + # github_repo_name = trim(basename(var.github_remote_uri), ".git") + + trigger_sa_roles = [ + "roles/artifactregistry.reader", + "roles/artifactregistry.writer", + ] + # github_repository = replace(var.github_remote_uri, "https://", "") +} diff --git a/docs/assets/terraform/5-appinfra/modules/publish_artifacts/main.tf b/docs/assets/terraform/5-appinfra/modules/publish_artifacts/main.tf new file mode 100644 index 00000000..c8c8ed6f --- /dev/null +++ b/docs/assets/terraform/5-appinfra/modules/publish_artifacts/main.tf @@ -0,0 +1,163 @@ +/** + * 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. + */ +resource "google_project_service_identity" "artifact_registry_agent" { + provider = google-beta + + project = var.project_id + service = "artifactregistry.googleapis.com" +} + +resource "google_kms_crypto_key_iam_member" "artifact-kms-key-binding" { + crypto_key_id = var.kms_crypto_key + role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" + member = "serviceAccount:${google_project_service_identity.artifact_registry_agent.email}" +} + +resource "google_artifact_registry_repository" "repo" { + provider = google-beta + location = var.region + repository_id = local.name_var + description = var.description + format = var.format + cleanup_policy_dry_run = var.cleanup_policy_dry_run + project = data.google_project.project.project_id + + #Customer Managed Encryption Keys + #Control ID: COM-CO-2.3 + #NIST 800-53: SC-12 SC-13 + #CRI Profile: PR.DS-1.1 PR.DS-1.2 PR.DS-2.1 PR.DS-2.2 PR.DS-5.1 + + kms_key_name = var.kms_crypto_key + + #Cleanup policy + #Control ID: AR-CO-6.1 + #NIST 800-53: SI-12 + #CRI Profile: PR.IP-2.1 PR.IP-2.2 PR.IP-2.3 + + dynamic "cleanup_policies" { + for_each = var.cleanup_policies + content { + id = cleanup_policies.value.id + action = cleanup_policies.value.action + + dynamic "condition" { + for_each = cleanup_policies.value.condition != null ? [cleanup_policies.value.condition] : [] + content { + tag_state = condition.value[0].tag_state + tag_prefixes = condition.value[0].tag_prefixes + package_name_prefixes = condition.value[0].package_name_prefixes + older_than = condition.value[0].older_than + } + } + + dynamic "most_recent_versions" { + for_each = cleanup_policies.value.most_recent_versions != null ? [cleanup_policies.value.most_recent_versions] : [] + content { + package_name_prefixes = most_recent_versions.value[0].package_name_prefixes + keep_count = most_recent_versions.value[0].keep_count + } + } + } + } + depends_on = [ + google_kms_crypto_key_iam_member.artifact-kms-key-binding, + + ] +} +resource "google_artifact_registry_repository_iam_member" "project" { + for_each = toset(local.trigger_sa_roles) + project = var.project_id + repository = google_artifact_registry_repository.repo.repository_id + location = var.region + role = each.key + # member = "serviceAccount:${google_service_account.trigger_sa.email}" + member = "serviceAccount:${data.google_project.project.number}@cloudbuild.gserviceaccount.com" +} + +# resource "google_sourcerepo_repository" "artifact_repo" { +# project = var.project_id +# name = var.name +# } +resource "google_cloudbuild_trigger" "docker_build" { + name = "docker-build" + project = var.project_id + location = var.region + + trigger_template { + branch_name = "^main$" + repo_name = var.name + } + build { + timeout = "1800s" + step { + id = "unshallow" + name = "gcr.io/cloud-builders/git" + entrypoint = "/bin/bash" + args = [ + "-c", + "git fetch --unshallow" + ] + } + step { + id = "select-folder" + name = "gcr.io/cloud-builders/git" + entrypoint = "/bin/bash" + args = [ + "-c", + <<-EOT + changed_files=$(git diff $${COMMIT_SHA}^1 --name-only -r) + changed_folders=$(echo "$changed_files" | awk -F/ '{print $2}' | sort | uniq ) + + for folder in $changed_folders; do + echo "Found docker folder: $folder" + echo $folder >> /workspace/docker_build + done + EOT + ] + } + step { + id = "build-image" + wait_for = ["select-folder"] + name = "gcr.io/cloud-builders/docker" + entrypoint = "/bin/bash" + args = [ + "-c", + <<-EOT + build_path="/workspace/docker_build" + while IFS= read -r line; do + docker build -t ${var.region}-docker.pkg.dev/$PROJECT_ID/c-publish-artifacts/$line images/$line + done < "$build_path" + EOT + ] + } + + step { + id = "push-image" + wait_for = ["select-folder", "build-image"] + name = "gcr.io/cloud-builders/docker" + entrypoint = "/bin/bash" + args = [ + "-c", + <<-EOT + build_path="/workspace/docker_build" + while IFS= read -r line; do + docker push ${var.region}-docker.pkg.dev/$PROJECT_ID/c-publish-artifacts/$line + done < "$build_path" + EOT + ] + } + } +} diff --git a/docs/assets/terraform/5-appinfra/modules/publish_artifacts/outputs.tf b/docs/assets/terraform/5-appinfra/modules/publish_artifacts/outputs.tf new file mode 100644 index 00000000..668f4e96 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/modules/publish_artifacts/outputs.tf @@ -0,0 +1,20 @@ +/** + * 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. + */ + +output "cloudbuild_trigger_id" { + value = google_cloudbuild_trigger.docker_build.id +} + diff --git a/docs/assets/terraform/5-appinfra/modules/publish_artifacts/variables.tf b/docs/assets/terraform/5-appinfra/modules/publish_artifacts/variables.tf new file mode 100644 index 00000000..18e8a528 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/modules/publish_artifacts/variables.tf @@ -0,0 +1,76 @@ +/** + * 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. + */ + +variable "region" { + description = "Location of the repository." + type = string +} +variable "name" { + description = "Name of the repository." + type = string +} + +variable "description" { + description = "Description of the repository." + type = string +} + +variable "format" { + description = "Format of the repository." + type = string +} + +variable "cleanup_policy_dry_run" { + description = "Whether to perform a dry run of the cleanup policy." + type = bool + default = false +} + +variable "cleanup_policies" { + description = "List of cleanup policies." + type = list(object({ + id = string + action = optional(string) + condition = optional(list(object({ + tag_state = optional(string) + tag_prefixes = optional(list(string)) + package_name_prefixes = optional(list(string)) + older_than = optional(string) + }))) + most_recent_versions = optional(list(object({ + package_name_prefixes = optional(list(string)) + keep_count = optional(number) + }))) + })) +} + +variable "environment" { + type = string + description = "development | staging | production | commmon" + validation { + condition = contains(["development", "staging", "production", "common"], var.environment) + error_message = "Environment must be one of [development, staging, production]." + } +} + +variable "project_id" { + description = "Project ID" +} + +variable "kms_crypto_key" { + description = "KMS Key to be used" + type = string +} diff --git a/docs/assets/terraform/5-appinfra/modules/publish_artifacts/versions.tf b/docs/assets/terraform/5-appinfra/modules/publish_artifacts/versions.tf new file mode 100644 index 00000000..7fb6a704 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/modules/publish_artifacts/versions.tf @@ -0,0 +1,46 @@ +/** + * 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 { + required_version = ">= 0.13" + required_providers { + google = { + source = "hashicorp/google" + version = ">= 3.61" + } + google-beta = { + source = "hashicorp/google-beta" + version = ">= 3.61" + } + null = { + source = "hashicorp/null" + version = "~> 3.0" + } + + random = { + source = "hashicorp/random" + version = "~> 3.1" + } + } + + provider_meta "google" { + module_name = "blueprints/terraform/terraform-google-enterprise-genai:app_env_base/v0.0.1" + } + + provider_meta "google-beta" { + module_name = "blueprints/terraform/terraform-google-enterprise-genai:app_env_base/v0.0.1" + } +} diff --git a/docs/assets/terraform/5-appinfra/modules/service_catalog/data.tf b/docs/assets/terraform/5-appinfra/modules/service_catalog/data.tf new file mode 100644 index 00000000..4671af93 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/modules/service_catalog/data.tf @@ -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. + */ + +data "google_project" "project" { + project_id = var.project_id +} diff --git a/docs/assets/terraform/5-appinfra/modules/service_catalog/locals.tf b/docs/assets/terraform/5-appinfra/modules/service_catalog/locals.tf new file mode 100644 index 00000000..1d4c7e5a --- /dev/null +++ b/docs/assets/terraform/5-appinfra/modules/service_catalog/locals.tf @@ -0,0 +1,41 @@ +/** + * 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. + */ + +locals { + # github_repository = replace(var.github_remote_uri, "https://", "") + log_bucket_prefix = "bkt" + bucket_permissions = { + + "roles/storage.admin" = [ + "serviceAccount:${data.google_project.project.number}@cloudbuild.gserviceaccount.com" + ], + "roles/storage.legacyObjectReader" = [ + "serviceAccount:${var.machine_learning_project_number}@cloudbuild.gserviceaccount.com", + ], + } + + bucket_roles = flatten([ + for role in keys(local.bucket_permissions) : [ + for sa in local.bucket_permissions[role] : + { + role = role + acct = sa + } + ] + ]) +} + + diff --git a/docs/assets/terraform/5-appinfra/modules/service_catalog/main.tf b/docs/assets/terraform/5-appinfra/modules/service_catalog/main.tf new file mode 100644 index 00000000..4aa6cde0 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/modules/service_catalog/main.tf @@ -0,0 +1,145 @@ +/** + * 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. + */ + +# resource "google_project_service_identity" "storage_agent" { +# provider = google-beta + +# project = var.project_id +# service = "storage.googleapis.com" +# } +# resource "google_kms_crypto_key_iam_member" "storage-kms-key-binding" { +# crypto_key_id = var.kms_crypto_key +# role = "roles/cloudkms.cryptoKeyEncrypterDecrypter" +# member = "serviceAccount:${google_project_service_identity.storage_agent.email}" +# } + +resource "random_string" "bucket_name" { + length = 4 + upper = false + numeric = true + lower = true + special = false +} + +resource "google_storage_bucket" "bucket" { + location = var.region + name = "${var.gcs_bucket_prefix}-${var.project_id}-${lower(var.region)}-${random_string.bucket_name.result}" + project = var.project_id + uniform_bucket_level_access = true + + encryption { + default_kms_key_name = var.kms_crypto_key + } + versioning { + enabled = true + } + logging { + log_bucket = var.log_bucket + } + +} + +resource "google_storage_bucket_iam_member" "bucket_role" { + for_each = { for gcs in local.bucket_roles : "${gcs.role}-${gcs.acct}" => gcs } + bucket = google_storage_bucket.bucket.name + role = each.value.role + member = each.value.acct +} + +# resource "google_sourcerepo_repository" "service_catalog" { +# project = var.project_id +# name = var.name +# } + +resource "google_sourcerepo_repository_iam_member" "read" { + project = var.project_id + repository = var.name + role = "roles/viewer" + member = "serviceAccount:${var.tf_service_catalog_sa_email}" +} + +resource "google_cloudbuild_trigger" "zip_files" { + name = "zip-tf-files-trigger" + project = var.project_id + location = var.region + + # repository_event_config { + # repository = var.cloudbuild_repo_id + # push { + # branch = "^main$" + # } + # } + + trigger_template { + branch_name = "^main$" + repo_name = var.name + } + + build { + # step { + # id = "unshallow" + # name = "gcr.io/cloud-builders/git" + # secret_env = ["token"] + # entrypoint = "/bin/bash" + # args = [ + # "-c", + # "git fetch --unshallow https://$token@${local.github_repository}" + # ] + + # } + step { + id = "unshallow" + name = "gcr.io/cloud-builders/git" + entrypoint = "/bin/bash" + args = [ + "-c", + "git fetch --unshallow" + ] + + } + # available_secrets { + # secret_manager { + # env = "token" + # version_name = var.secret_version_name + # } + # } + step { + id = "find-folders-affected-in-push" + name = "gcr.io/cloud-builders/git" + entrypoint = "/bin/bash" + args = [ + "-c", + <<-EOT + changed_files=$(git diff $${COMMIT_SHA}^1 --name-only -r) + changed_folders=$(echo "$changed_files" | awk -F/ '{print $2}' | sort | uniq ) + + for folder in $changed_folders; do + if [[ "$folder" != *.* ]]; then + echo "Found change in folder: $folder" + (cd modules/$folder && find . -type f -name '*.tf' -exec tar -cvzPf "/workspace/$folder.tar.gz" {} +) + fi + done + EOT + ] + } + step { + id = "push-to-bucket" + name = "gcr.io/cloud-builders/gsutil" + args = ["cp", "/workspace/*.tar.gz", "gs://${google_storage_bucket.bucket.name}/modules/"] + } + } +} + diff --git a/docs/assets/terraform/5-appinfra/modules/service_catalog/outputs.tf b/docs/assets/terraform/5-appinfra/modules/service_catalog/outputs.tf new file mode 100644 index 00000000..9efe0568 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/modules/service_catalog/outputs.tf @@ -0,0 +1,25 @@ +/** + * 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. + */ + +output "storage_bucket_name" { + description = "Name of storage bucket created" + value = google_storage_bucket.bucket.name +} + +output "cloudbuild_trigger_id" { + description = "Id of Cloud Build Trigger" + value = google_cloudbuild_trigger.zip_files.id +} diff --git a/docs/assets/terraform/5-appinfra/modules/service_catalog/variables.tf b/docs/assets/terraform/5-appinfra/modules/service_catalog/variables.tf new file mode 100644 index 00000000..c3e72086 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/modules/service_catalog/variables.tf @@ -0,0 +1,54 @@ +/** + * 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. + */ + +variable "name" { + description = "Name of the repository." + type = string +} +variable "region" { + description = "Location of the repository." + type = string +} + +variable "project_id" { + description = "Project ID" + type = string +} + +variable "gcs_bucket_prefix" { + description = "Prefix of the bucket name" + default = "bkt" +} + +variable "tf_service_catalog_sa_email" { + description = "Full email of the terraform service account for service-catalog" + type = string +} + +variable "machine_learning_project_number" { + description = "Project Number for the Machine Learning (Vertex) Project" + type = string +} + +variable "kms_crypto_key" { + description = "KMS Key to be used" + type = string +} + +variable "log_bucket" { + description = "Bucket to store logs from service catalog bucket" + type = string +} diff --git a/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/README.md b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/README.md new file mode 100644 index 00000000..e69de29b diff --git a/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/common.auto.example.tfvars b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/common.auto.example.tfvars new file mode 100644 index 00000000..a9f152f5 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/common.auto.example.tfvars @@ -0,0 +1,28 @@ +/** + * 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. + */ + +instance_region = "us-central1" // should be one of the regions used to create network on step 3-networks + +remote_state_bucket = "REMOTE_STATE_BUCKET" + +log_bucket = "REPLACE_LOG_BUCKET" + +# github_ api_ token = "PUT IN TOKEN" + +# github_app_installation_id = "18685983" + +# github_remote_uri = "https://github.com/badal-io/ml-foundations-tf-modules.git" + diff --git a/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/README.md b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/README.md new file mode 100644 index 00000000..849fc76c --- /dev/null +++ b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/README.md @@ -0,0 +1,16 @@ + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| instance\_region | The region where compute instance will be created. A subnetwork must exists in the instance region. | `string` | n/a | yes | +| remote\_state\_bucket | Backend bucket to load remote state information from previous steps. | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| cloudbuild\_trigger\_id | Id of Cloud Build Trigger | +| storage\_bucket\_name | Name of storage bucket created | + + diff --git a/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/backend.tf b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/backend.tf new file mode 100644 index 00000000..0b671313 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/backend.tf @@ -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_APP_INFRA_BUCKET" + prefix = "terraform/app-infra/ml_business_unit/shared" + } +} diff --git a/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/common.auto.tfvars b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/common.auto.tfvars new file mode 120000 index 00000000..39aaa462 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/common.auto.tfvars @@ -0,0 +1 @@ +../../common.auto.tfvars \ No newline at end of file diff --git a/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/locals.tf b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/locals.tf new file mode 100644 index 00000000..09352bd6 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/locals.tf @@ -0,0 +1,21 @@ +/** + * 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. + */ + +locals { + business_unit = "ml_business_unit" + environment = "common" +} + diff --git a/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/outputs.tf b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/outputs.tf new file mode 100644 index 00000000..22d794b2 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/outputs.tf @@ -0,0 +1,25 @@ +/** + * 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. + */ + +output "storage_bucket_name" { + description = "Name of storage bucket created" + value = module.service_catalog.storage_bucket_name +} + +output "cloudbuild_trigger_id" { + description = "Id of Cloud Build Trigger" + value = module.service_catalog.cloudbuild_trigger_id +} diff --git a/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/remote.tf b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/remote.tf new file mode 100644 index 00000000..366949d7 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/remote.tf @@ -0,0 +1,40 @@ +/** + * 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. + */ + +locals { + service_catalog_project_id = data.terraform_remote_state.projects_shared.outputs.service_catalog_project_id + service_catalog_repo_name = data.terraform_remote_state.projects_shared.outputs.service_catalog_repo_name + machine_learning_project_number = data.terraform_remote_state.machine_learning_development.outputs.machine_learning_project_number + tf_service_catalog_sa_email = data.terraform_remote_state.projects_shared.outputs.terraform_service_accounts["ml-service-catalog"] + shared_keyrings = data.terraform_remote_state.projects_shared.outputs.shared_level_keyrings +} + +data "terraform_remote_state" "projects_shared" { + backend = "gcs" + + config = { + bucket = var.remote_state_bucket + prefix = "terraform/projects/${local.business_unit}/shared" + } +} + +data "terraform_remote_state" "machine_learning_development" { + backend = "gcs" + config = { + bucket = var.remote_state_bucket + prefix = "terraform/projects/${local.business_unit}/development" + } +} diff --git a/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/service_catalog.tf b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/service_catalog.tf new file mode 100644 index 00000000..2a031be5 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/service_catalog.tf @@ -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. + */ + +locals { + region_kms_keyring = [for i in local.shared_keyrings : i if split("/", i)[3] == var.instance_region] +} + +data "google_project" "common_svc_catalog" { + project_id = local.service_catalog_project_id +} + +module "service_catalog" { + source = "../../modules/service_catalog" + + project_id = local.service_catalog_project_id + region = var.instance_region + name = local.service_catalog_repo_name + machine_learning_project_number = local.machine_learning_project_number + tf_service_catalog_sa_email = local.tf_service_catalog_sa_email + + log_bucket = var.log_bucket + kms_crypto_key = "${one(local.region_kms_keyring)}/cryptoKeys/${data.google_project.common_svc_catalog.name}" +} diff --git a/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/variables.tf b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/variables.tf new file mode 100644 index 00000000..debeaa58 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/variables.tf @@ -0,0 +1,30 @@ +/** + * 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. + */ + +variable "instance_region" { + description = "The region where compute instance will be created. A subnetwork must exists in the instance region." + type = string +} + +variable "remote_state_bucket" { + description = "Backend bucket to load remote state information from previous steps." + type = string +} + +variable "log_bucket" { + description = "Log bucket to be used by Service Catalog Bucket" + type = string +} diff --git a/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/versions.tf b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/versions.tf new file mode 100644 index 00000000..baa38abb --- /dev/null +++ b/docs/assets/terraform/5-appinfra/service-catalog-infra-repo/ml_business_unit/shared/versions.tf @@ -0,0 +1,43 @@ +/** + * Copyright 2022 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 { + required_version = ">= 0.13" + + required_providers { + + google = { + source = "hashicorp/google" + version = ">= 3.77, < 6" + } + + google-beta = { + source = "hashicorp/google-beta" + version = ">= 3.77, < 6" + } + + null = { + source = "hashicorp/null" + version = "~> 3.0" + } + + random = { + source = "hashicorp/random" + version = "~> 3.1" + } + + } +} diff --git a/docs/assets/terraform/5-appinfra/service-catalog-pipeline/README.md b/docs/assets/terraform/5-appinfra/service-catalog-pipeline/README.md new file mode 100644 index 00000000..7dde3147 --- /dev/null +++ b/docs/assets/terraform/5-appinfra/service-catalog-pipeline/README.md @@ -0,0 +1,135 @@ +# The Service Catalog + +## Overview + +This repo provides a number of the [Google Service Catalog](https://cloud.google.com/service-catalog) Terraform-based solution modules: + +
artifact_registry | +Artifact Registry is the next generation of Container Registry. Store, manage, and secure your build artifacts. | +
bigquery | +BigQuery is a serverless and cost-effective enterprise data warehouse that works across clouds and scales with your data. Use built-in ML/AI and BI for insights at scale. | +
bucket | +Cloud Storage is a managed service for storing unstructured data. | +
composer | +Cloud Composer is a fully managed workflow orchestration service built on Apache Airflow. | +
metadata | +Vertex ML Metadata is a service that provides capabilities for managing the lifecycle of metadata consumed and produced by machine-learning (ML) workflows. | +
notebook | +Vertex AI Workbench is a Jupyter notebook-based development environment for the entire data science workflow. | +
pubsub | +Pub/Sub is an asynchronous and scalable messaging service that decouples services producing messages from services processing those messages. | +
secrets | +Secret Manager lets you store, manage, and access secrets as binary blobs or text strings. With the appropriate permissions, you can view the contents of the secret. | +
tensorboard | +Vertex AI TensorBoard is an enterprise-ready managed service for machine learning experiment visualization. | +