Skip to content

Commit

Permalink
feat: Adds prefix to projects and folder name (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
amandakarina authored and bharathkkb committed Mar 31, 2021
1 parent c1a2852 commit 66dacf2
Show file tree
Hide file tree
Showing 106 changed files with 390 additions and 65 deletions.
2 changes: 2 additions & 0 deletions 0-bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ Currently, the bucket information is replaced in the state backends as a part of
|------|-------------|------|---------|:--------:|
| billing\_account | The ID of the billing account to associate projects with. | `string` | n/a | yes |
| default\_region | Default region to create resources where applicable. | `string` | `"us-central1"` | no |
| folder\_prefix | Name prefix to use for folders created. | `string` | `"fldr"` | no |
| group\_billing\_admins | Google Group for GCP Billing Administrators | `string` | n/a | yes |
| group\_org\_admins | Google Group for GCP Organization Administrators | `string` | n/a | yes |
| org\_id | GCP Organization ID | `string` | n/a | yes |
| org\_policy\_admin\_role | Additional Org Policy Admin role for admin group. You can use this for testing purposes. | `bool` | `false` | no |
| org\_project\_creators | Additional list of members to have project creator role across the organization. Prefix of group: user: or serviceAccount: is required. | `list(string)` | `[]` | no |
| parent\_folder | Optional - if using a folder for testing. | `string` | `""` | no |
| project\_prefix | Name prefix to use for projects created. | `string` | `"prj"` | no |
| skip\_gcloud\_download | Whether to skip downloading gcloud (assumes gcloud is already available outside the module) | `bool` | `true` | no |

## Outputs
Expand Down
4 changes: 3 additions & 1 deletion 0-bootstrap/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ locals {
}

resource "google_folder" "bootstrap" {
display_name = "fldr-bootstrap"
display_name = "${var.folder_prefix}-bootstrap"
parent = local.parent
}

Expand All @@ -59,6 +59,7 @@ module "seed_bootstrap" {
parent_folder = var.parent_folder == "" ? "" : local.parent
skip_gcloud_download = var.skip_gcloud_download
org_admins_org_iam_permissions = local.org_admins_org_iam_permissions
project_prefix = var.project_prefix

project_labels = {
environment = "bootstrap"
Expand Down Expand Up @@ -127,6 +128,7 @@ module "cloudbuild_bootstrap" {
skip_gcloud_download = var.skip_gcloud_download
cloudbuild_plan_filename = "cloudbuild-tf-plan.yaml"
cloudbuild_apply_filename = "cloudbuild-tf-apply.yaml"
project_prefix = var.project_prefix

activate_apis = [
"serviceusage.googleapis.com",
Expand Down
12 changes: 12 additions & 0 deletions 0-bootstrap/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ variable "skip_gcloud_download" {
default = true
}

variable "project_prefix" {
description = "Name prefix to use for projects created."
type = string
default = "prj"
}

variable "folder_prefix" {
description = "Name prefix to use for folders created."
type = string
default = "fldr"
}

/* ----------------------------------------
Specific to jenkins_bootstrap module
---------------------------------------- */
Expand Down
2 changes: 2 additions & 0 deletions 1-org/envs/shared/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
| dns\_hub\_project\_budget\_amount | The amount to use as the budget for the DNS hub project. | `number` | `1000` | no |
| domains\_to\_allow | The list of domains to allow users from in IAM. | `list(string)` | n/a | yes |
| enable\_os\_login\_policy | Enable OS Login policy. | `bool` | `false` | no |
| folder\_prefix | Name prefix to use for folders created. | `string` | `"fldr"` | no |
| interconnect\_project\_alert\_pubsub\_topic | The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}` for the interconnect project. | `string` | `null` | no |
| interconnect\_project\_alert\_spent\_percents | A list of percentages of the budget to alert on when threshold is exceeded for the interconnect project. | `list(number)` | <pre>[<br> 0.5,<br> 0.75,<br> 0.9,<br> 0.95<br>]</pre> | no |
| interconnect\_project\_budget\_amount | The amount to use as the budget for the interconnect project. | `number` | `1000` | no |
Expand All @@ -33,6 +34,7 @@
| org\_secrets\_project\_alert\_spent\_percents | A list of percentages of the budget to alert on when threshold is exceeded for the org secrets project. | `list(number)` | <pre>[<br> 0.5,<br> 0.75,<br> 0.9,<br> 0.95<br>]</pre> | no |
| org\_secrets\_project\_budget\_amount | The amount to use as the budget for the org secrets project. | `number` | `1000` | no |
| parent\_folder | Optional - if using a folder for testing. | `string` | `""` | no |
| project\_prefix | Name prefix to use for projects created. | `string` | `"prj"` | no |
| scc\_notification\_filter | Filter used to SCC Notification, you can see more details how to create filters in https://cloud.google.com/security-command-center/docs/how-to-api-filter-notifications#create-filter | `string` | `"state=\\\"ACTIVE\\\""` | no |
| scc\_notification\_name | Name of SCC Notification | `string` | n/a | yes |
| scc\_notifications\_project\_alert\_pubsub\_topic | The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}` for the SCC notifications project. | `string` | `null` | no |
Expand Down
2 changes: 1 addition & 1 deletion 1-org/envs/shared/folders.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ locals {
*****************************************/

resource "google_folder" "common" {
display_name = "fldr-common"
display_name = "${var.folder_prefix}-common"
parent = local.parent
}
24 changes: 12 additions & 12 deletions 1-org/envs/shared/projects.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ module "org_audit_logs" {
version = "~> 9.2"
random_project_id = "true"
impersonate_service_account = var.terraform_service_account
default_service_account = "deprivilege"
name = "prj-c-logging"
default_service_account = "depriviledge"
name = "${var.project_prefix}-c-logging"
org_id = var.org_id
billing_account = var.billing_account
folder_id = google_folder.common.id
Expand All @@ -50,8 +50,8 @@ module "org_billing_logs" {
version = "~> 9.2"
random_project_id = "true"
impersonate_service_account = var.terraform_service_account
default_service_account = "deprivilege"
name = "prj-c-billing-logs"
default_service_account = "depriviledge"
name = "${var.project_prefix}-c-billing-logs"
org_id = var.org_id
billing_account = var.billing_account
folder_id = google_folder.common.id
Expand Down Expand Up @@ -81,8 +81,8 @@ module "org_secrets" {
version = "~> 9.2"
random_project_id = "true"
impersonate_service_account = var.terraform_service_account
default_service_account = "deprivilege"
name = "prj-c-secrets"
default_service_account = "depriviledge"
name = "${var.project_prefix}-c-secrets"
org_id = var.org_id
billing_account = var.billing_account
folder_id = google_folder.common.id
Expand Down Expand Up @@ -112,8 +112,8 @@ module "interconnect" {
version = "~> 9.2"
random_project_id = "true"
impersonate_service_account = var.terraform_service_account
default_service_account = "deprivilege"
name = "prj-c-interconnect"
default_service_account = "depriviledge"
name = "${var.project_prefix}-c-interconnect"
org_id = var.org_id
billing_account = var.billing_account
folder_id = google_folder.common.id
Expand Down Expand Up @@ -143,8 +143,8 @@ module "scc_notifications" {
version = "~> 9.2"
random_project_id = "true"
impersonate_service_account = var.terraform_service_account
default_service_account = "deprivilege"
name = "prj-c-scc"
default_service_account = "depriviledge"
name = "${var.project_prefix}-c-scc"
org_id = var.org_id
billing_account = var.billing_account
folder_id = google_folder.common.id
Expand Down Expand Up @@ -174,8 +174,8 @@ module "dns_hub" {
version = "~> 9.2"
random_project_id = "true"
impersonate_service_account = var.terraform_service_account
default_service_account = "deprivilege"
name = "prj-c-dns-hub"
default_service_account = "depriviledge"
name = "${var.project_prefix}-c-dns-hub"
org_id = var.org_id
billing_account = var.billing_account
folder_id = google_folder.common.id
Expand Down
12 changes: 12 additions & 0 deletions 1-org/envs/shared/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,15 @@ variable "scc_notifications_project_budget_amount" {
type = number
default = 1000
}

variable "project_prefix" {
description = "Name prefix to use for projects created."
type = string
default = "prj"
}

variable "folder_prefix" {
description = "Name prefix to use for folders created."
type = string
default = "fldr"
}
2 changes: 2 additions & 0 deletions 2-environments/envs/development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| billing\_account | The ID of the billing account to associate this project with | `string` | n/a | yes |
| folder\_prefix | Name prefix to use for folders created. | `string` | `"fldr"` | no |
| monitoring\_workspace\_users | Gsuite or Cloud Identity group that have access to Monitoring Workspaces. | `string` | n/a | yes |
| org\_id | The organization id for the associated services | `string` | n/a | yes |
| parent\_folder | Optional - if using a folder for testing. | `string` | `""` | no |
| project\_prefix | Name prefix to use for projects created. | `string` | `"prj"` | no |
| terraform\_service\_account | Service account email of the account to impersonate to run Terraform. | `string` | n/a | yes |

## Outputs
Expand Down
2 changes: 2 additions & 0 deletions 2-environments/envs/development/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ module "env" {
billing_account = var.billing_account
terraform_service_account = var.terraform_service_account
monitoring_workspace_users = var.monitoring_workspace_users
project_prefix = var.project_prefix
folder_prefix = var.folder_prefix
}
12 changes: 12 additions & 0 deletions 2-environments/envs/development/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,15 @@ variable "monitoring_workspace_users" {
description = "Gsuite or Cloud Identity group that have access to Monitoring Workspaces."
type = string
}

variable "project_prefix" {
description = "Name prefix to use for projects created."
type = string
default = "prj"
}

variable "folder_prefix" {
description = "Name prefix to use for folders created."
type = string
default = "fldr"
}
2 changes: 2 additions & 0 deletions 2-environments/envs/non-production/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| billing\_account | The ID of the billing account to associate this project with | `string` | n/a | yes |
| folder\_prefix | Name prefix to use for folders created. | `string` | `"fldr"` | no |
| monitoring\_workspace\_users | Gsuite or Cloud Identity group that have access to Monitoring Workspaces. | `string` | n/a | yes |
| org\_id | The organization id for the associated services | `string` | n/a | yes |
| parent\_folder | Optional - if using a folder for testing. | `string` | `""` | no |
| project\_prefix | Name prefix to use for projects created. | `string` | `"prj"` | no |
| terraform\_service\_account | Service account email of the account to impersonate to run Terraform. | `string` | n/a | yes |

## Outputs
Expand Down
2 changes: 2 additions & 0 deletions 2-environments/envs/non-production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ module "env" {
billing_account = var.billing_account
terraform_service_account = var.terraform_service_account
monitoring_workspace_users = var.monitoring_workspace_users
project_prefix = var.project_prefix
folder_prefix = var.folder_prefix
}
12 changes: 12 additions & 0 deletions 2-environments/envs/non-production/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,15 @@ variable "monitoring_workspace_users" {
description = "Gsuite or Cloud Identity group that have access to Monitoring Workspaces."
type = string
}

variable "project_prefix" {
description = "Name prefix to use for projects created."
type = string
default = "prj"
}

variable "folder_prefix" {
description = "Name prefix to use for folders created."
type = string
default = "fldr"
}
2 changes: 2 additions & 0 deletions 2-environments/envs/production/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| billing\_account | The ID of the billing account to associate this project with | `string` | n/a | yes |
| folder\_prefix | Name prefix to use for folders created. | `string` | `"fldr"` | no |
| monitoring\_workspace\_users | Gsuite or Cloud Identity group that have access to Monitoring Workspaces. | `string` | n/a | yes |
| org\_id | The organization id for the associated services | `string` | n/a | yes |
| parent\_folder | Optional - if using a folder for testing. | `string` | `""` | no |
| project\_prefix | Name prefix to use for projects created. | `string` | `"prj"` | no |
| terraform\_service\_account | Service account email of the account to impersonate to run Terraform. | `string` | n/a | yes |

## Outputs
Expand Down
2 changes: 2 additions & 0 deletions 2-environments/envs/production/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ module "env" {
billing_account = var.billing_account
terraform_service_account = var.terraform_service_account
monitoring_workspace_users = var.monitoring_workspace_users
project_prefix = var.project_prefix
folder_prefix = var.folder_prefix
}
12 changes: 12 additions & 0 deletions 2-environments/envs/production/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,15 @@ variable "monitoring_workspace_users" {
type = string
}

variable "project_prefix" {
description = "Name prefix to use for projects created."
type = string
default = "prj"
}

variable "folder_prefix" {
description = "Name prefix to use for folders created."
type = string
default = "fldr"
}

2 changes: 2 additions & 0 deletions 2-environments/modules/env_baseline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
| billing\_account | The ID of the billing account to associate this project with | `string` | n/a | yes |
| env | The environment to prepare (ex. development) | `string` | n/a | yes |
| environment\_code | A short form of the folder level resources (environment) within the Google Cloud organization (ex. d). | `string` | n/a | yes |
| folder\_prefix | Name prefix to use for folders created. | `string` | `"fldr"` | no |
| monitoring\_project\_alert\_pubsub\_topic | The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}` for the monitoring project. | `string` | `null` | no |
| monitoring\_project\_alert\_spent\_percents | A list of percentages of the budget to alert on when threshold is exceeded for the monitoring project. | `list(number)` | <pre>[<br> 0.5,<br> 0.75,<br> 0.9,<br> 0.95<br>]</pre> | no |
| monitoring\_project\_budget\_amount | The amount to use as the budget for the monitoring project. | `number` | `1000` | no |
| monitoring\_workspace\_users | Gsuite or Cloud Identity group that have access to Monitoring Workspaces. | `string` | n/a | yes |
| org\_id | The organization id for the associated services | `string` | n/a | yes |
| parent\_id | The parent folder or org for environments | `string` | n/a | yes |
| project\_prefix | Name prefix to use for projects created. | `string` | `"prj"` | no |
| restricted\_network\_project\_alert\_pubsub\_topic | The name of the Cloud Pub/Sub topic where budget related messages will be published, in the form of `projects/{project_id}/topics/{topic_id}` for the restricted networks project | `string` | `null` | no |
| restricted\_network\_project\_alert\_spent\_percents | A list of percentages of the budget to alert on when threshold is exceeded for the restricted networks project. | `list(number)` | <pre>[<br> 0.5,<br> 0.75,<br> 0.9,<br> 0.95<br>]</pre> | no |
| restricted\_network\_project\_budget\_amount | The amount to use as the budget for the restricted networks project. | `number` | `1000` | no |
Expand Down
4 changes: 2 additions & 2 deletions 2-environments/modules/env_baseline/folders.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*****************************************/

data "google_active_folder" "common" {
display_name = "fldr-common"
display_name = "${var.folder_prefix}-common"
parent = local.parent
}

Expand All @@ -28,6 +28,6 @@ data "google_active_folder" "common" {
*****************************************/

resource "google_folder" "env" {
display_name = "fldr-${var.env}"
display_name = "${var.folder_prefix}-${var.env}"
parent = local.parent
}
2 changes: 1 addition & 1 deletion 2-environments/modules/env_baseline/monitoring.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module "monitoring_project" {
version = "~> 9.2"
random_project_id = "true"
impersonate_service_account = var.terraform_service_account
name = "prj-${var.environment_code}-monitoring"
name = "${var.project_prefix}-${var.environment_code}-monitoring"
org_id = var.org_id
billing_account = var.billing_account
folder_id = google_folder.env.id
Expand Down
4 changes: 2 additions & 2 deletions 2-environments/modules/env_baseline/networking.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module "base_shared_vpc_host_project" {
version = "~> 9.2"
random_project_id = "true"
impersonate_service_account = var.terraform_service_account
name = "prj-${var.environment_code}-shared-base"
name = "${var.project_prefix}-${var.environment_code}-shared-base"
org_id = var.org_id
billing_account = var.billing_account
folder_id = google_folder.env.id
Expand Down Expand Up @@ -57,7 +57,7 @@ module "restricted_shared_vpc_host_project" {
version = "~> 9.2"
random_project_id = "true"
impersonate_service_account = var.terraform_service_account
name = "prj-${var.environment_code}-shared-restricted"
name = "${var.project_prefix}-${var.environment_code}-shared-restricted"
org_id = var.org_id
billing_account = var.billing_account
folder_id = google_folder.env.id
Expand Down
4 changes: 2 additions & 2 deletions 2-environments/modules/env_baseline/secrets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ module "env_secrets" {
version = "~> 9.2"
random_project_id = "true"
impersonate_service_account = var.terraform_service_account
default_service_account = "deprivilege"
name = "prj-${var.environment_code}-secrets"
default_service_account = "depriviledge"
name = "${var.project_prefix}-${var.environment_code}-secrets"
org_id = var.org_id
billing_account = var.billing_account
folder_id = google_folder.env.id
Expand Down
12 changes: 12 additions & 0 deletions 2-environments/modules/env_baseline/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,15 @@ variable "secret_project_budget_amount" {
type = number
default = 1000
}

variable "project_prefix" {
description = "Name prefix to use for projects created."
type = string
default = "prj"
}

variable "folder_prefix" {
description = "Name prefix to use for folders created."
type = string
default = "fldr"
}
3 changes: 2 additions & 1 deletion 3-networks/envs/development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ The purpose of this step is to set up base and restricted shared VPCs with defau
| dns\_enable\_inbound\_forwarding | Toggle inbound query forwarding for VPC DNS. | `bool` | `true` | no |
| dns\_enable\_logging | Toggle DNS logging for VPC DNS. | `bool` | `true` | no |
| domain | The DNS name of peering managed zone, for instance 'example.com.' | `string` | n/a | yes |
| firewall\_enable\_logging | Toggle firewall logging for VPC Firewalls. | `bool` | `true` | no |
| firewall\_enable\_logging | Toggle firewall logginglogging for VPC Firewalls. | `bool` | `true` | no |
| folder\_prefix | Name prefix to use for folders created. | `string` | `"fldr"` | no |
| nat\_bgp\_asn | BGP ASN for first NAT cloud routes. | `number` | `64514` | no |
| nat\_enabled | Toggle creation of NAT cloud router. | `bool` | `false` | no |
| nat\_num\_addresses | Number of external IPs to reserve for Cloud NAT. | `number` | `2` | no |
Expand Down

0 comments on commit 66dacf2

Please sign in to comment.