Removing unless variables, using local modules.
This commit is contained in:
parent
18a59285d2
commit
73269eeed5
|
@ -155,7 +155,8 @@ def create_metric(metric_name, description):
|
|||
for desc in client.list_metric_descriptors(name=MONITORING_PROJECT_LINK):
|
||||
types.append(desc.type)
|
||||
|
||||
if metric_link not in types: # If the metric doesn't exist yet, then we create it
|
||||
# If the metric doesn't exist yet, then we create it
|
||||
if metric_link not in types:
|
||||
descriptor = ga_metric.MetricDescriptor()
|
||||
descriptor.type = f"custom.googleapis.com/{metric_name}"
|
||||
descriptor.metric_kind = ga_metric.MetricDescriptor.MetricKind.GAUGE
|
||||
|
|
|
@ -41,7 +41,7 @@ locals {
|
|||
################################################
|
||||
|
||||
module "project-monitoring" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/project?ref=v14.0.0"
|
||||
source = "../../../modules/project"
|
||||
name = "monitoring"
|
||||
parent = "organizations/${var.organization_id}"
|
||||
prefix = var.prefix
|
||||
|
@ -54,7 +54,7 @@ module "project-monitoring" {
|
|||
################################################
|
||||
|
||||
module "service-account-function" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/iam-service-account?ref=v14.0.0"
|
||||
source = "../../../modules/iam-service-account"
|
||||
project_id = module.project-monitoring.project_id
|
||||
name = "sa-dash"
|
||||
generate_key = false
|
||||
|
@ -81,7 +81,7 @@ module "service-account-function" {
|
|||
################################################
|
||||
|
||||
module "pubsub" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/pubsub?ref=v14.0.0"
|
||||
source = "../../../modules/pubsub"
|
||||
project_id = module.project-monitoring.project_id
|
||||
name = "network-dashboard-pubsub"
|
||||
subscriptions = {
|
||||
|
@ -104,16 +104,11 @@ resource "google_cloud_scheduler_job" "job" {
|
|||
}
|
||||
}
|
||||
|
||||
# Random ID to re-deploy the Cloud Function with every Terraform run
|
||||
resource "random_pet" "random" {
|
||||
length = 1
|
||||
}
|
||||
|
||||
module "cloud-function" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/cloud-function?ref=v14.0.0"
|
||||
source = "../../../modules/cloud-function"
|
||||
project_id = module.project-monitoring.project_id
|
||||
name = "network-dashboard-cloud-function"
|
||||
bucket_name = "network-dashboard-bucket-${random_pet.random.id}"
|
||||
bucket_name = "network-dashboard-bucket"
|
||||
bucket_config = {
|
||||
location = var.region
|
||||
lifecycle_delete_age = null
|
||||
|
|
|
@ -22,7 +22,7 @@ resource "google_folder" "test-net-dash" {
|
|||
##### Creating host projects, VPCs, service projects #####
|
||||
|
||||
module "project-hub" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/project?ref=v14.0.0"
|
||||
source = "../../../../modules/project"
|
||||
name = "test-host-hub"
|
||||
parent = google_folder.test-net-dash.name
|
||||
prefix = var.prefix
|
||||
|
@ -36,7 +36,7 @@ module "project-hub" {
|
|||
}
|
||||
|
||||
module "vpc-hub" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/net-vpc?ref=v14.0.0"
|
||||
source = "../../../../modules/net-vpc"
|
||||
project_id = module.project-hub.project_id
|
||||
name = "vpc-hub"
|
||||
subnets = [
|
||||
|
@ -50,7 +50,7 @@ module "vpc-hub" {
|
|||
}
|
||||
|
||||
module "project-svc-hub" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/project?ref=v14.0.0"
|
||||
source = "../../../../modules/project"
|
||||
parent = google_folder.test-net-dash.name
|
||||
billing_account = var.billing_account
|
||||
prefix = var.prefix
|
||||
|
@ -60,11 +60,12 @@ module "project-svc-hub" {
|
|||
shared_vpc_service_config = {
|
||||
attach = true
|
||||
host_project = module.project-hub.project_id
|
||||
service_identity_iam = {}
|
||||
}
|
||||
}
|
||||
|
||||
module "project-prod" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/project?ref=v14.0.0"
|
||||
source = "../../../../modules/project"
|
||||
name = "test-host-prod"
|
||||
parent = google_folder.test-net-dash.name
|
||||
prefix = var.prefix
|
||||
|
@ -78,7 +79,7 @@ module "project-prod" {
|
|||
}
|
||||
|
||||
module "vpc-prod" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/net-vpc?ref=v14.0.0"
|
||||
source = "../../../../modules/net-vpc"
|
||||
project_id = module.project-prod.project_id
|
||||
name = "vpc-prod"
|
||||
subnets = [
|
||||
|
@ -92,7 +93,7 @@ module "vpc-prod" {
|
|||
}
|
||||
|
||||
module "project-svc-prod" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/project?ref=v14.0.0"
|
||||
source = "../../../../modules/project"
|
||||
parent = google_folder.test-net-dash.name
|
||||
billing_account = var.billing_account
|
||||
prefix = var.prefix
|
||||
|
@ -102,11 +103,12 @@ module "project-svc-prod" {
|
|||
shared_vpc_service_config = {
|
||||
attach = true
|
||||
host_project = module.project-prod.project_id
|
||||
service_identity_iam = {}
|
||||
}
|
||||
}
|
||||
|
||||
module "project-dev" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/project?ref=v14.0.0"
|
||||
source = "../../../../modules/project"
|
||||
name = "test-host-dev"
|
||||
parent = google_folder.test-net-dash.name
|
||||
prefix = var.prefix
|
||||
|
@ -120,7 +122,7 @@ module "project-dev" {
|
|||
}
|
||||
|
||||
module "vpc-dev" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/net-vpc?ref=v14.0.0"
|
||||
source = "../../../../modules/net-vpc"
|
||||
project_id = module.project-dev.project_id
|
||||
name = "vpc-dev"
|
||||
subnets = [
|
||||
|
@ -134,7 +136,7 @@ module "vpc-dev" {
|
|||
}
|
||||
|
||||
module "project-svc-dev" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/project?ref=v14.0.0"
|
||||
source = "../../../../modules/project"
|
||||
parent = google_folder.test-net-dash.name
|
||||
billing_account = var.billing_account
|
||||
prefix = var.prefix
|
||||
|
@ -144,32 +146,33 @@ module "project-svc-dev" {
|
|||
shared_vpc_service_config = {
|
||||
attach = true
|
||||
host_project = module.project-dev.project_id
|
||||
service_identity_iam = {}
|
||||
}
|
||||
}
|
||||
|
||||
##### Creating VPC peerings #####
|
||||
|
||||
module "hub-to-prod-peering" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/net-vpc?ref=v14.0.0-peering"
|
||||
source = "../../../../modules/net-vpc-peering"
|
||||
local_network = module.vpc-hub.self_link
|
||||
peer_network = module.vpc-prod.self_link
|
||||
}
|
||||
|
||||
module "prod-to-hub-peering" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/net-vpc?ref=v14.0.0-peering"
|
||||
source = "../../../../modules/net-vpc-peering"
|
||||
local_network = module.vpc-prod.self_link
|
||||
peer_network = module.vpc-hub.self_link
|
||||
depends_on = [module.hub-to-prod-peering]
|
||||
}
|
||||
|
||||
module "hub-to-dev-peering" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/net-vpc?ref=v14.0.0-peering"
|
||||
source = "../../../../modules/net-vpc-peering"
|
||||
local_network = module.vpc-hub.self_link
|
||||
peer_network = module.vpc-dev.self_link
|
||||
}
|
||||
|
||||
module "dev-to-hub-peering" {
|
||||
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/net-vpc?ref=v14.0.0-peering"
|
||||
source = "../../../../modules/net-vpc-peering"
|
||||
local_network = module.vpc-dev.self_link
|
||||
peer_network = module.vpc-hub.self_link
|
||||
depends_on = [module.hub-to-dev-peering]
|
||||
|
@ -205,7 +208,7 @@ resource "google_compute_instance" "test-vm-prod2" {
|
|||
machine_type = "f1-micro"
|
||||
zone = var.zone
|
||||
|
||||
tags = ["${var.region}"]
|
||||
tags = [var.region]
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
|
|
|
@ -24,7 +24,6 @@ variable "billing_account" {
|
|||
|
||||
variable "prefix" {
|
||||
description = "Customer name to use as prefix for resources' naming"
|
||||
default = "net-dash"
|
||||
}
|
||||
|
||||
variable "project_vm_services" {
|
||||
|
|
|
@ -24,13 +24,6 @@ variable "billing_account" {
|
|||
|
||||
variable "prefix" {
|
||||
description = "Customer name to use as prefix for resources' naming"
|
||||
default = "net-dash"
|
||||
}
|
||||
|
||||
# Not used for now as I am creating the monitoring project in my main.tf file
|
||||
variable "monitoring_project_id" {
|
||||
type = string
|
||||
description = "ID of the monitoring project, where the Cloud Function and dashboards will be deployed."
|
||||
}
|
||||
|
||||
# TODO: support folder instead of a list of projects?
|
||||
|
|
Loading…
Reference in New Issue