Skip to content

Commit b170478

Browse files
authored
fix: add standalone repo for terraform-validator policies (terraform-google-modules#403)
* add standalone repo for terraform-validator policies * fix terraform lint issue
1 parent 7beb5a0 commit b170478

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

0-bootstrap/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Currently, the bucket information is replaced in the state backends as a part of
6161
| Name | Description | Type | Default | Required |
6262
|------|-------------|------|---------|:--------:|
6363
| billing\_account | The ID of the billing account to associate projects with. | `string` | n/a | yes |
64-
| cloud\_source\_repos | List of Cloud Source Repositories created during bootstrap project build stage | `list(string)` | <pre>[<br> "gcp-org",<br> "gcp-environments",<br> "gcp-networks",<br> "gcp-projects",<br> "gcp-policies"<br>]</pre> | no |
64+
| cloud\_source\_repos | List of Cloud Source Repositories created during bootstrap project build stage for use with Cloud Build. | `list(string)` | <pre>[<br> "gcp-org",<br> "gcp-environments",<br> "gcp-networks",<br> "gcp-projects"<br>]</pre> | no |
6565
| default\_region | Default region to create resources where applicable. | `string` | `"us-central1"` | no |
6666
| folder\_prefix | Name prefix to use for folders created. | `string` | `"fldr"` | no |
6767
| group\_billing\_admins | Google Group for GCP Billing Administrators | `string` | n/a | yes |
@@ -85,6 +85,7 @@ Currently, the bucket information is replaced in the state backends as a part of
8585
| seed\_project\_id | Project where service accounts and core APIs will be enabled. |
8686
| terraform\_sa\_name | Fully qualified name for privileged service account for Terraform. |
8787
| terraform\_service\_account | Email for privileged service account for Terraform. |
88+
| terraform\_validator\_policies\_repo | Cloud Source Repository created for terraform-validator policies. |
8889
8990
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
9091

0-bootstrap/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,15 @@ module "cloudbuild_bootstrap" {
150150
]
151151
}
152152

153+
// Standalone repo for Terraform-validator policies.
154+
// This repo does not need to trigger builds in Cloud Build.
155+
resource "google_sourcerepo_repository" "gcp_policies" {
156+
project = module.cloudbuild_bootstrap.cloudbuild_project_id
157+
name = "gcp-policies"
158+
159+
depends_on = [module.cloudbuild_bootstrap.csr_repos]
160+
}
161+
153162
resource "google_project_iam_member" "project_source_reader" {
154163
project = module.cloudbuild_bootstrap.cloudbuild_project_id
155164
role = "roles/source.reader"

0-bootstrap/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ output "csr_repos" {
5353
value = module.cloudbuild_bootstrap.csr_repos
5454
}
5555

56+
output "terraform_validator_policies_repo" {
57+
description = "Cloud Source Repository created for terraform-validator policies."
58+
value = google_sourcerepo_repository.gcp_policies
59+
}
60+
5661
output "kms_keyring" {
5762
description = "KMS Keyring created by the module."
5863
value = module.cloudbuild_bootstrap.kms_keyring

0-bootstrap/variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ variable "folder_prefix" {
7070
default = "fldr"
7171
}
7272
variable "cloud_source_repos" {
73-
description = "List of Cloud Source Repositories created during bootstrap project build stage"
73+
description = "List of Cloud Source Repositories created during bootstrap project build stage for use with Cloud Build."
7474
type = list(string)
75-
default = ["gcp-org", "gcp-environments", "gcp-networks", "gcp-projects", "gcp-policies"]
75+
default = ["gcp-org", "gcp-environments", "gcp-networks", "gcp-projects"]
7676
}
7777

7878
/* ----------------------------------------

test/integration/bootstrap/controls/gcp_cloudbuild.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
'gcp-org',
1919
'gcp-environments',
2020
'gcp-networks',
21-
'gcp-projects'
21+
'gcp-projects',
22+
'gcp-policies'
2223
]
2324

2425
control 'gcp_cloudbuild' do

0 commit comments

Comments
 (0)