add support for optional project suffix

This commit is contained in:
Ludovico Magnocavallo
2022-02-18 14:39:04 +01:00
parent f84c47d6f4
commit 2259f3f44c
9 changed files with 18 additions and 10 deletions

View File

@@ -25,7 +25,7 @@ module "land-project" {
parent = var.folder_id
billing_account = var.billing_account_id
prefix = var.prefix
name = "lnd"
name = "lnd${local.project_suffix}"
group_iam = {
(local.groups.data-engineers) = [
"roles/bigquery.dataEditor",

View File

@@ -38,7 +38,7 @@ module "load-project" {
parent = var.folder_id
billing_account = var.billing_account_id
prefix = var.prefix
name = "lod"
name = "lod${local.project_suffix}"
group_iam = {
(local.groups.data-engineers) = [
"roles/compute.viewer",

View File

@@ -32,7 +32,7 @@ module "orch-project" {
parent = var.folder_id
billing_account = var.billing_account_id
prefix = var.prefix
name = "orc"
name = "orc${local.project_suffix}"
group_iam = {
(local.groups.data-engineers) = [
"roles/bigquery.dataEditor",

View File

@@ -32,7 +32,7 @@ module "transf-project" {
parent = var.folder_id
billing_account = var.billing_account_id
prefix = var.prefix
name = "trf"
name = "trf${local.project_suffix}"
group_iam = {
(local.groups.data-engineers) = [
"roles/bigquery.jobUser",

View File

@@ -92,7 +92,7 @@ module "lake-0-project" {
parent = var.folder_id
billing_account = var.billing_account_id
prefix = var.prefix
name = "dtl-0"
name = "dtl-0${local.project_suffix}"
group_iam = local.lake_group_iam
iam = local.lake_0_iam
services = local.lake_services
@@ -107,7 +107,7 @@ module "lake-1-project" {
parent = var.folder_id
billing_account = var.billing_account_id
prefix = var.prefix
name = "dtl-1"
name = "dtl-1${local.project_suffix}"
group_iam = local.lake_group_iam
iam = local.lake_iam
services = local.lake_services
@@ -122,7 +122,7 @@ module "lake-2-project" {
parent = var.folder_id
billing_account = var.billing_account_id
prefix = var.prefix
name = "dtl-2"
name = "dtl-2${local.project_suffix}"
group_iam = local.lake_group_iam
iam = local.lake_iam
services = local.lake_services
@@ -137,7 +137,7 @@ module "lake-plg-project" {
parent = var.folder_id
billing_account = var.billing_account_id
prefix = var.prefix
name = "dtl-plg"
name = "dtl-plg${local.project_suffix}"
group_iam = local.lake_plg_group_iam
iam = {}
services = local.lake_services

View File

@@ -19,5 +19,5 @@ module "exp-project" {
parent = var.folder_id
billing_account = var.billing_account_id
prefix = var.prefix
name = "exp"
name = "exp${local.project_suffix}"
}

View File

@@ -234,7 +234,8 @@ Description of commands:
| [location](variables.tf#L47) | Location used for multi-regional resources. | <code>string</code> | | <code>&#34;eu&#34;</code> |
| [network_config](variables.tf#L63) | Shared VPC network configurations to use. If null networks will be created in projects with preconfigured values. | <code title="object&#40;&#123;&#10; host_project &#61; string&#10; network_self_link &#61; string&#10; subnet_self_links &#61; object&#40;&#123;&#10; load &#61; string&#10; transformation &#61; string&#10; orchestration &#61; string&#10; &#125;&#41;&#10; composer_ip_ranges &#61; object&#40;&#123;&#10; cloudsql &#61; string&#10; gke_master &#61; string&#10; web_server &#61; string&#10; &#125;&#41;&#10; composer_secondary_ranges &#61; object&#40;&#123;&#10; pods &#61; string&#10; services &#61; string&#10; &#125;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
| [project_services](variables.tf#L96) | List of core services enabled on all projects. | <code>list&#40;string&#41;</code> | | <code title="&#91;&#10; &#34;cloudresourcemanager.googleapis.com&#34;,&#10; &#34;iam.googleapis.com&#34;,&#10; &#34;serviceusage.googleapis.com&#34;,&#10; &#34;stackdriver.googleapis.com&#34;&#10;&#93;">&#91;&#8230;&#93;</code> |
| [region](variables.tf#L107) | Region used for regional resources. | <code>string</code> | | <code>&#34;europe-west1&#34;</code> |
| [project_suffix](variables.tf#L107) | Suffix used only for project ids. | <code>string</code> | | <code>null</code> |
| [region](variables.tf#L113) | Region used for regional resources. | <code>string</code> | | <code>&#34;europe-west1&#34;</code> |
## Outputs

View File

@@ -35,6 +35,7 @@ locals {
groups_iam = {
for k, v in local.groups : k => "group:${v}"
}
project_suffix = var.project_suffix == null ? "" : "-${var.project_suffix}"
service_encryption_keys = var.service_encryption_keys
shared_vpc_project = try(var.network_config.host_project, null)
# this is needed so that for_each only uses static values

View File

@@ -104,6 +104,12 @@ variable "project_services" {
]
}
variable "project_suffix" {
description = "Suffix used only for project ids."
type = string
default = null
}
variable "region" {
description = "Region used for regional resources."
type = string