<commit_before>locals {
  forseti_org_required_roles = [
    "roles/resourcemanager.organizationAdmin",
    "roles/iam.organizationRoleAdmin",         // Permissions to manage/test real-time-enforcer roles
    "roles/logging.configWriter",              // Permissions to create stackdriver log exports
  ]

  forseti_host_project_required_roles = [
    "roles/compute.admin",
  ]

  forseti_project_required_roles = [
    "roles/compute.instanceAdmin",
    "roles/compute.networkAdmin",
    "roles/compute.securityAdmin",
    "roles/iam.serviceAccountAdmin",
    "roles/iam.serviceAccountUser",
    "roles/serviceusage.serviceUsageAdmin",
    "roles/storage.admin",
    "roles/cloudsql.admin",
    "roles/pubsub.admin",
  ]

  forseti_enforcer_project_required_roles = [
    "roles/storage.admin", // Permissions to create GCS buckets that the enforcer will manage
  ]

  forseti_required_apis = [
    "compute.googleapis.com",
    "serviceusage.googleapis.com",
    "cloudresourcemanager.googleapis.com",
  ]
}

// Define a host project for the Forseti shared VPC test suite.
module "forseti-host-project" {
  source  = "terraform-google-modules/project-factory/google"
  version = "2.4.1"

  providers {
    "google"      = "google.phoogle"
    "google-beta" = "google-beta.phoogle"
  }

  billing_account = "${module.variables.phoogle_billing_account}"
  name            = "ci-forseti-host"
  org_id          = "${var.phoogle_org_id}"

  activate_apis    = "${local.forseti_required_apis}"
  credentials_path = "${var.phoogle_credentials_path}"
  folder_id        = "${google_folder.phoogle_cloud_foundation_cicd.name}"
  project_id       = "ci-forseti-host-a1b2"
}

// Define a shared VPC network within the Forseti host project.
module "forseti-host-network-01" {
  source  = "terraform-google-modules/network/google"
  version = "0.8.0"

  providers {
    "google"      = "google.phoogle"
    "google-beta" = "google-beta.phoogle"
  }

  project_id      = "${module.forseti-host-project.project_id}"
  network_name    = "forseti-network"
  shared_vpc_host = "true"

  secondary_ranges {
    forseti-subnetwork = []
  }

  subnets = [
    {
      subnet_name   = "forseti-subnetwork"
      subnet_ip     = "10.128.0.0/20"
      subnet_region = "us-central1"
    },
  ]
}

resource "google_compute_router" "forseti_host" {
  name    = "forseti-host"
  network = "${module.forseti-host-network-01.network_self_link}"

  bgp {
    asn = "64514"
  }

  region  = "us-central1"
  project = "${module.forseti-host-project.project_id}"
}

resource "google_compute_router_nat" "forseti_host" {
  name                               = "forseti-host"
  router                             = "${google_compute_router.forseti_host.name}"
  nat_ip_allocate_option             = "AUTO_ONLY"
  source_subnetwork_ip_ranges_to_nat = "LIST_OF_SUBNETWORKS"

  subnetwork {
    name                    = "${module.forseti-host-network-01.subnets_self_links[0]}"
    source_ip_ranges_to_nat = ["ALL_IP_RANGES"]
  }

  project = "${module.forseti-host-project.project_id}"
  region  = "${google_compute_router.forseti_host.region}"
}

module "forseti-service-project" {
  source  = "terraform-google-modules/project-factory/google"
  version = "2.4.1"

  providers {
    "google"      = "google.phoogle"
    "google-beta" = "google-beta.phoogle"
  }

  billing_account = "${module.variables.phoogle_billing_account}"
  name            = "ci-forseti"
  org_id          = "${var.phoogle_org_id}"

  activate_apis      = "${local.forseti_required_apis}"
  credentials_path   = "${var.phoogle_credentials_path}"
  folder_id          = "${google_folder.phoogle_cloud_foundation_cicd.name}"
  random_project_id  = "true"
  shared_vpc         = "${module.forseti-host-project.project_id}"
  shared_vpc_subnets = ["projects/ci-forseti-host-a1b2/regions/us-central1/subnetworks/forseti-subnetwork"]
}


}


}

<commit_msg>Add network, router, NAT to service project<commit_after>locals {
  forseti_org_required_roles = [
    "roles/resourcemanager.organizationAdmin",
    "roles/iam.organizationRoleAdmin",         // Permissions to manage/test real-time-enforcer roles
    "roles/logging.configWriter",              // Permissions to create stackdriver log exports
  ]

  forseti_host_project_required_roles = [
    "roles/compute.admin",
  ]

  forseti_project_required_roles = [
    "roles/compute.instanceAdmin",
    "roles/compute.networkAdmin",
    "roles/compute.securityAdmin",
    "roles/iam.serviceAccountAdmin",
    "roles/iam.serviceAccountUser",
    "roles/serviceusage.serviceUsageAdmin",
    "roles/storage.admin",
    "roles/cloudsql.admin",
    "roles/pubsub.admin",
  ]

  forseti_enforcer_project_required_roles = [
    "roles/storage.admin", // Permissions to create GCS buckets that the enforcer will manage
  ]

  forseti_required_apis = [
    "compute.googleapis.com",
    "serviceusage.googleapis.com",
    "cloudresourcemanager.googleapis.com",
  ]
}

