- Notifications
You must be signed in to change notification settings - Fork 393
feat: Added IAP Principals terraform resource for backend-service #528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2c202c1 721407c 9b22215 f26db6d 83d29c4 d27d2dd e13b51a fc5f26e c1fb134 739224a 1060256 ad0dc82 6f03fd9 3cbc9d5 1080e69 92113c1 73ec3ab 0a41688 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /** | ||
| * Copyright 2025 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 | ||
| * | ||
| * http://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. | ||
| */ | ||
| | ||
| module "lb-backend-iap" { | ||
| source = "terraform-google-modules/lb-http/google//modules/backend" | ||
| version = "~> 12.0" | ||
| | ||
| project_id = var.project_id | ||
| name = "backend-with-iap" | ||
| iap_config = { | ||
| enable = true | ||
| iap_members = ["user:test@test.test"] | ||
| } | ||
| } | ||
| | ||
| module "lb-frontend" { | ||
| source = "terraform-google-modules/lb-http/google//modules/frontend" | ||
| version = "~> 12.0" | ||
| | ||
| project_id = var.project_id | ||
| name = "global-lb-fe-bucket" | ||
| url_map_input = module.lb-backend-iap.backend_service_info | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| /** | ||
| * Copyright 2025 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 | ||
| * | ||
| * http://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. | ||
| */ | ||
| | ||
| | ||
| output "project_id" { | ||
| value = module.lb-backend-iap.project_id | ||
| description = "Project ID of the service" | ||
| } | ||
| | ||
| output "service_name" { | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need this to be added as output. You can directly use the | ||
| value = module.lb-backend-iap.service_name | ||
| description = "Name of the created service" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /** | ||
| * Copyright 2025 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 | ||
| * | ||
| * http://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. | ||
| */ | ||
| | ||
| variable "project_id" { | ||
| type = string | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -22,7 +22,7 @@ This module creates `google_compute_backend_service` resource and its dependenci | |
| | groups | The list of backend instance group which serves the traffic. | <pre>list(object({<br> group = string<br> description = optional(string)<br><br> balancing_mode = optional(string)<br> capacity_scaler = optional(number)<br> max_connections = optional(number)<br> max_connections_per_instance = optional(number)<br> max_connections_per_endpoint = optional(number)<br> max_rate = optional(number)<br> max_rate_per_instance = optional(number)<br> max_rate_per_endpoint = optional(number)<br> max_utilization = optional(number)<br> }))</pre> | `[]` | no | | ||
| | health\_check | Input for creating HttpHealthCheck or HttpsHealthCheck resource for health checking this BackendService. A health check must be specified unless the backend service uses an internet or serverless NEG as a backend. | <pre>object({<br> host = optional(string, null)<br> request_path = optional(string, null)<br> request = optional(string, null)<br> response = optional(string, null)<br> port = optional(number, null)<br> port_name = optional(string, null)<br> proxy_header = optional(string, null)<br> port_specification = optional(string, null)<br> protocol = optional(string, null)<br> check_interval_sec = optional(number, 5)<br> timeout_sec = optional(number, 5)<br> healthy_threshold = optional(number, 2)<br> unhealthy_threshold = optional(number, 2)<br> logging = optional(bool, false)<br> })</pre> | `null` | no | | ||
| | host\_path\_mappings | The list of host/path for which traffic could be sent to the backend service | <pre>list(object({<br> host = string<br> path = string<br> }))</pre> | <pre>[<br> {<br> "host": "*",<br> "path": "/*"<br> }<br>]</pre> | no | | ||
| | iap\_config | Settings for enabling Cloud Identity Aware Proxy Structure. | <pre>object({<br> enable = bool<br> oauth2_client_id = optional(string)<br> oauth2_client_secret = optional(string)<br> })</pre> | <pre>{<br> "enable": false<br>}</pre> | no | | ||
| | iap\_config | Settings for enabling Cloud Identity Aware Proxy and Users/SAs to be given IAP HttpResourceAccessor access to the service. | <pre>object({<br> enable = bool<br> oauth2_client_id = optional(string)<br> oauth2_client_secret = optional(string)<br> iap_members = optional(list(string))<br> })</pre> | <pre>{<br> "enable": false<br>}</pre> | no | | ||
| | load\_balancing\_scheme | Load balancing scheme type (EXTERNAL for classic external load balancer, EXTERNAL\_MANAGED for Envoy-based load balancer, INTERNAL\_MANAGED for internal load balancer and INTERNAL\_SELF\_MANAGED for traffic director) | `string` | `"EXTERNAL_MANAGED"` | no | | ||
| | locality\_lb\_policy | The load balancing algorithm used within the scope of the locality. | `string` | `null` | no | | ||
| | log\_config | This field denotes the logging options for the load balancer traffic served by this backend service. If logging is enabled, logs will be exported to Stackdriver. | <pre>object({<br> enable = bool<br> sample_rate = number<br> })</pre> | <pre>{<br> "enable": true,<br> "sample_rate": 1<br>}</pre> | no | | ||
| | @@ -44,5 +44,7 @@ This module creates `google_compute_backend_service` resource and its dependenci | |
| |------|-------------| | ||
| | apphub\_service\_uri | Service URI in CAIS style to be used by Apphub. | | ||
| | backend\_service\_info | Host, path and backend service mapping | | ||
| | project\_id | Project ID of the service | | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These new output variables are not needed. | ||
| | service\_name | Name of the created service | | ||
| | ||
| <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -32,6 +32,8 @@ spec: | |
| description: {} | ||
| content: | ||
| examples: | ||
| - name: backend-with-iap | ||
| location: examples/backend-with-iap | ||
| - name: cdn-policy | ||
| location: examples/cdn-policy | ||
| - name: certificate-map | ||
| | @@ -189,12 +191,13 @@ spec: | |
| spec: | ||
| outputExpr: name | ||
| - name: iap_config | ||
| description: Settings for enabling Cloud Identity Aware Proxy Structure. | ||
| description: Settings for enabling Cloud Identity Aware Proxy and Users/SAs to be given IAP HttpResourceAccessor access to the service. | ||
| varType: |- | ||
| object({ | ||
| enable = bool | ||
| oauth2_client_id = optional(string) | ||
| oauth2_client_secret = optional(string) | ||
| iap_members = optional(list(string)) | ||
| }) | ||
| defaultValue: | ||
| enable: false | ||
| | @@ -327,20 +330,25 @@ spec: | |
| - backend_service: string | ||
| host: string | ||
| path: string | ||
| - name: project_id | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These new output variables are not needed | ||
| description: Project ID of the service | ||
| - name: service_name | ||
| description: Name of the created service | ||
| requirements: | ||
| roles: | ||
| - level: Project | ||
| roles: | ||
| - roles/run.admin | ||
| - roles/compute.networkAdmin | ||
| - roles/iap.admin | ||
| - roles/iam.serviceAccountUser | ||
| - roles/iam.serviceAccountAdmin | ||
| - roles/compute.admin | ||
| - roles/storage.admin | ||
| - roles/run.admin | ||
| - roles/compute.networkAdmin | ||
| - roles/iap.admin | ||
| services: | ||
| - cloudresourcemanager.googleapis.com | ||
| - compute.googleapis.com | ||
| - iap.googleapis.com | ||
| - run.googleapis.com | ||
| - storage-api.googleapis.com | ||
| - vpcaccess.googleapis.com | ||
| | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -43,3 +43,13 @@ output "apphub_service_uri" { | |
| ) | ||
| description = "Service URI in CAIS style to be used by Apphub." | ||
| } | ||
| | ||
| output "project_id" { | ||
| Collaborator There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this? Input should not be added as output. | ||
| value = var.project_id | ||
| description = "Project ID of the service" | ||
| } | ||
| | ||
| output "service_name" { | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here! | ||
| value = var.name | ||
| description = "Name of the created service" | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can directly use var.project_id here.