|
| 1 | +/** |
| 2 | + * Copyright 2023 Google LLC |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +/****************************************** |
| 18 | + Run helper module to get generic calculated data |
| 19 | + *****************************************/ |
| 20 | +module "helper" { |
| 21 | + source = "../helper" |
| 22 | + bindings = var.bindings |
| 23 | + mode = var.mode |
| 24 | + entities = var.iap_web_backend_services |
| 25 | + conditional_bindings = var.conditional_bindings |
| 26 | +} |
| 27 | + |
| 28 | +/****************************************** |
| 29 | + IAP Web Backend IAM binding authoritative |
| 30 | + *****************************************/ |
| 31 | +resource "google_iap_web_backend_service_iam_binding" "iap_web_backend_service_iam_authoritative" { |
| 32 | + for_each = module.helper.set_authoritative |
| 33 | + web_backend_service = module.helper.bindings_authoritative[each.key].name |
| 34 | + project = var.project |
| 35 | + role = module.helper.bindings_authoritative[each.key].role |
| 36 | + members = module.helper.bindings_authoritative[each.key].members |
| 37 | + dynamic "condition" { |
| 38 | + for_each = module.helper.bindings_authoritative[each.key].condition.title == "" ? [] : [module.helper.bindings_authoritative[each.key].condition] |
| 39 | + content { |
| 40 | + title = module.helper.bindings_authoritative[each.key].condition.title |
| 41 | + description = module.helper.bindings_authoritative[each.key].condition.description |
| 42 | + expression = module.helper.bindings_authoritative[each.key].condition.expression |
| 43 | + } |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | +/****************************************** |
| 48 | + IAP Web Backend IAM binding additive |
| 49 | + *****************************************/ |
| 50 | +resource "google_iap_web_backend_service_iam_member" "iap_web_backend_service_iam_additive" { |
| 51 | + for_each = module.helper.set_additive |
| 52 | + web_backend_service = module.helper.bindings_additive[each.key].name |
| 53 | + project = var.project |
| 54 | + role = module.helper.bindings_additive[each.key].role |
| 55 | + member = module.helper.bindings_additive[each.key].member |
| 56 | + dynamic "condition" { |
| 57 | + for_each = module.helper.bindings_additive[each.key].condition.title == "" ? [] : [module.helper.bindings_additive[each.key].condition] |
| 58 | + content { |
| 59 | + title = module.helper.bindings_additive[each.key].condition.title |
| 60 | + description = module.helper.bindings_additive[each.key].condition.description |
| 61 | + expression = module.helper.bindings_additive[each.key].condition.expression |
| 62 | + } |
| 63 | + } |
| 64 | +} |
0 commit comments