// Define a host project for the Forseti shared VPC test suite.
module "forseti-host-project" {
  source  = "terraform-google-modules/project-factory/google"
  version = "2.4.1"

  providers {
    "google"      = "google.phoogle"
    "google-beta" = "google-beta.phoogle"
  }

  billing_account = "${module.variables.phoogle_billing_account}"
  name            = "ci-forseti-host"
  org_id          = "${var.phoogle_org_id}"

  activate_apis    = "${local.forseti_required_apis}"
  credentials_path = "${var.phoogle_credentials_path}"
  folder_id        = "${google_folder.phoogle_cloud_foundation_cicd.name}"
  project_id       = "ci-forseti-host-a1b2"
}

// Define a shared VPC network within the Forseti host project.
module "forseti-host-network-01" {
  source  = "terraform-google-modules/network/google"
  version = "0.8.0"

  providers {
    "google"      = "google.phoogle"
    "google-beta" = "google-beta.phoogle"
  }

  project_id      = "${module.forseti-host-project.project_id}"
  network_name    = "forseti-network"
  shared_vpc_host = "true"

  secondary_ranges {
    forseti-subnetwork = []
  }

  subnets = [
    {
      subnet_name   = "forseti-subnetwork"
      subnet_ip     = "10.128.0.0/20"
      subnet_region = "us-central1"
    },
  ]
}

resource "google_compute_router" "forseti_host" {
  name    = "forseti-host"
  network = "${module.forseti-host-network-01.network_self_link}"

  bgp {
    asn = "64514"
  }

  region  = "us-central1"
  project = "${module.forseti-host-project.project_id}"
}

resource "google_compute_router_nat" "forseti_host" {
  name                               = "forseti-host"
  router                             = "${google_compute_router.forseti_host.name}"
  nat_ip_allocate_option             = "AUTO_ONLY"
  source_subnetwork_ip_ranges_to_nat = "LIST_OF_SUBNETWORKS"

  subnetwork {
    name                    = "${module.forseti-host-network-01.subnets_self_links[0]}"
    source_ip_ranges_to_nat = ["ALL_IP_RANGES"]
  }

  project = "${module.forseti-host-project.project_id}"
  region  = "${google_compute_router.forseti_host.region}"
}

module "forseti-service-project" {
  source  = "terraform-google-modules/project-factory/google"
  version = "2.4.1"

  providers {
    "google"      = "google.phoogle"
    "google-beta" = "google-beta.phoogle"
  }

  billing_account = "${module.variables.phoogle_billing_account}"
  name            = "ci-forseti"
  org_id          = "${var.phoogle_org_id}"

  activate_apis      = "${local.forseti_required_apis}"
  credentials_path   = "${var.phoogle_credentials_path}"
  folder_id          = "${google_folder.phoogle_cloud_foundation_cicd.name}"
  random_project_id  = "true"
  shared_vpc         = "${module.forseti-host-project.project_id}"
  shared_vpc_subnets = ["projects/ci-forseti-host-a1b2/regions/us-central1/subnetworks/forseti-subnetwork"]
}

module "forseti-service-network" {
  source  = "terraform-google-modules/network/google"
  version = "0.8.0"

  providers {
    "google"      = "google.phoogle"
    "google-beta" = "google-beta.phoogle"
  }

  network_name = "forseti-network"
  project_id   = "${module.forseti-service-project.project_id}"

  secondary_ranges = {
    forseti-subnetwork = []
  }

  subnets = [
    {
      subnet_name   = "forseti-subnetwork"
      subnet_ip     = "10.129.0.0/20"
      subnet_region = "us-central1"
    },
  ]
}

resource "google_compute_router" "forseti_service" {
  name    = "forseti-service"
  network = "${module.forseti-service-network.network_self_link}"

  bgp {
    asn = "64514"
  }

  region  = "us-central1"
  project = "${module.forseti-service-project.project_id}"
}

resource "google_compute_router_nat" "forseti_service" {
  name                               = "forseti-service"
  router                             = "${google_compute_router.forseti_service.name}"
  nat_ip_allocate_option             = "AUTO_ONLY"
  source_subnetwork_ip_ranges_to_nat = "LIST_OF_SUBNETWORKS"

  subnetwork {
    name                    = "${module.forseti-service-network.subnets_self_links[0]}"
    source_ip_ranges_to_nat = ["ALL_IP_RANGES"]
  }

  project = "${module.forseti-service-project.project_id}"
  region  = "${google_compute_router.forseti_service.region}"
{'fraction_non_alphanumeric': 0.12576219512195122, 'fraction_numerical': 0.010235191637630661, 'mean_word_length': 3.0713652482269502, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1084419', 'n_tokens_mistral': 3360, 'n_tokens_neox': 3191, 'n_words': 422}