cloud-foundation-fabric/examples/data-solutions/data-platform-foundations/03-composer.tf

125 lines
4.7 KiB
Terraform
Raw Normal View History

2022-01-17 23:58:14 -08:00
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2022-02-01 00:09:53 -08:00
# tfdoc:file:description Orchestration Cloud Composer definition.
2022-01-31 21:41:33 -08:00
2022-02-09 08:01:25 -08:00
module "orch-sa-cmp-0" {
2022-02-12 01:20:14 -08:00
source = "../../../modules/iam-service-account"
project_id = module.orch-project.project_id
prefix = var.prefix
name = "orc-cmp-0"
display_name = "Data platform Composer service account"
2022-01-17 23:58:14 -08:00
iam = {
2022-02-09 08:01:25 -08:00
"roles/iam.serviceAccountTokenCreator" = [local.groups_iam.data-engineers]
"roles/iam.serviceAccountUser" = [module.orch-sa-cmp-0.iam_email]
2022-01-17 23:58:14 -08:00
}
}
2022-02-09 08:01:25 -08:00
resource "google_composer_environment" "orch-cmp-0" {
2022-01-17 23:58:14 -08:00
provider = google-beta
2022-02-09 08:01:25 -08:00
project = module.orch-project.project_id
name = "${var.prefix}-orc-cmp-0"
region = var.region
2022-01-17 23:58:14 -08:00
config {
2022-02-05 00:04:18 -08:00
node_count = var.composer_config.node_count
2022-01-17 23:58:14 -08:00
node_config {
2022-02-09 08:01:25 -08:00
zone = "${var.region}-b"
service_account = module.orch-sa-cmp-0.email
network = local.orch_vpc
subnetwork = local.orch_subnet
2022-01-17 23:58:14 -08:00
tags = ["composer-worker", "http-server", "https-server"]
ip_allocation_policy {
2022-02-09 08:01:25 -08:00
use_ip_aliases = "true"
cluster_secondary_range_name = try(
var.network_config.composer_secondary_ranges.pods, "pods"
)
services_secondary_range_name = try(
var.network_config.composer_secondary_ranges.services, "services"
)
2022-01-17 23:58:14 -08:00
}
}
software_config {
2022-02-07 12:28:54 -08:00
image_version = var.composer_config.airflow_version
env_variables = merge(
var.composer_config.env_variables, {
2022-02-12 00:48:16 -08:00
BQ_LOCATION = var.location
2022-02-09 08:01:25 -08:00
DTL_L0_PRJ = module.lake-0-project.project_id
DTL_L0_BQ_DATASET = module.lake-0-bq-0.dataset_id
DTL_L0_GCS = module.lake-0-cs-0.url
DTL_L1_PRJ = module.lake-1-project.project_id
DTL_L1_BQ_DATASET = module.lake-1-bq-0.dataset_id
DTL_L1_GCS = module.lake-1-cs-0.url
DTL_L2_PRJ = module.lake-2-project.project_id
DTL_L2_BQ_DATASET = module.lake-2-bq-0.dataset_id
DTL_L2_GCS = module.lake-2-cs-0.url
DTL_PLG_PRJ = module.lake-plg-project.project_id
DTL_PLG_BQ_DATASET = module.lake-plg-bq-0.dataset_id
DTL_PLG_GCS = module.lake-plg-cs-0.url
GCP_REGION = var.region
LND_PRJ = module.land-project.project_id
LND_BQ = module.land-bq-0.dataset_id
LND_GCS = module.land-cs-0.url
LND_PS = module.land-ps-0.id
LOD_PRJ = module.load-project.project_id
LOD_GCS_STAGING = module.load-cs-df-0.url
LOD_NET_VPC = local.load_vpc
LOD_NET_SUBNET = local.load_subnet
LOD_SA_DF = module.load-sa-df-0.email
ORC_PRJ = module.orch-project.project_id
ORC_GCS = module.orch-cs-0.url
TRF_PRJ = module.transf-project.project_id
TRF_GCS_STAGING = module.transf-cs-df-0.url
TRF_NET_VPC = local.transf_vpc
TRF_NET_SUBNET = local.transf_subnet
TRF_SA_DF = module.transf-sa-df-0.email
TRF_SA_BQ = module.transf-sa-bq-0.email
2022-02-07 12:28:54 -08:00
}
)
2022-01-17 23:58:14 -08:00
}
private_environment_config {
2022-02-09 08:01:25 -08:00
enable_private_endpoint = "true"
cloud_sql_ipv4_cidr_block = try(
var.network_config.composer_ip_ranges.cloudsql, "10.20.10.0/24"
)
master_ipv4_cidr_block = try(
var.network_config.composer_ip_ranges.gke_master, "10.20.11.0/28"
)
web_server_ipv4_cidr_block = try(
var.network_config.composer_ip_ranges.web_server, "10.20.11.16/28"
)
2022-01-17 23:58:14 -08:00
}
dynamic "encryption_config" {
2022-02-09 08:01:25 -08:00
for_each = (
try(local.service_encryption_keys.composer != null, false)
? { 1 = 1 }
: {}
)
2022-01-17 23:58:14 -08:00
content {
2022-01-31 22:09:25 -08:00
kms_key_name = try(local.service_encryption_keys.composer, null)
2022-01-17 23:58:14 -08:00
}
}
# web_server_network_access_control {
# allowed_ip_range {
# value = "172.16.0.0/12"
# description = "Allowed ip range"
# }
# }
}
2022-02-17 09:00:47 -08:00
depends_on = [
google_project_iam_member.shared_vpc,
]
2022-01-17 23:58:14 -08:00
}