From 1ca493e3d7cc1bd62c3dafea2535d964b2f16fc2 Mon Sep 17 00:00:00 2001 From: Brian Jung <65934595+brianhmj@users.noreply.github.com> Date: Thu, 27 Oct 2022 13:17:20 -0400 Subject: [PATCH 1/6] Update main.tf Added a terraform and provider block - terraform relies on plugins and following best practices to allow allowing the rightmost component of a version to increment. (https://developer.hashicorp.com/terraform/language/providers/requirements#version-constraints) Also removed comment about it being ok to use project roles of monitoring viewer and compute networkViewer. (Look at Issue #922) --- .../cloud-operations/network-dashboard/main.tf | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/blueprints/cloud-operations/network-dashboard/main.tf b/blueprints/cloud-operations/network-dashboard/main.tf index 00ca7bb2e0..99a1740083 100644 --- a/blueprints/cloud-operations/network-dashboard/main.tf +++ b/blueprints/cloud-operations/network-dashboard/main.tf @@ -13,7 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + +terraform { + required_version = "~> 1.3.3" + required_providers { + google = { + version = "~> 4.41.0" + } + } +} + locals { project_ids = toset(var.monitored_projects_list) projects = join(",", local.project_ids) @@ -50,7 +59,6 @@ module "service-account-function" { # Required IAM permissions for this service account are: # 1) compute.networkViewer on projects to be monitored (I gave it at organization level for now for simplicity) # 2) monitoring viewer on the projects to be monitored (I gave it at organization level for now for simplicity) - # 3) if you dont have permission to create service account and assign permission at organization Level, move these 3 roles to project level. iam_organization_roles = { "${var.organization_id}" = [ @@ -184,4 +192,4 @@ module "cloud-function" { resource "google_monitoring_dashboard" "dashboard" { dashboard_json = file("${path.module}/dashboards/quotas-utilization.json") project = local.monitoring_project -} \ No newline at end of file +} From 1148a5fd246106a3cb8a84da221927263b326d59 Mon Sep 17 00:00:00 2001 From: Brian Jung <65934595+brianhmj@users.noreply.github.com> Date: Thu, 27 Oct 2022 13:22:42 -0400 Subject: [PATCH 2/6] Update README.md --- blueprints/cloud-operations/network-dashboard/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/blueprints/cloud-operations/network-dashboard/README.md b/blueprints/cloud-operations/network-dashboard/README.md index 5e640fddb8..c835dc01de 100644 --- a/blueprints/cloud-operations/network-dashboard/README.md +++ b/blueprints/cloud-operations/network-dashboard/README.md @@ -26,6 +26,8 @@ Clone this repository, then go through the following steps to create resources: - `terraform init` - `terraform apply` +Note: Org level viewing permission is required for some metrics such as firewall policies. + Once the resources are deployed, go to the following page to see the dashboard: https://console.cloud.google.com/monitoring/dashboards?project=. A dashboard called "quotas-utilization" should be created. @@ -74,6 +76,7 @@ In a future release, we could support: - Dynamic routes calculation for VPCs/PPGs with "global routing" set to OFF - Static routes calculation for projects/PPGs with "custom routes importing/exporting" set to OFF - Calculations for cross Organization peering groups +- Support different scopes (reduced and fine-grained) If you are interested in this and/or would like to contribute, please contact legranda@google.com. From e0c41f959f5ff0437e3c1a8c154f423fc8081309 Mon Sep 17 00:00:00 2001 From: Brian Jung <65934595+brianhmj@users.noreply.github.com> Date: Fri, 28 Oct 2022 09:18:01 -0400 Subject: [PATCH 3/6] Update main.tf --- blueprints/cloud-operations/network-dashboard/main.tf | 9 --------- 1 file changed, 9 deletions(-) diff --git a/blueprints/cloud-operations/network-dashboard/main.tf b/blueprints/cloud-operations/network-dashboard/main.tf index 99a1740083..0c3804021a 100644 --- a/blueprints/cloud-operations/network-dashboard/main.tf +++ b/blueprints/cloud-operations/network-dashboard/main.tf @@ -14,15 +14,6 @@ * limitations under the License. */ -terraform { - required_version = "~> 1.3.3" - required_providers { - google = { - version = "~> 4.41.0" - } - } -} - locals { project_ids = toset(var.monitored_projects_list) projects = join(",", local.project_ids) From b38ade0a26e3c370c99084d39d08f62f9739c1b9 Mon Sep 17 00:00:00 2001 From: Brian Jung <65934595+brianhmj@users.noreply.github.com> Date: Fri, 28 Oct 2022 09:21:17 -0400 Subject: [PATCH 4/6] Create versions.tf --- .../network-dashboard/versions.tf | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 blueprints/cloud-operations/network-dashboard/versions.tf diff --git a/blueprints/cloud-operations/network-dashboard/versions.tf b/blueprints/cloud-operations/network-dashboard/versions.tf new file mode 100644 index 0000000000..c1e644a8d3 --- /dev/null +++ b/blueprints/cloud-operations/network-dashboard/versions.tf @@ -0,0 +1,23 @@ +# 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 +# +# 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. + +terraform { + required_version = ">= 1.3.1" + required_providers { + google = { + source = "hashicorp/google" + version = ">= 4.40.0" + } + } +} From 22736473fdd41dadbd264ce8c1f4097d72fa0a2c Mon Sep 17 00:00:00 2001 From: Brian Jung <65934595+brianhmj@users.noreply.github.com> Date: Fri, 28 Oct 2022 09:22:59 -0400 Subject: [PATCH 5/6] Update versions.tf --- blueprints/cloud-operations/network-dashboard/versions.tf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blueprints/cloud-operations/network-dashboard/versions.tf b/blueprints/cloud-operations/network-dashboard/versions.tf index c1e644a8d3..3bdf23370a 100644 --- a/blueprints/cloud-operations/network-dashboard/versions.tf +++ b/blueprints/cloud-operations/network-dashboard/versions.tf @@ -17,7 +17,11 @@ terraform { required_providers { google = { source = "hashicorp/google" - version = ">= 4.40.0" + version = ">= 4.40.0" # tftest + } + google-beta = { + source = "hashicorp/google-beta" + version = ">= 4.40.0" # tftest } } } From 980cc678c88d0f59a2147636e06e3b1f9eff55f6 Mon Sep 17 00:00:00 2001 From: Brian Jung <65934595+brianhmj@users.noreply.github.com> Date: Fri, 28 Oct 2022 11:19:46 -0400 Subject: [PATCH 6/6] Update main.tf --- blueprints/cloud-operations/network-dashboard/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blueprints/cloud-operations/network-dashboard/main.tf b/blueprints/cloud-operations/network-dashboard/main.tf index 0c3804021a..b5edfb5c1f 100644 --- a/blueprints/cloud-operations/network-dashboard/main.tf +++ b/blueprints/cloud-operations/network-dashboard/main.tf @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + locals { project_ids = toset(var.monitored_projects_list) projects = join(",", local.project_ids)