fix remaining issues, align variables

This commit is contained in:
Ludovico Magnocavallo 2022-02-16 14:12:39 +01:00
parent 0c9e2a5767
commit c5fa5d62e4
7 changed files with 107 additions and 72 deletions

View File

@ -74,8 +74,8 @@ locals {
}
service_accounts = merge(
{
data-platform-dev = module.branch-dp-dev-sa.iam_email
data-platform-prod = module.branch-dp-prod-sa.iam_email
data-platform-dev = module.branch-dp-dev-sa.email
data-platform-prod = module.branch-dp-prod-sa.email
networking = module.branch-network-sa.email
project-factory-dev = module.branch-teams-dev-projectfactory-sa.email
project-factory-prod = module.branch-teams-prod-projectfactory-sa.email

View File

@ -37,7 +37,7 @@ module "landing-project" {
enabled = true
service_projects = []
}
metric_scopes = [module.landing-project.project_id]
# metric_scopes = [module.landing-project.project_id]
iam = {
"roles/dns.admin" = [local.service_accounts.project-factory-prod]
(local.custom_roles.service_project_network_admin) = [

View File

@ -37,7 +37,7 @@ module "landing-project" {
enabled = true
service_projects = []
}
metric_scopes = [module.landing-project.project_id]
# metric_scopes = [module.landing-project.project_id]
iam = {
"roles/dns.admin" = [local.service_accounts.project-factory-prod]
(local.custom_roles.service_project_network_admin) = [

View File

@ -25,9 +25,15 @@ locals {
prod-landing = module.landing-project.number
prod-spoke-0 = module.prod-spoke-project.number
}
subnet_self_links = {
prod-landing = module.landing-vpc.subnet_self_links
dev-spoke-0 = module.dev-spoke-vpc.subnet_self_links
prod-spoke-0 = module.prod-spoke-vpc.subnet_self_links
}
tfvars = {
host_project_ids = local.host_project_ids
host_project_numbers = local.host_project_numbers
subnet_self_links = local.subnet_self_links
vpc_self_links = local.vpc_self_links
}
vpc_self_links = {

View File

@ -110,25 +110,27 @@ terraform apply
|---|---|---|---|
| [main.tf](./main.tf) | Data Platformy. | <code>data-platform-foundations</code> | |
| [outputs.tf](./outputs.tf) | Output variables. | | <code>local_file</code> |
| [providers.tf](./providers.tf) | Provider configurations. | | |
| [variables.tf](./variables.tf) | Terraform Variables. | | |
## Variables
| name | description | type | required | default | producer |
|---|---|:---:|:---:|:---:|:---:|
| [billing_account_id](variables.tf#L17) | Billing account id. | <code>string</code> | ✓ | | <code>00-bootstrap</code> |
| [folder_id](variables.tf#L42) | Folder to be used for the networking resources in folders/nnnn format. | <code>string</code> | ✓ | | <code>resman</code> |
| [network_config](variables.tf#L58) | Network configurations to use. Specify a shared VPC to use, if null networks will be created in projects. | <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;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | | |
| [organization_domain](variables.tf#L97) | Organization domain. | <code>string</code> | ✓ | | |
| [prefix](variables.tf#L108) | Unique prefix used for resource names. Not used for projects if 'project_create' is null. | <code>string</code> | ✓ | | <code>00-bootstrap</code> |
| [composer_config](variables.tf#L23) | | <code title="object&#40;&#123;&#10; node_count &#61; number&#10; airflow_version &#61; string&#10; env_variables &#61; map&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; node_count &#61; 3&#10; airflow_version &#61; &#34;composer-1.17.5-airflow-2.1.4&#34;&#10; env_variables &#61; &#123;&#125;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [data_force_destroy](variables.tf#L36) | Flag to set 'force_destroy' on data services like BiguQery or Cloud Storage. | <code>bool</code> | | <code>false</code> | |
| [groups](variables.tf#L48) | Groups. | <code>map&#40;string&#41;</code> | | <code title="&#123;&#10; data-analysts &#61; &#34;gcp-data-analysts&#34;&#10; data-engineers &#61; &#34;gcp-data-engineers&#34;&#10; data-security &#61; &#34;gcp-data-security&#34;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [network_config_composer](variables.tf#L71) | Network configurations to use for Composer. | <code title="object&#40;&#123;&#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 title="&#123;&#10; composer_ip_ranges &#61; &#123;&#10; cloudsql &#61; &#34;172.18.29.0&#47;24&#34;&#10; gke_master &#61; &#34;172.18.30.0&#47;28&#34;&#10; web_server &#61; &#34;172.18.30.16&#47;28&#34;&#10; &#125;&#10; composer_secondary_ranges &#61; &#123;&#10; pods &#61; &#34;pods&#34;&#10; services &#61; &#34;services&#34;&#10; &#125;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [outputs_location](variables.tf#L102) | Path where providers, tfvars files, and lists for the following stages are written. Leave empty to disable. | <code>string</code> | | <code>null</code> | |
| [project_services](variables.tf#L114) | 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#L125) | Region used for regional resources. | <code>string</code> | | <code>&#34;europe-west1&#34;</code> | |
| [billing_account](variables.tf#L17) | Billing account id and organization id ('nnnnnnnn' or null). | <code title="object&#40;&#123;&#10; id &#61; string&#10; organization_id &#61; number&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | | <code>00-globals</code> |
| [host_project_ids](variables.tf#L64) | Shared VPC project ids. | <code title="object&#40;&#123;&#10; dev-spoke-0 &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | | <code>02-networking</code> |
| [organization](variables.tf#L90) | Organization details. | <code title="object&#40;&#123;&#10; domain &#61; string&#10; id &#61; number&#10; customer_id &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | ✓ | | <code>00-globals</code> |
| [prefix](variables.tf#L106) | Unique prefix used for resource names. Not used for projects if 'project_create' is null. | <code>string</code> | ✓ | | <code>00-globals</code> |
| [composer_config](variables.tf#L26) | | <code title="object&#40;&#123;&#10; node_count &#61; number&#10; airflow_version &#61; string&#10; env_variables &#61; map&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; node_count &#61; 3&#10; airflow_version &#61; &#34;composer-1.17.5-airflow-2.1.4&#34;&#10; env_variables &#61; &#123;&#125;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [data_force_destroy](variables.tf#L39) | Flag to set 'force_destroy' on data services like BigQery or Cloud Storage. | <code>bool</code> | | <code>false</code> | |
| [folder_ids](variables.tf#L45) | Folder to be used for the networking resources in folders/nnnn format. | <code title="object&#40;&#123;&#10; data-platform &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> | <code>01-resman</code> |
| [groups](variables.tf#L54) | Groups. | <code>map&#40;string&#41;</code> | | <code title="&#123;&#10; data-analysts &#61; &#34;gcp-data-analysts&#34;&#10; data-engineers &#61; &#34;gcp-data-engineers&#34;&#10; data-security &#61; &#34;gcp-data-security&#34;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [network_config_composer](variables.tf#L72) | Network configurations to use for Composer. | <code title="object&#40;&#123;&#10; cloudsql_range &#61; string&#10; gke_master_range &#61; string&#10; gke_pods_name &#61; string&#10; gke_services_name &#61; string&#10; web_server_range &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; cloudsql_range &#61; &#34;172.18.29.0&#47;24&#34;&#10; gke_master_range &#61; &#34;172.18.30.0&#47;28&#34;&#10; gke_pods_name &#61; &#34;pods&#34;&#10; gke_services_name &#61; &#34;services&#34;&#10; web_server_range &#61; &#34;172.18.30.16&#47;28&#34;&#10;&#125;">&#123;&#8230;&#125;</code> | |
| [outputs_location](variables.tf#L100) | Path where providers, tfvars files, and lists for the following stages are written. Leave empty to disable. | <code>string</code> | | <code>null</code> | |
| [project_services](variables.tf#L112) | 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#L123) | Region used for regional resources. | <code>string</code> | | <code>&#34;europe-west1&#34;</code> | |
| [service_encryption_keys](variables.tf#L129) | Cloud KMS to use to encrypt different services. Key location should match service region. | <code title="object&#40;&#123;&#10; bq &#61; string&#10; composer &#61; string&#10; dataflow &#61; string&#10; storage &#61; string&#10; pubsub &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> | |
| [subnet_self_links](variables.tf#L141) | Shared VPC subnet self links. | <code title="object&#40;&#123;&#10; dev-spoke-0 &#61; map&#40;string&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> | <code>02-networking</code> |
| [vpc_self_links](variables.tf#L150) | Shared VPC self links. | <code title="object&#40;&#123;&#10; dev-spoke-0 &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> | <code>02-networking</code> |
## Outputs

View File

@ -16,22 +16,33 @@
# tfdoc:file:description Data Platformy.
locals {
_network_config = merge(
var.network_config_composer,
var.network_config
)
}
module "data-platform" {
source = "../../../../examples/data-solutions/data-platform-foundations"
billing_account_id = var.billing_account_id
composer_config = var.composer_config
data_force_destroy = var.data_force_destroy
folder_id = var.folder_id
groups = var.groups
network_config = local._network_config
organization_domain = var.organization_domain
source = "../../../../examples/data-solutions/data-platform-foundations"
billing_account_id = var.billing_account.id
composer_config = var.composer_config
data_force_destroy = var.data_force_destroy
folder_id = var.folder_ids.data-platform
groups = var.groups
network_config = {
host_project = var.host_project_ids.dev-spoke-0
network_self_link = var.vpc_self_links.dev-spoke-0
subnet_self_links = {
load = var.subnet_self_links.dev-spoke-0["europe-west1/dev-dataplatform-ew1"]
transformation = var.subnet_self_links.dev-spoke-0["europe-west1/dev-dataplatform-ew1"]
orchestration = var.subnet_self_links.dev-spoke-0["europe-west1/dev-dataplatform-ew1"]
}
# TODO: align example variable
composer_ip_ranges = {
cloudsql = var.network_config_composer.cloudsql_range
gke_master = var.network_config_composer.gke_master_range
web_server = var.network_config_composer.web_server_range
}
composer_secondary_ranges = {
pods = var.network_config_composer.gke_pods_name
services = var.network_config_composer.gke_services_name
}
}
organization_domain = var.organization.domain
prefix = var.prefix
project_services = var.project_services
region = var.region

View File

@ -14,10 +14,13 @@
# tfdoc:file:description Terraform Variables.
variable "billing_account_id" {
# tfdoc:variable:source 00-bootstrap
description = "Billing account id."
type = string
variable "billing_account" {
# tfdoc:variable:source 00-globals
description = "Billing account id and organization id ('nnnnnnnn' or null)."
type = object({
id = string
organization_id = number
})
}
variable "composer_config" {
@ -34,15 +37,18 @@ variable "composer_config" {
}
variable "data_force_destroy" {
description = "Flag to set 'force_destroy' on data services like BiguQery or Cloud Storage."
description = "Flag to set 'force_destroy' on data services like BigQery or Cloud Storage."
type = bool
default = false
}
variable "folder_id" {
# tfdoc:variable:source resman
variable "folder_ids" {
# tfdoc:variable:source 01-resman
description = "Folder to be used for the networking resources in folders/nnnn format."
type = string
type = object({
data-platform = string
})
default = null
}
variable "groups" {
@ -55,48 +61,40 @@ variable "groups" {
}
}
variable "network_config" {
description = "Network configurations to use. Specify a shared VPC to use, if null networks will be created in projects."
variable "host_project_ids" {
# tfdoc:variable:source 02-networking
description = "Shared VPC project ids."
type = object({
host_project = string
network_self_link = string
subnet_self_links = object({
load = string
transformation = string
orchestration = string
})
dev-spoke-0 = string
})
}
variable "network_config_composer" {
description = "Network configurations to use for Composer."
type = object({
composer_ip_ranges = object({
cloudsql = string
gke_master = string
web_server = string
})
composer_secondary_ranges = object({
pods = string
services = string
})
cloudsql_range = string
gke_master_range = string
gke_pods_name = string
gke_services_name = string
web_server_range = string
})
default = {
composer_ip_ranges = {
cloudsql = "172.18.29.0/24"
gke_master = "172.18.30.0/28"
web_server = "172.18.30.16/28"
}
composer_secondary_ranges = {
pods = "pods"
services = "services"
}
cloudsql_range = "172.18.29.0/24"
gke_master_range = "172.18.30.0/28"
gke_pods_name = "pods"
gke_services_name = "services"
web_server_range = "172.18.30.16/28"
}
}
variable "organization_domain" {
description = "Organization domain."
type = string
variable "organization" {
# tfdoc:variable:source 00-globals
description = "Organization details."
type = object({
domain = string
id = number
customer_id = string
})
}
variable "outputs_location" {
@ -106,7 +104,7 @@ variable "outputs_location" {
}
variable "prefix" {
# tfdoc:variable:source 00-bootstrap
# tfdoc:variable:source 00-globals
description = "Unique prefix used for resource names. Not used for projects if 'project_create' is null."
type = string
}
@ -128,7 +126,7 @@ variable "region" {
default = "europe-west1"
}
variable "service_encryption_keys" { # service encription key
variable "service_encryption_keys" {
description = "Cloud KMS to use to encrypt different services. Key location should match service region."
type = object({
bq = string
@ -139,3 +137,21 @@ variable "service_encryption_keys" { # service encription key
})
default = null
}
variable "subnet_self_links" {
# tfdoc:variable:source 02-networking
description = "Shared VPC subnet self links."
type = object({
dev-spoke-0 = map(string)
})
default = null
}
variable "vpc_self_links" {
# tfdoc:variable:source 02-networking
description = "Shared VPC self links."
type = object({
dev-spoke-0 = string
})
default = null
}