'Monitoring GCP Projects with Terraform

I have a "Monitor" project in Google Cloud and want it to monitor the metrics of several other projects. On the Cloud Console, I can easily add these projects to the metric scope of my Monitor project. However, I would like to automate this process in Terraform. Does anyone know how?



Solution 1:[1]

Yes you can achieve that using terraform. You need to have a scoping project or a new project which will host your metrics from other projects.

You can then add the projects as monitored project using the below terraform resource :

https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/monitoring_monitored_project

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sumeet Singh