From 98499ca12d43c609da20ce39d7d71f380368d2e6 Mon Sep 17 00:00:00 2001 From: prajin-op Date: Tue, 23 Jul 2024 17:17:38 +0530 Subject: [PATCH 1/6] chore: Update usecase Trial CF Deployement --- released/usecases/trial_cf_deployment/main.tf | 36 ++++++++++--------- .../usecases/trial_cf_deployment/outputs.tf | 2 +- .../usecases/trial_cf_deployment/provider.tf | 4 +-- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/released/usecases/trial_cf_deployment/main.tf b/released/usecases/trial_cf_deployment/main.tf index 6d7d1d59..25969e48 100644 --- a/released/usecases/trial_cf_deployment/main.tf +++ b/released/usecases/trial_cf_deployment/main.tf @@ -19,7 +19,7 @@ resource "random_id" "suffix" { resource "cloudfoundry_route" "helloterraform" { domain = data.cloudfoundry_domain.cfapps.id space = data.cloudfoundry_space.dev.id - hostname = "helloterraform-${random_id.suffix.hex}" + host = "helloterraform-${random_id.suffix.hex}" } data "cloudfoundry_service" "xsuaa" { @@ -27,10 +27,11 @@ data "cloudfoundry_service" "xsuaa" { } resource "cloudfoundry_service_instance" "helloterraform_xsuaa" { - name = "helloterraform-xsuaa" - space = data.cloudfoundry_space.dev.id - service_plan = data.cloudfoundry_service.xsuaa.service_plans["application"] - json_params = jsonencode({ + name = "helloterraform-xsuaa" + space = data.cloudfoundry_space.dev.id + service_plan = data.cloudfoundry_service.xsuaa.service_plans["application"] + type = "managed" + parameters = jsonencode({ xsappname = "helloterraform-${random_id.suffix.hex}" tenant-mode = "shared" scopes = [ @@ -52,19 +53,22 @@ resource "cloudfoundry_service_instance" "helloterraform_xsuaa" { } resource "cloudfoundry_app" "helloterraform" { - space = data.cloudfoundry_space.dev.id - name = "helloterraform" - buildpack = "nodejs_buildpack" - memory = 512 - path = data.archive_file.helloterraform.output_path - - routes { - route = cloudfoundry_route.helloterraform.id + name = "helloterraform" + org_name = module.trialaccount.cloudfoundry.org_name + space_name = data.cloudfoundry_space.dev.name + buildpacks = ["nodejs_buildpack"] + memory = "512M" + path = data.archive_file.helloterraform.output_path + service_bindings = [ + { + service_instance = cloudfoundry_service_instance.helloterraform_xsuaa.name } - - service_binding { - service_instance = cloudfoundry_service_instance.helloterraform_xsuaa.id + ] + routes = [ + { + route = cloudfoundry_route.helloterraform.url } + ] } data "archive_file" "helloterraform" { diff --git a/released/usecases/trial_cf_deployment/outputs.tf b/released/usecases/trial_cf_deployment/outputs.tf index 69c8a601..65fb4a70 100644 --- a/released/usecases/trial_cf_deployment/outputs.tf +++ b/released/usecases/trial_cf_deployment/outputs.tf @@ -1,3 +1,3 @@ output "app_url" { - value = "https://${cloudfoundry_route.helloterraform.endpoint}" + value = "https://${cloudfoundry_route.helloterraform.url}" } diff --git a/released/usecases/trial_cf_deployment/provider.tf b/released/usecases/trial_cf_deployment/provider.tf index aa1c7608..7127bd18 100644 --- a/released/usecases/trial_cf_deployment/provider.tf +++ b/released/usecases/trial_cf_deployment/provider.tf @@ -5,8 +5,8 @@ terraform { version = "~> 1.4.0" } cloudfoundry = { - source = "cloudfoundry-community/cloudfoundry" - version = "0.53.1" + source = "SAP/cloudfoundry" + version = "1.0.0-rc1" } } } From fbceec11845aa9d695d908777ee85b0e8a6f6678 Mon Sep 17 00:00:00 2001 From: prajin-op Date: Tue, 23 Jul 2024 17:21:34 +0530 Subject: [PATCH 2/6] chore: Fixes format error --- released/usecases/trial_cf_deployment/main.tf | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/released/usecases/trial_cf_deployment/main.tf b/released/usecases/trial_cf_deployment/main.tf index 25969e48..113e8fa8 100644 --- a/released/usecases/trial_cf_deployment/main.tf +++ b/released/usecases/trial_cf_deployment/main.tf @@ -17,9 +17,9 @@ resource "random_id" "suffix" { } resource "cloudfoundry_route" "helloterraform" { - domain = data.cloudfoundry_domain.cfapps.id - space = data.cloudfoundry_space.dev.id - host = "helloterraform-${random_id.suffix.hex}" + domain = data.cloudfoundry_domain.cfapps.id + space = data.cloudfoundry_space.dev.id + host = "helloterraform-${random_id.suffix.hex}" } data "cloudfoundry_service" "xsuaa" { @@ -27,11 +27,11 @@ data "cloudfoundry_service" "xsuaa" { } resource "cloudfoundry_service_instance" "helloterraform_xsuaa" { - name = "helloterraform-xsuaa" - space = data.cloudfoundry_space.dev.id - service_plan = data.cloudfoundry_service.xsuaa.service_plans["application"] - type = "managed" - parameters = jsonencode({ + name = "helloterraform-xsuaa" + space = data.cloudfoundry_space.dev.id + service_plan = data.cloudfoundry_service.xsuaa.service_plans["application"] + type = "managed" + parameters = jsonencode({ xsappname = "helloterraform-${random_id.suffix.hex}" tenant-mode = "shared" scopes = [ @@ -53,21 +53,21 @@ resource "cloudfoundry_service_instance" "helloterraform_xsuaa" { } resource "cloudfoundry_app" "helloterraform" { - name = "helloterraform" - org_name = module.trialaccount.cloudfoundry.org_name - space_name = data.cloudfoundry_space.dev.name - buildpacks = ["nodejs_buildpack"] - memory = "512M" - path = data.archive_file.helloterraform.output_path + name = "helloterraform" + org_name = module.trialaccount.cloudfoundry.org_name + space_name = data.cloudfoundry_space.dev.name + buildpacks = ["nodejs_buildpack"] + memory = "512M" + path = data.archive_file.helloterraform.output_path service_bindings = [ { - service_instance = cloudfoundry_service_instance.helloterraform_xsuaa.name - } + service_instance = cloudfoundry_service_instance.helloterraform_xsuaa.name + } ] routes = [ { - route = cloudfoundry_route.helloterraform.url - } + route = cloudfoundry_route.helloterraform.url + } ] } From 8101f3f7c2347c46930051e41073b8acb07a05b7 Mon Sep 17 00:00:00 2001 From: prajin-op Date: Mon, 29 Jul 2024 06:43:12 +0530 Subject: [PATCH 3/6] chore: Update multi account setup --- README.md | 49 ------------------- .../setup_subaccount_cf/provider.tf | 4 +- .../btp-cf/btp-cf-env-instance/btp_env_cf.tf | 4 +- .../btp-cf-org-space/btp_cf_org_space.tf | 2 +- .../modules/btp-cf/space-btp-cf/README.md | 13 +++++ .../modules/btp-cf/space-btp-cf/space_cf.tf | 43 ++++++++++++++++ .../btp-cf/space-btp-cf/space_cf_outputs.tf | 9 ++++ .../btp-cf/space-btp-cf/space_cf_variables.tf | 27 ++++++++++ released/usecases/multi_account_setup/main.tf | 1 + .../subaccount_setup/subaccount_setup.tf | 7 +-- .../subaccount_setup_variables.tf | 24 ++++++--- .../usecases/multi_account_setup/provider.tf | 6 +-- .../usecases/multi_account_setup/variables.tf | 15 +++--- 13 files changed, 131 insertions(+), 73 deletions(-) delete mode 100644 README.md create mode 100644 released/modules/btp-cf/space-btp-cf/README.md create mode 100644 released/modules/btp-cf/space-btp-cf/space_cf.tf create mode 100644 released/modules/btp-cf/space-btp-cf/space_cf_outputs.tf create mode 100644 released/modules/btp-cf/space-btp-cf/space_cf_variables.tf diff --git a/README.md b/README.md deleted file mode 100644 index 750763df..00000000 --- a/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# Samples for the 'Terraform provider for SAP BTP' - -[![REUSE status](https://api.reuse.software/badge/github.com/SAP-samples/btp-terraform-samples)](https://api.reuse.software/info/github.com/SAP-samples/btp-terraform-samples) - -## Description - -This repository provides you with samples on how to use the **Terraform provider for SAP BTP** for various use cases. - -> **Note**: The application of the Terraform configurations we provide in this repository can create cost on your side depending on the sample and the contained resources. Please be aware of that and destroy the resources if no longer needed to avoid unnecessary costs on your side. - -## Get started - -You have three options to get started. You find the details in the [Get started section](./GET_STARTED.md). - -## The Terraform Provider for SAP BTP - -If you want to learn more about the [Terraform provider for SAP BTP](https://registry.terraform.io/providers/SAP/btp/latest) then the official [documentation](https://registry.terraform.io/providers/SAP/btp/latest/docs) in the [Terraform registry](https://registry.terraform.io/) is a perfect place to start. In case you want to dive deeper into the provider, you can also check out the [source code](https://github.com/SAP/terraform-provider-btp) on GitHub. - -## Support, Feedback, Contributing - -❓ - If you have a *question* you can ask it here in [GitHub Discussions](https://github.com/SAP-samples/btp-terraform-samples/discussions/) or in the [SAP Community](https://answers.sap.com/questions/ask.html). - -🐞 - If you find a bug, feel free to create a [bug report](https://github.com/SAP-samples/btp-terraform-samples/issues/new?assignees=&labels=bug&projects=&template=bug_report.yml&title=%5BBUG%5D). - -💡 - If you have an idea for improvement or a feature request, please open a [feature request](https://github.com/SAP-samples/btp-terraform-samples/issues/new?assignees=&labels=enhancement&projects=&template=feature_request.yml&title=%5BFEATURE%5D). - -For more information about how to contribute, the project structure, and additional contribution information, see our [Contribution Guidelines](CONTRIBUTING.md). - -## Code of Conduct - -Members, contributors, and leaders pledge to make participation in our community a harassment-free experience. By participating in this project, you agree to always abide by its [Code of Conduct](https://github.com/SAP/.github/blob/main/CODE_OF_CONDUCT.md). - -## Licensing - -Copyright 2024 SAP SE or an SAP affiliate company and `btp-terraform-samples` contributors. See our [LICENSE](LICENSE) for copyright and license information. Detailed information, including third-party components and their licensing/copyright information, is available [via the REUSE tool](https://api.reuse.software/info/github.com/SAP-samples/btp-terraform-samples). - -## How to obtain support - -[Create an issue](https://github.com/SAP-samples/btp-terraform-samples/issues) in this repository if you find a bug or have questions about the content. - -For additional support, [ask a question in SAP Community](https://answers.sap.com/questions/ask.html). - -## Contributing - -If you wish to contribute code, offer fixes or improvements, please send a pull request. Due to legal reasons, contributors will be asked to accept a DCO when they create the first pull request to this project. This happens in an automated fashion during the submission process. SAP uses [the standard DCO text of the Linux Foundation](https://developercertificate.org/). - -## License - -Copyright (c) 2024 SAP SE or an SAP affiliate company. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSE) file. diff --git a/released/discovery_center/mission_4327/setup_subaccount_cf/provider.tf b/released/discovery_center/mission_4327/setup_subaccount_cf/provider.tf index 086b3f30..7e5d68c6 100644 --- a/released/discovery_center/mission_4327/setup_subaccount_cf/provider.tf +++ b/released/discovery_center/mission_4327/setup_subaccount_cf/provider.tf @@ -2,11 +2,11 @@ terraform { required_providers { btp = { source = "sap/btp" - version = "~> 1.4.0" + version = "~> 1.5.0" } cloudfoundry = { source = "SAP/cloudfoundry" - version = "0.2.1-beta" + version = "1.0.0-rc1" } } } diff --git a/released/modules/btp-cf/btp-cf-env-instance/btp_env_cf.tf b/released/modules/btp-cf/btp-cf-env-instance/btp_env_cf.tf index 56950218..43c5e6d7 100644 --- a/released/modules/btp-cf/btp-cf-env-instance/btp_env_cf.tf +++ b/released/modules/btp-cf/btp-cf-env-instance/btp_env_cf.tf @@ -5,11 +5,11 @@ terraform { required_providers { btp = { source = "sap/btp" - version = "~> 1.4.0" + version = "~> 1.5.0" } cloudfoundry = { source = "SAP/cloudfoundry" - version = "0.2.1-beta" + version = "1.0.0-rc1" } } } diff --git a/released/modules/btp-cf/btp-cf-org-space/btp_cf_org_space.tf b/released/modules/btp-cf/btp-cf-org-space/btp_cf_org_space.tf index 2b8907f1..ba102a93 100644 --- a/released/modules/btp-cf/btp-cf-org-space/btp_cf_org_space.tf +++ b/released/modules/btp-cf/btp-cf-org-space/btp_cf_org_space.tf @@ -5,7 +5,7 @@ terraform { required_providers { btp = { source = "sap/btp" - version = "~> 1.4.0" + version = "~> 1.5.0" } cloudfoundry = { source = "SAP/cloudfoundry" diff --git a/released/modules/btp-cf/space-btp-cf/README.md b/released/modules/btp-cf/space-btp-cf/README.md new file mode 100644 index 00000000..ccc05372 --- /dev/null +++ b/released/modules/btp-cf/space-btp-cf/README.md @@ -0,0 +1,13 @@ +# Module: modules - cloudfoundry - space_cf + +## Content of setup + +This module is executing the following tasks: +- creates a space within a Cloudfoundry environment instance in a subaccount +- assigns users to the newly created Cloudfoundry space + +## Pre-requisites + +The following things need to be available before calling this: +- subaccount needs to exist +- subaccount needs to have a Cloudfoundry environment already setup diff --git a/released/modules/btp-cf/space-btp-cf/space_cf.tf b/released/modules/btp-cf/space-btp-cf/space_cf.tf new file mode 100644 index 00000000..e65bd0c8 --- /dev/null +++ b/released/modules/btp-cf/space-btp-cf/space_cf.tf @@ -0,0 +1,43 @@ +# ------------------------------------------------------------------------------------------------------ +# Define the required providers for this module +# ------------------------------------------------------------------------------------------------------ +terraform { + required_providers { + cloudfoundry = { + source = "SAP/cloudfoundry" + version = "1.0.0-rc1" + } + } +} + +# ------------------------------------------------------------------------------------------------------ +# Create the Cloud Foundry space +# ------------------------------------------------------------------------------------------------------ +resource "cloudfoundry_space" "space" { + name = var.name + org = var.cf_org_id +} + +# ------------------------------------------------------------------------------------------------------ +# Create the CF users +# ------------------------------------------------------------------------------------------------------ +resource "cloudfoundry_space_role" "manager" { + for_each = var.cf_space_managers + username = each.value + type = "space_manager" + space = cloudfoundry_space.space.id +} + +resource "cloudfoundry_space_role" "developer" { + for_each = var.cf_space_developers + username = each.value + type = "space_developer" + space = cloudfoundry_space.space.id +} + +resource "cloudfoundry_space_role" "auditor" { + for_each = var.cf_space_auditors + username = each.value + type = "space_auditor" + space = cloudfoundry_space.space.id +} diff --git a/released/modules/btp-cf/space-btp-cf/space_cf_outputs.tf b/released/modules/btp-cf/space-btp-cf/space_cf_outputs.tf new file mode 100644 index 00000000..933a744d --- /dev/null +++ b/released/modules/btp-cf/space-btp-cf/space_cf_outputs.tf @@ -0,0 +1,9 @@ +output "id" { + value = cloudfoundry_space.space.id + description = "The GUID of the space." +} + +output "name" { + value = cloudfoundry_space.space.name + description = "The name of the space." +} diff --git a/released/modules/btp-cf/space-btp-cf/space_cf_variables.tf b/released/modules/btp-cf/space-btp-cf/space_cf_variables.tf new file mode 100644 index 00000000..7d97b443 --- /dev/null +++ b/released/modules/btp-cf/space-btp-cf/space_cf_variables.tf @@ -0,0 +1,27 @@ +variable "cf_org_id" { + type = string + description = "The ID of the Cloud Foundry org." +} +variable "name" { + type = string + description = "The name of the Cloud Foundry space." + default = "dev" +} + +variable "cf_space_managers" { + type = set(string) + description = "The list of Cloud Foundry space managers." + default = [] +} + +variable "cf_space_developers" { + type = set(string) + description = "The list of Cloud Foundry space developers." + default = [] +} + +variable "cf_space_auditors" { + type = set(string) + description = "The list of Cloud Foundry space auditors." + default = [] +} \ No newline at end of file diff --git a/released/usecases/multi_account_setup/main.tf b/released/usecases/multi_account_setup/main.tf index ed371ab9..c87db319 100644 --- a/released/usecases/multi_account_setup/main.tf +++ b/released/usecases/multi_account_setup/main.tf @@ -42,5 +42,6 @@ module "subaccount_setup" { cf_org_managers = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.org_managers : [] cf_org_billing_managers = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.org_billing_managers : [] cf_org_auditors = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.org_auditors : [] + cf_org_user = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.cf_org_user : [] cf_spaces = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.spaces : [] } diff --git a/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup.tf b/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup.tf index d460a055..5fff73d9 100644 --- a/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup.tf +++ b/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup.tf @@ -5,7 +5,7 @@ terraform { required_providers { btp = { source = "SAP/btp" - version = "~> 1.4.0" + version = "~> 1.5.0" } } } @@ -77,13 +77,14 @@ resource "btp_subaccount_role_collection_assignment" "role_collection_assignment # ------------------------------------------------------------------------------------------------------ module "cloudfoundry_environment" { count = local.cf_env ? 1 : 0 - source = "../../../../modules/environment/cloudfoundry/envinstance_cf" + source = "../../../../modules/btp-cf/btp-cf-env-instance" subaccount_id = btp_subaccount.subaccount.id instance_name = var.cf_env_instance_name cf_org_name = var.cf_org_name cf_org_managers = var.cf_org_managers cf_org_billing_managers = var.cf_org_billing_managers cf_org_auditors = var.cf_org_auditors + cf_org_user = var.cf_org_user } # ------------------------------------------------------------------------------------------------------ @@ -96,7 +97,7 @@ module "cloudfoundry_space" { if local.cf_env } - source = "../../../../modules/environment/cloudfoundry/space_cf" + source = "../../../../modules/btp-cf/space-btp-cf" cf_org_id = module.cloudfoundry_environment[0].cf_org_id name = each.value.space_name cf_space_managers = each.value.space_managers diff --git a/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf b/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf index e0946b5d..dd941760 100644 --- a/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf +++ b/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf @@ -67,29 +67,41 @@ variable "cf_org_name" { } variable "cf_org_managers" { - type = list(string) + type = set(string) description = "List of Cloud Foundry org managers." default = [] } variable "cf_org_billing_managers" { - type = list(string) + type = set(string) description = "List of Cloud Foundry org billing managers." default = [] } variable "cf_org_auditors" { - type = list(string) + type = set(string) description = "List of Cloud Foundry org auditors." default = [] } +variable "cf_org_user" { + type = set(string) + description = "List of Cloud Foundry org users." + default = [] +} + +variable "origin" { + type = string + description = "Origin of the user" + default = "sap.ids" +} + variable "cf_spaces" { type = list(object({ space_name = string - space_managers = list(string) - space_developers = list(string) - space_auditors = list(string) + space_managers = set(string) + space_developers = set(string) + space_auditors = set(string) })) description = "List of Cloud Foundry spaces." default = [] diff --git a/released/usecases/multi_account_setup/provider.tf b/released/usecases/multi_account_setup/provider.tf index a7d2c53d..b4452658 100644 --- a/released/usecases/multi_account_setup/provider.tf +++ b/released/usecases/multi_account_setup/provider.tf @@ -2,11 +2,11 @@ terraform { required_providers { btp = { source = "sap/btp" - version = "~> 1.4.0" + version = "~> 1.5.0" } cloudfoundry = { - source = "cloudfoundry-community/cloudfoundry" - version = "0.53.1" + source = "SAP/cloudfoundry" + version = "1.0.0-rc1" } } } diff --git a/released/usecases/multi_account_setup/variables.tf b/released/usecases/multi_account_setup/variables.tf index bffd204c..547ac82d 100644 --- a/released/usecases/multi_account_setup/variables.tf +++ b/released/usecases/multi_account_setup/variables.tf @@ -28,17 +28,18 @@ variable "subaccounts" { })) role_collection_assignments = list(object({ role_collection_name = string - users = list(string) + users = set(string) })) cf_environment_instance = optional(object({ - org_managers = list(string) - org_billing_managers = list(string) - org_auditors = list(string) + org_managers = set(string) + org_billing_managers = set(string) + org_auditors = set(string) + cf_org_user = set(string) spaces = list(object({ space_name = string - space_managers = list(string) - space_developers = list(string) - space_auditors = list(string) + space_managers = set(string) + space_developers = set(string) + space_auditors = set(string) })) }), null) })) From 2d0123a1a0d7ed09b06dea95fcd77178c706c91f Mon Sep 17 00:00:00 2001 From: prajin-op Date: Mon, 29 Jul 2024 06:54:13 +0530 Subject: [PATCH 4/6] chore: Update variable description --- .../modules/subaccount_setup/subaccount_setup_variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf b/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf index dd941760..1a76b340 100644 --- a/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf +++ b/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf @@ -86,7 +86,7 @@ variable "cf_org_auditors" { variable "cf_org_user" { type = set(string) - description = "List of Cloud Foundry org users." + description = "List of Cloud Foundry org users (Space users who need to be added as CF org users before assigning space-specific roles)." default = [] } From 3f7b2d4614a75da782a36129f53c64d5a68b7c70 Mon Sep 17 00:00:00 2001 From: prajin-op Date: Mon, 29 Jul 2024 07:26:27 +0530 Subject: [PATCH 5/6] chore: Fixes format errors --- released/usecases/multi_account_setup/main.tf | 36 +++++++++---------- .../subaccount_setup_variables.tf | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/released/usecases/multi_account_setup/main.tf b/released/usecases/multi_account_setup/main.tf index c87db319..bdd2bee3 100644 --- a/released/usecases/multi_account_setup/main.tf +++ b/released/usecases/multi_account_setup/main.tf @@ -20,16 +20,16 @@ resource "btp_directory" "directory" { # Call module for creating subaccount # ------------------------------------------------------------------------------------------------------ module "subaccount_setup" { - for_each = tomap(var.subaccounts) - source = "./modules/subaccount_setup" - subaccount_name = "${var.project_name}_${each.key}" - subaccount_subdomain = lower("${var.project_name}${each.key}") - region = var.region - parent_directory_id = local.multiple_subaccounts ? btp_directory.directory[0].id : null - subaccount_labels = each.value.labels - entitlements = each.value.entitlements - subscriptions = each.value.subscriptions - role_collection_assignments = flatten([ + for_each = tomap(var.subaccounts) + source = "./modules/subaccount_setup" + subaccount_name = "${var.project_name}_${each.key}" + subaccount_subdomain = lower("${var.project_name}${each.key}") + region = var.region + parent_directory_id = local.multiple_subaccounts ? btp_directory.directory[0].id : null + subaccount_labels = each.value.labels + entitlements = each.value.entitlements + subscriptions = each.value.subscriptions + role_collection_assignments = flatten([ for index, role_collection_assignment in each.value.role_collection_assignments : [ for index, user in role_collection_assignment.users : { role_collection_name = role_collection_assignment.role_collection_name @@ -37,11 +37,11 @@ module "subaccount_setup" { } ] ]) - cf_env_instance_name = each.value.cf_environment_instance != null ? lower("${var.project_name}${lookup(local.stage2space_map, each.key, "dev")}") : "" - cf_org_name = each.value.cf_environment_instance != null ? lower("${var.project_name}${lookup(local.stage2space_map, each.key, "dev")}") : "" - cf_org_managers = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.org_managers : [] - cf_org_billing_managers = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.org_billing_managers : [] - cf_org_auditors = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.org_auditors : [] - cf_org_user = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.cf_org_user : [] - cf_spaces = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.spaces : [] -} + cf_env_instance_name = each.value.cf_environment_instance != null ? lower("${var.project_name}${lookup(local.stage2space_map, each.key, "dev")}") : "" + cf_org_name = each.value.cf_environment_instance != null ? lower("${var.project_name}${lookup(local.stage2space_map, each.key, "dev")}") : "" + cf_org_managers = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.org_managers : [] + cf_org_billing_managers = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.org_billing_managers : [] + cf_org_auditors = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.org_auditors : [] + cf_org_user = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.cf_org_user : [] + cf_spaces = each.value.cf_environment_instance != null ? each.value.cf_environment_instance.spaces : [] +} \ No newline at end of file diff --git a/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf b/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf index 1a76b340..54405ce3 100644 --- a/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf +++ b/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf @@ -103,6 +103,6 @@ variable "cf_spaces" { space_developers = set(string) space_auditors = set(string) })) - description = "List of Cloud Foundry spaces." + description = "List of Cloud Foundry spaces."   default = [] } \ No newline at end of file From 7c4e7b96f9082e0fca562b8f2a06b27c8693072a Mon Sep 17 00:00:00 2001 From: prajin-op Date: Mon, 29 Jul 2024 07:30:43 +0530 Subject: [PATCH 6/6] chore: Fixes format errors --- .../modules/subaccount_setup/subaccount_setup_variables.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf b/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf index 54405ce3..4eab6be1 100644 --- a/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf +++ b/released/usecases/multi_account_setup/modules/subaccount_setup/subaccount_setup_variables.tf @@ -86,7 +86,7 @@ variable "cf_org_auditors" { variable "cf_org_user" { type = set(string) - description = "List of Cloud Foundry org users (Space users who need to be added as CF org users before assigning space-specific roles)." + description = "List of Cloud Foundry org users to be added as space users." default = [] } @@ -103,6 +103,6 @@ variable "cf_spaces" { space_developers = set(string) space_auditors = set(string) })) - description = "List of Cloud Foundry spaces."   + description = "List of Cloud Foundry spaces." default = [] } \ No newline at end of file