From 313e279ea5b544299b5c9608f726da904e7024c5 Mon Sep 17 00:00:00 2001 From: Caetano Colin <164910343+caetano-colin@users.noreply.github.com> Date: Mon, 24 Jun 2024 16:45:23 -0300 Subject: [PATCH] add module (#57) --- .../modules/metadata/README.md | 59 +------------------ .../service-catalog/modules/metadata/data.tf | 13 +--- .../modules/metadata/locals.tf | 19 ------ .../modules/metadata/variables.tf | 15 +++-- 4 files changed, 16 insertions(+), 90 deletions(-) delete mode 100644 5-app-infra/source_repos/service-catalog/modules/metadata/locals.tf diff --git a/5-app-infra/source_repos/service-catalog/modules/metadata/README.md b/5-app-infra/source_repos/service-catalog/modules/metadata/README.md index 08ca1098..69068713 100644 --- a/5-app-infra/source_repos/service-catalog/modules/metadata/README.md +++ b/5-app-infra/source_repos/service-catalog/modules/metadata/README.md @@ -1,64 +1,11 @@ - -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. - -## Requirements - -No requirements. - -## Providers - -| Name | Version | -|------|---------| -| [google](#provider\_google) | n/a | -| [google-beta](#provider\_google-beta) | n/a | - -## Modules - -No modules. - -## Resources - -| Name | Type | -|------|------| -| [google-beta_google_vertex_ai_metadata_store.store](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/google_vertex_ai_metadata_store) | resource | -| [google_kms_crypto_key.key](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/kms_crypto_key) | data source | -| [google_kms_key_ring.kms](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/kms_key_ring) | data source | -| [google_project.project](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/project) | data source | -| [google_projects.kms](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/projects) | data source | - -## Inputs - -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [name](#input\_name) | The name of the metadata store instance | `string` | `null` | no | -| [project\_id](#input\_project\_id) | Optional Project ID. | `string` | `null` | no | -| [region](#input\_region) | The resource region, one of [us-central1, us-east4]. | `string` | `"us-central1"` | no | - -## Outputs - -| Name | Description | -|------|-------------| -| [vertex\_ai\_metadata\_store](#output\_vertex\_ai\_metadata\_store) | Vertex AI Metadata Store. | - ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| name | The name of the metadata store instance | `string` | `null` | no | -| project\_id | Optional Project ID. | `string` | `null` | no | +| kms\_keyring | The KMS keyring that will be used when selecting the KMS key, preferably this should be on the same region as the other resources and the same environment.
This value can be obtained by running "gcloud kms keyrings list --project=KMS\_PROJECT\_ID --location=REGION." | `string` | n/a | yes | +| name | The name of the metadata store instance. | `string` | n/a | yes | +| project\_id | Project ID. | `string` | n/a | yes | | region | The resource region, one of [us-central1, us-east4]. | `string` | `"us-central1"` | no | ## Outputs diff --git a/5-app-infra/source_repos/service-catalog/modules/metadata/data.tf b/5-app-infra/source_repos/service-catalog/modules/metadata/data.tf index 035a39b9..f91fceb6 100644 --- a/5-app-infra/source_repos/service-catalog/modules/metadata/data.tf +++ b/5-app-infra/source_repos/service-catalog/modules/metadata/data.tf @@ -18,17 +18,8 @@ data "google_project" "project" { project_id = var.project_id } -data "google_projects" "kms" { - filter = "labels.application_name:env-kms labels.environment:${data.google_project.project.labels.environment} lifecycleState:ACTIVE" -} - -data "google_kms_key_ring" "kms" { - name = local.keyring_name - location = var.region - project = data.google_projects.kms.projects.0.project_id -} - data "google_kms_crypto_key" "key" { name = data.google_project.project.name - key_ring = data.google_kms_key_ring.kms.id + key_ring = var.kms_keyring } + diff --git a/5-app-infra/source_repos/service-catalog/modules/metadata/locals.tf b/5-app-infra/source_repos/service-catalog/modules/metadata/locals.tf deleted file mode 100644 index 9a1fcf38..00000000 --- a/5-app-infra/source_repos/service-catalog/modules/metadata/locals.tf +++ /dev/null @@ -1,19 +0,0 @@ -/** - * 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 { - keyring_name = "sample-keyring" -} diff --git a/5-app-infra/source_repos/service-catalog/modules/metadata/variables.tf b/5-app-infra/source_repos/service-catalog/modules/metadata/variables.tf index 403910f3..65be58f8 100644 --- a/5-app-infra/source_repos/service-catalog/modules/metadata/variables.tf +++ b/5-app-infra/source_repos/service-catalog/modules/metadata/variables.tf @@ -16,8 +16,7 @@ variable "name" { type = string - description = "The name of the metadata store instance" - default = null + description = "The name of the metadata store instance." } variable "region" { @@ -32,6 +31,14 @@ variable "region" { variable "project_id" { type = string - description = "Optional Project ID." - default = null + description = "Project ID." } + +variable "kms_keyring" { + type = string + description = <