Skip to content

Commit c41ba36

Browse files
authored
feat: expose grant_services_security_admin_role var (#536)
It's supported already in the shared_vpc_access submodule but not available in upper modules. It should be exposed so caller of project factory modules can leverage this feature.
1 parent 67a0b04 commit c41ba36

File tree

6 files changed

+32
-16
lines changed

6 files changed

+32
-16
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ determining that location is as follows:
130130
| domain | The domain name (optional). | `string` | `""` | no |
131131
| enable\_shared\_vpc\_host\_project | If this project is a shared VPC host project. If true, you must *not* set svpc\_host\_project\_id variable. Default is false. | `bool` | `false` | no |
132132
| folder\_id | The ID of a folder to host this project | `string` | `""` | no |
133+
| grant\_services\_security\_admin\_role | Whether or not to grant Kubernetes Engine Service Agent the Security Admin role on the host project so it can manage firewall rules | `bool` | `false` | no |
133134
| group\_name | A group to control the project by being assigned group\_role (defaults to project editor) | `string` | `""` | no |
134135
| group\_role | The role to give the controlling group (group\_name) over the project (defaults to project editor) | `string` | `"roles/editor"` | no |
135136
| impersonate\_service\_account | An optional service account to impersonate. This cannot be used with credentials\_path. If this service account is not specified and credentials\_path is absent, the module will use Application Default Credentials. | `string` | `""` | no |

main.tf

+9-8
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@ module "project-factory" {
6868
Setting API service accounts for shared VPC
6969
*****************************************/
7070
module "shared_vpc_access" {
71-
source = "./modules/shared_vpc_access"
72-
enable_shared_vpc_service_project = var.svpc_host_project_id != "" ? true : false
73-
host_project_id = var.svpc_host_project_id
74-
service_project_id = module.project-factory.project_id
75-
active_apis = module.project-factory.enabled_apis
76-
shared_vpc_subnets = var.shared_vpc_subnets
77-
service_project_number = module.project-factory.project_number
78-
lookup_project_numbers = false
71+
source = "./modules/shared_vpc_access"
72+
enable_shared_vpc_service_project = var.svpc_host_project_id != "" ? true : false
73+
host_project_id = var.svpc_host_project_id
74+
service_project_id = module.project-factory.project_id
75+
active_apis = module.project-factory.enabled_apis
76+
shared_vpc_subnets = var.shared_vpc_subnets
77+
service_project_number = module.project-factory.project_number
78+
lookup_project_numbers = false
79+
grant_services_security_admin_role = var.grant_services_security_admin_role
7980
}
8081

8182
/******************************************

modules/svpc_service_project/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ module "service-project" {
5050
| disable\_services\_on\_destroy | Whether project services will be disabled when the resources are destroyed | `bool` | `true` | no |
5151
| domain | The domain name (optional). | `string` | `""` | no |
5252
| folder\_id | The ID of a folder to host this project | `string` | `""` | no |
53+
| grant\_services\_security\_admin\_role | Whether or not to grant Kubernetes Engine Service Agent the Security Admin role on the host project so it can manage firewall rules | `bool` | `false` | no |
5354
| group\_name | A group to control the project by being assigned group\_role (defaults to project editor) | `string` | `""` | no |
5455
| group\_role | The role to give the controlling group (group\_name) over the project (defaults to project editor) | `string` | `"roles/editor"` | no |
5556
| impersonate\_service\_account | An optional service account to impersonate. This cannot be used with credentials\_path. If this service account is not specified and credentials\_path is absent, the module will use Application Default Credentials. | `string` | `""` | no |

modules/svpc_service_project/main.tf

+9-8
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ module "project-factory" {
6464
Setting API service accounts for shared VPC
6565
*****************************************/
6666
module "shared_vpc_access" {
67-
source = "../shared_vpc_access"
68-
host_project_id = var.shared_vpc
69-
enable_shared_vpc_service_project = true
70-
service_project_id = module.project-factory.project_id
71-
active_apis = module.project-factory.enabled_apis
72-
shared_vpc_subnets = var.shared_vpc_subnets
73-
service_project_number = module.project-factory.project_number
74-
lookup_project_numbers = false
67+
source = "../shared_vpc_access"
68+
host_project_id = var.shared_vpc
69+
enable_shared_vpc_service_project = true
70+
service_project_id = module.project-factory.project_id
71+
active_apis = module.project-factory.enabled_apis
72+
shared_vpc_subnets = var.shared_vpc_subnets
73+
service_project_number = module.project-factory.project_number
74+
lookup_project_numbers = false
75+
grant_services_security_admin_role = var.grant_services_security_admin_role
7576
}
7677

7778
/******************************************

modules/svpc_service_project/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,9 @@ variable "budget_alert_spent_percents" {
214214
type = list(number)
215215
default = [0.5, 0.7, 1.0]
216216
}
217+
218+
variable "grant_services_security_admin_role" {
219+
description = "Whether or not to grant Kubernetes Engine Service Agent the Security Admin role on the host project so it can manage firewall rules"
220+
type = bool
221+
default = false
222+
}

variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,9 @@ variable "vpc_service_control_perimeter_name" {
240240
type = string
241241
default = null
242242
}
243+
244+
variable "grant_services_security_admin_role" {
245+
description = "Whether or not to grant Kubernetes Engine Service Agent the Security Admin role on the host project so it can manage firewall rules"
246+
type = bool
247+
default = false
248+
}

0 commit comments

Comments
 (0)