Skip to content

Commit 4fa07fc

Browse files
committed
fix required directional policies keys and roles list
1 parent 589b590 commit 4fa07fc

File tree

4 files changed

+205
-114
lines changed

4 files changed

+205
-114
lines changed

1-org/envs/shared/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
| enable\_kms\_key\_usage\_tracking | Enable KMS centralized key usage tracking system. | `bool` | `true` | no |
1919
| enable\_scc\_resources\_in\_terraform | Create Security Command Center resources in Terraform. Security Command Center must be activated before the creation of the resources. See [Overview of activating Security Command Center](https://cloud.google.com/security-command-center/docs/activate-scc-overview) before enabling this feature. | `bool` | `false` | no |
2020
| enforce\_allowed\_worker\_pools | Whether to enforce the organization policy restriction on allowed worker pools for Cloud Build. | `bool` | `false` | no |
21+
| envs | n/a | `map(bool)` | <pre>{<br> "development": true,<br> "nonproduction": true,<br> "production": true<br>}</pre> | no |
2122
| essential\_contacts\_domains\_to\_allow | The list of domains that email addresses added to Essential Contacts can have. | `list(string)` | n/a | yes |
2223
| essential\_contacts\_language | Essential Contacts preferred language for notifications, as a ISO 639-1 language code. See [Supported languages](https://cloud.google.com/resource-manager/docs/managing-notification-contacts#supported-languages) for a list of supported languages. | `string` | `"en"` | no |
2324
| folder\_deletion\_protection | Prevent Terraform from destroying or recreating the folder. | `string` | `true` | no |

1-org/envs/shared/remote.tf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ locals {
3939
seed_project_id = data.terraform_remote_state.bootstrap.outputs.seed_project_id
4040
seed_project_number = data.terraform_remote_state.bootstrap.outputs.seed_project_number
4141
parent_id = data.terraform_remote_state.bootstrap.outputs.parent_id
42+
projects_gcs_bucket_tfstate = data.terraform_remote_state.bootstrap.outputs.projects_gcs_bucket_tfstate
43+
peering_projects_numbers = compact([for s in data.terraform_remote_state.projects_env : try(s.outputs.peering_project_number, null)])
44+
shared_vpc_project_numbers = compact([for s in data.terraform_remote_state.projects_env : try(s.outputs.shared_vpc_project_number, null)])
45+
app_infra_project_id = try(data.terraform_remote_state.projects_app_infra[0].outputs.cloudbuild_project_id, null)
46+
app_infra_project_number = try(data.terraform_remote_state.projects_app_infra[0].outputs.cloudbuild_project_number, null)
47+
48+
app_infra_pipeline_identity = local.app_infra_project_number != null ? "serviceAccount:${local.app_infra_project_number}@cloudbuild.gserviceaccount.com" : null
49+
app_infra_pipeline_source_projects = local.app_infra_project_number != null ? ["projects/${local.app_infra_project_number}"] : []
50+
app_infra_targets = distinct(concat(
51+
[for n in local.shared_vpc_project_numbers : "projects/${n}"],
52+
[for n in local.peering_projects_numbers : "projects/${n}"]
53+
))
54+
app_infra_cicd_identity = (
55+
local.app_infra_project_id != null
56+
? "serviceAccount:sa-tf-cb-bu1-example-app@${local.app_infra_project_id}.iam.gserviceaccount.com"
57+
: null
58+
)
4259
}
4360

4461
data "terraform_remote_state" "bootstrap" {
@@ -49,3 +66,25 @@ data "terraform_remote_state" "bootstrap" {
4966
prefix = "terraform/bootstrap/state"
5067
}
5168
}
69+
70+
data "terraform_remote_state" "projects_env" {
71+
backend = "gcs"
72+
73+
for_each = (var.required_egress_rules_app_infra_dry_run && var.required_ingress_rules_app_infra_dry_run) || (var.required_egress_rules_app_infra && var.required_ingress_rules_app_infra) ? var.envs : {}
74+
75+
config = {
76+
bucket = local.projects_gcs_bucket_tfstate
77+
prefix = "terraform/projects/business_unit_1/${each.key}"
78+
}
79+
}
80+
81+
data "terraform_remote_state" "projects_app_infra" {
82+
backend = "gcs"
83+
84+
count = (var.required_egress_rules_app_infra_dry_run && var.required_ingress_rules_app_infra_dry_run) || (var.required_egress_rules_app_infra && var.required_ingress_rules_app_infra) ? 1 : 0
85+
86+
config = {
87+
bucket = local.projects_gcs_bucket_tfstate
88+
prefix = "terraform/projects/business_unit_1/shared"
89+
}
90+
}

0 commit comments

Comments
 (0)