From d95a1e27bad92e61921edd69d1ce4b0ef9e11196 Mon Sep 17 00:00:00 2001 From: prajin-op Date: Wed, 31 Jul 2024 12:40:25 +0530 Subject: [PATCH 1/3] chore: Update mission 4327 --- .../setup_subaccount_cf/README.md | 0 .../setup_subaccount_cf/main.tf | 0 .../setup_subaccount_cf/provider.tf | 0 .../setup_subaccount_cf/samples.tfvars | 0 .../setup_subaccount_cf/testsamples.tfvars | 0 .../setup_subaccount_cf/variables.tf | 0 .../mission_4327/step1/README.md | 78 +++++++++++ .../mission_4327/step1/main.tf | 129 ++++++++++++++++++ .../mission_4327/step1/provider.tf | 15 ++ .../mission_4327/step1/samples.tfvars | 25 ++++ .../mission_4327/step1/variables.tf | 120 ++++++++++++++++ .../mission_4327/step2_cf/README.md | 78 +++++++++++ .../mission_4327/step2_cf/main.tf | 40 ++++++ .../mission_4327/step2_cf/outputs.tf | 19 +++ .../mission_4327/step2_cf/provider.tf | 15 ++ .../mission_4327/step2_cf/samples.tfvars | 14 ++ .../mission_4327/step2_cf/variables.tf | 59 ++++++++ .../README.md | 0 .../main.tf | 0 .../provider.tf | 0 .../samples.tfvars | 0 .../variables.tf | 0 22 files changed, 592 insertions(+) rename released/{discovery_center/mission_4327 => cicd}/setup_subaccount_cf/README.md (100%) rename released/{discovery_center/mission_4327 => cicd}/setup_subaccount_cf/main.tf (100%) rename released/{discovery_center/mission_4327 => cicd}/setup_subaccount_cf/provider.tf (100%) rename released/{discovery_center/mission_4327 => cicd}/setup_subaccount_cf/samples.tfvars (100%) rename released/{discovery_center/mission_4327 => cicd}/setup_subaccount_cf/testsamples.tfvars (100%) rename released/{discovery_center/mission_4327 => cicd}/setup_subaccount_cf/variables.tf (100%) create mode 100644 released/discovery_center/mission_4327/step1/README.md create mode 100644 released/discovery_center/mission_4327/step1/main.tf create mode 100644 released/discovery_center/mission_4327/step1/provider.tf create mode 100644 released/discovery_center/mission_4327/step1/samples.tfvars create mode 100644 released/discovery_center/mission_4327/step1/variables.tf create mode 100644 released/discovery_center/mission_4327/step2_cf/README.md create mode 100644 released/discovery_center/mission_4327/step2_cf/main.tf create mode 100644 released/discovery_center/mission_4327/step2_cf/outputs.tf create mode 100644 released/discovery_center/mission_4327/step2_cf/provider.tf create mode 100644 released/discovery_center/mission_4327/step2_cf/samples.tfvars create mode 100644 released/discovery_center/mission_4327/step2_cf/variables.tf rename released/discovery_center/mission_4327/{setup_subaccount_kyma => step2_kyma}/README.md (100%) rename released/discovery_center/mission_4327/{setup_subaccount_kyma => step2_kyma}/main.tf (100%) rename released/discovery_center/mission_4327/{setup_subaccount_kyma => step2_kyma}/provider.tf (100%) rename released/discovery_center/mission_4327/{setup_subaccount_kyma => step2_kyma}/samples.tfvars (100%) rename released/discovery_center/mission_4327/{setup_subaccount_kyma => step2_kyma}/variables.tf (100%) diff --git a/released/discovery_center/mission_4327/setup_subaccount_cf/README.md b/released/cicd/setup_subaccount_cf/README.md similarity index 100% rename from released/discovery_center/mission_4327/setup_subaccount_cf/README.md rename to released/cicd/setup_subaccount_cf/README.md diff --git a/released/discovery_center/mission_4327/setup_subaccount_cf/main.tf b/released/cicd/setup_subaccount_cf/main.tf similarity index 100% rename from released/discovery_center/mission_4327/setup_subaccount_cf/main.tf rename to released/cicd/setup_subaccount_cf/main.tf diff --git a/released/discovery_center/mission_4327/setup_subaccount_cf/provider.tf b/released/cicd/setup_subaccount_cf/provider.tf similarity index 100% rename from released/discovery_center/mission_4327/setup_subaccount_cf/provider.tf rename to released/cicd/setup_subaccount_cf/provider.tf diff --git a/released/discovery_center/mission_4327/setup_subaccount_cf/samples.tfvars b/released/cicd/setup_subaccount_cf/samples.tfvars similarity index 100% rename from released/discovery_center/mission_4327/setup_subaccount_cf/samples.tfvars rename to released/cicd/setup_subaccount_cf/samples.tfvars diff --git a/released/discovery_center/mission_4327/setup_subaccount_cf/testsamples.tfvars b/released/cicd/setup_subaccount_cf/testsamples.tfvars similarity index 100% rename from released/discovery_center/mission_4327/setup_subaccount_cf/testsamples.tfvars rename to released/cicd/setup_subaccount_cf/testsamples.tfvars diff --git a/released/discovery_center/mission_4327/setup_subaccount_cf/variables.tf b/released/cicd/setup_subaccount_cf/variables.tf similarity index 100% rename from released/discovery_center/mission_4327/setup_subaccount_cf/variables.tf rename to released/cicd/setup_subaccount_cf/variables.tf diff --git a/released/discovery_center/mission_4327/step1/README.md b/released/discovery_center/mission_4327/step1/README.md new file mode 100644 index 00000000..d7afd868 --- /dev/null +++ b/released/discovery_center/mission_4327/step1/README.md @@ -0,0 +1,78 @@ +# Set Up SAP BTP Account using Terraform – Cloud Foundry + +The Terraform provider for SAP Business Technology Platform (BTP) enables you to automate the provisioning, management, and configuration of resources on SAP BTP. By leveraging this provider, you can simplify and streamline the deployment and maintenance of SAP BTP services and applications. + +Currently, the SAP BTP provider is available in beta for non productive usage: [SAP BTP Terraform](https://registry.terraform.io/providers/SAP/btp/latest). + +The Terraform script documented here automates the setup of an SAP BTP subaccount based on a predefined template. The scripts can be used create SAP BTP subaccount with Cloud Foundry or Kyma runtime. The Terraform script does the below configuration after creating a SAP BTP subaccount: + +1. Configures the SAP BTP entitlements required to complete the mission. See [Setup SAP BTP Account using Terraform](https://github.com/SAP-samples/btp-terraform-samples/blob/main/released/discovery_center/mission_4327/setup_subaccount_cf/README.md#entitlements). +2. Enables the SAP BTP runtime (Cloud Foundry or Kyma). +3. Creates the neccessary subscription to applications: SAP Business Application Studio (BAS), SAP Build Work Zone, standard edition, etc. +4. Assigns users the neccessary roles required to access the applications, such as SAP Business Application Studio. +5. Adds additional users to the subaccount. +### [Entitlements ](https://github.tools.sap/refapps/incidents-mgmt/blob/main/documentation/administrate/Prepare-BTP/Configure-BTP-CF.md) + +| Service | Plan | Quota required | +| ------------- | :-----------: | ----: | +| Cloud Foundry Runtime | MEMORY | 1 | +| SAP Build Work Zone, standard edition | Standard | 1 | +| SAP HANA Cloud | hana | 1 | +| SAP HANA Cloud | tools | 1 | +| SAP HANA Schemas & HDI Containers | hdi-shared | 1 | + +## Deploy the resources + +To deploy the resources you must: +1. Clone repository `git clone https://github.com/SAP-samples/btp-terraform-samples.git` +2. Navigate to `released/discovery_center/mission_4327/setup_subaccount_cf` +3. You will be seeing these files named `main.tf`,`provider.tf`,`samples.tfvars`,`variables.tf`. +4. Create a file named `terraform.tfvars` and copy `samples.tfvars` content to `terraform.tfvars`. Update the variables to meet your requirements (By default free-tier plans are used, if you want to use it for production update in the `terraform.tfvars` accordingly) +Follow these steps to use the script: +5. Set `BTP_USERNAME`,`BTP_PASSWORD`,`CF_USER` and `CF_PASSWORD` as ENV variables. + +Windows PowerShell: +```Powershell + $env:BTP_USERNAME="" + $env:BTP_PASSWORD="" + $env:CF_USER="" + $env:CF_PASSWORD="" +``` +Linux, macOS: +```mac OS + export BTP_USERNAME="" + export BTP_PASSWORD="" + export CF_USER="" + export CF_PASSWORD="" +``` +6. **Install Terraform Plugins**: Open a terminal and navigate to the directory containing your Terraform configuration files. Run the following command to initialize and upgrade Terraform plugins: + + ```shell + terraform init + ``` + +7. **Review Changes**: Generate an execution plan to review the changes that will be made to your SAP BTP account. Run: + + ```shell + terraform plan + ``` + +8. **Apply Configuration**: Apply the Terraform configuration to create the SAP BTP subaccount and entitlements. Run: + + ```shell + terraform apply + ``` + + Confirm the changes by typing "yes." + +9. **Cleanup**: After your session or project is complete, you can delete the SAP BTP subaccount and associated resources to avoid charges: + + ```shell + terraform destroy + ``` + + Confirm the resource destruction by typing "yes." + +11. **Optional**: You can remove the Terraform state file (`terraform.tfstate`) manually if needed. + +Please exercise caution when using this script, especially in production environments, and ensure you understand the resources that will be created or modified. diff --git a/released/discovery_center/mission_4327/step1/main.tf b/released/discovery_center/mission_4327/step1/main.tf new file mode 100644 index 00000000..bda45b69 --- /dev/null +++ b/released/discovery_center/mission_4327/step1/main.tf @@ -0,0 +1,129 @@ +############################################################################################### +# Generating random ID for subdomain +############################################################################################### +resource "random_uuid" "uuid" {} +############################################################################################### +# Creation of subaccount +############################################################################################### +resource "btp_subaccount" "project" { + name = var.subaccount_name + subdomain = "btp-gp${random_uuid.uuid.result}" + region = lower(var.region) +} +data "btp_whoami" "me" {} + +data "btp_subaccount_environments" "all" { + subaccount_id = btp_subaccount.project.id +} +# ------------------------------------------------------------------------------------------------------ +# Take the landscape label from the first CF environment if no environment label is provided +# (this replaces the previous null_resource) +# ------------------------------------------------------------------------------------------------------ +resource "terraform_data" "cf_landscape_label" { + input = length(var.cf_landscape_label) > 0 ? var.cf_landscape_label : [for env in data.btp_subaccount_environments.all.values : env if env.service_name == "cloudfoundry" && env.environment_type == "cloudfoundry"][0].landscape_label +} +############################################################################################### +# Creation of Cloud Foundry environment +############################################################################################### +resource "btp_subaccount_environment_instance" "cloudfoundry" { + subaccount_id = btp_subaccount.project.id + name = btp_subaccount.project.subdomain + landscape_label = terraform_data.cf_landscape_label.output + environment_type = "cloudfoundry" + service_name = "cloudfoundry" + plan_name = "standard" + # ATTENTION: some regions offer multiple environments of a kind and you must explicitly select the target environment in which + # the instance shall be created using the parameter landscape label. + # available environments can be looked up using the btp_subaccount_environments datasource + parameters = jsonencode({ + instance_name = btp_subaccount.project.subdomain + }) + timeouts = { + create = "1h" + update = "35m" + delete = "30m" + } +} + +############################################################################################### +# Assignment of users as sub account administrators +############################################################################################### +resource "btp_subaccount_role_collection_assignment" "subaccount-admins" { + for_each = toset("${var.subaccount_admins}") + subaccount_id = btp_subaccount.project.id + role_collection_name = "Subaccount Administrator" + user_name = each.value +} +###################################################################### +# Add entitlement for BAS, Subscribe BAS and add roles +###################################################################### +resource "btp_subaccount_entitlement" "bas" { + subaccount_id = btp_subaccount.project.id + service_name = "sapappstudio" + plan_name = var.bas_plan_name +} +resource "btp_subaccount_subscription" "bas-subscribe" { + subaccount_id = btp_subaccount.project.id + app_name = "sapappstudio" + plan_name = var.bas_plan_name + depends_on = [btp_subaccount_entitlement.bas] +} +resource "btp_subaccount_role_collection_assignment" "Business_Application_Studio_Administrator" { + subaccount_id = btp_subaccount.project.id + role_collection_name = "Business_Application_Studio_Administrator" + user_name = data.btp_whoami.me.email + depends_on = [btp_subaccount_subscription.bas-subscribe] +} + + +resource "btp_subaccount_role_collection_assignment" "Business_Application_Studio_Developer" { + subaccount_id = btp_subaccount.project.id + role_collection_name = "Business_Application_Studio_Developer" + user_name = data.btp_whoami.me.email + depends_on = [btp_subaccount_subscription.bas-subscribe] +} +###################################################################### +# Add Build Workzone entitlement subscription and role Assignment +###################################################################### +resource "btp_subaccount_entitlement" "build_workzone" { + subaccount_id = btp_subaccount.project.id + service_name = "SAPLaunchpad" + plan_name = var.build_workzone_plan_name +} +resource "btp_subaccount_subscription" "build_workzone_subscribe" { + subaccount_id = btp_subaccount.project.id + app_name = "SAPLaunchpad" + plan_name = var.build_workzone_plan_name + depends_on = [btp_subaccount_entitlement.build_workzone] +} +resource "btp_subaccount_role_collection_assignment" "launchpad_admin" { + subaccount_id = btp_subaccount.project.id + role_collection_name = "Launchpad_Admin" + user_name = data.btp_whoami.me.email + depends_on = [btp_subaccount_subscription.build_workzone_subscribe] +} +###################################################################### +# Create HANA entitlement subscription +###################################################################### +resource "btp_subaccount_entitlement" "hana-cloud" { + subaccount_id = btp_subaccount.project.id + service_name = "hana-cloud" + plan_name = var.hana-cloud_plan_name +} +# Enable HANA Cloud Tools +resource "btp_subaccount_entitlement" "hana-cloud-tools" { + subaccount_id = btp_subaccount.project.id + service_name = "hana-cloud-tools" + plan_name = "tools" +} +resource "btp_subaccount_subscription" "hana-cloud-tools" { + subaccount_id = btp_subaccount.project.id + app_name = "hana-cloud-tools" + plan_name = "tools" + depends_on = [btp_subaccount_entitlement.hana-cloud-tools] +} +resource "btp_subaccount_entitlement" "hana-hdi-shared" { + subaccount_id = btp_subaccount.project.id + service_name = "hana" + plan_name = "hdi-shared" +} diff --git a/released/discovery_center/mission_4327/step1/provider.tf b/released/discovery_center/mission_4327/step1/provider.tf new file mode 100644 index 00000000..8408e02e --- /dev/null +++ b/released/discovery_center/mission_4327/step1/provider.tf @@ -0,0 +1,15 @@ +terraform { + required_providers { + btp = { + source = "sap/btp" + version = "1.5.0" + } + } +} + +# Please checkout documentation on how best to authenticate against SAP BTP +# via the Terraform provider for SAP BTP +provider "btp" { + globalaccount = var.globalaccount + cli_server_url = var.cli_server_url +} \ No newline at end of file diff --git a/released/discovery_center/mission_4327/step1/samples.tfvars b/released/discovery_center/mission_4327/step1/samples.tfvars new file mode 100644 index 00000000..a825c905 --- /dev/null +++ b/released/discovery_center/mission_4327/step1/samples.tfvars @@ -0,0 +1,25 @@ +# ------------------------------------------------------------------------------------------------------ +# Provider configuration +# ------------------------------------------------------------------------------------------------------ +# Your global account subdomain +globalaccount = "terraformintprod" +region = "eu10" +subaccount_name = "dcmqas" +cf_landscape_label = "cf-eu10" +# ------------------------------------------------------------------------------------------------------ +# Project specific configuration (please adapt!) +# ------------------------------------------------------------------------------------------------------ +# To add extra users to the subaccount, the user running the script becomes the admin, without inclusion in admins. +subaccount_admins = ["joe.do@sap.com", "jane.do@sap.com"] +# To Create Cloudfoundry Org and add users with specific roles +#------------------------------------------------------------------------------------------------------ +# Entitlements plan update +#------------------------------------------------------------------------------------------------------ +# For production use of Business Application Studio, upgrade the plan from the `free-tier` to the appropriate plan e.g standard-edition +bas_plan_name = "standard-edition" +#------------------------------------------------------------------------------------------------------- +#For production use of Build Workzone, upgrade the plan from the `free-tier` to the appropriate plan e.g standard +build_workzone_plan_name = "standard" +#-------------------------------------------------------------------------------------------------------- +# For production use of HANA, upgrade the plan from the `free-tier` to the appropriate plan e.g hana +hana-cloud_plan_name = "hana" diff --git a/released/discovery_center/mission_4327/step1/variables.tf b/released/discovery_center/mission_4327/step1/variables.tf new file mode 100644 index 00000000..6211db02 --- /dev/null +++ b/released/discovery_center/mission_4327/step1/variables.tf @@ -0,0 +1,120 @@ +###################################################################### +# Customer account setup +###################################################################### +# subaccount +variable "globalaccount" { + type = string + description = "The globalaccount subdomain." +} +# subaccount +variable "subaccount_name" { + type = string + description = "The subaccount name." +} +# Region +variable "region" { + type = string + description = "The region where the project account shall be created in." + default = "us10" +} + +# CLI server +variable "cli_server_url" { + type = string + description = "The BTP CLI server URL." + default = "https://cpcli.cf.eu10.hana.ondemand.com" +} + +variable "subaccount_admins" { + type = list(string) + description = "Defines the colleagues who are added to each subaccount as subaccount administrators." + default = ["jane.doe@test.com", "john.doe@test.com"] +} + +#cf_landscape_label +variable "cf_landscape_label" { + type = string + description = "The region where the project account shall be created in." + default = "us10" +} +### +# Entitlements +### +variable "entitlements" { + type = list(object({ + service_name = string + plan_name = string + type = string + })) + description = "The list of entitlements that shall be added to the subaccount." + default = [ + { + service_name = "connectivity" + plan_name = "lite", + type = "service" + }, + { + service_name = "destination" + plan_name = "lite", + type = "service" + }, + { + service_name = "html5-apps-repo" + plan_name = "app-host", + type = "service" + }, + { + service_name = "sapappstudio" + plan_name = "standard-edition", + type = "app" + }, + { + service_name = "enterprise-messaging" + plan_name = "default", + type = "service" + }, + { + service_name = "enterprise-messaging-hub" + plan_name = "standard", + type = "app" + }, + { + service_name = "privatelink" + plan_name = "standard", + type = "service" + }, + { + service_name = "xsuaa" + plan_name = "application", + type = "service" + }, + { + service_name = "hana" + plan_name = "hdi-shared", + type = "service" + }, + { + service_name = "hana-cloud" + plan_name = "hana", + type = "service" + } + ] +} +# Plan_name update +variable "bas_plan_name" { + description = "BAS plan" + type = string + default = "free-tier" +} + +variable "build_workzone_plan_name" { + description = "Build Workzone plan" + type = string + default = "free-tier" +} + +variable "hana-cloud_plan_name" { + description = "hana-cloud plan" + type = string + default = "free" +} \ No newline at end of file diff --git a/released/discovery_center/mission_4327/step2_cf/README.md b/released/discovery_center/mission_4327/step2_cf/README.md new file mode 100644 index 00000000..d7afd868 --- /dev/null +++ b/released/discovery_center/mission_4327/step2_cf/README.md @@ -0,0 +1,78 @@ +# Set Up SAP BTP Account using Terraform – Cloud Foundry + +The Terraform provider for SAP Business Technology Platform (BTP) enables you to automate the provisioning, management, and configuration of resources on SAP BTP. By leveraging this provider, you can simplify and streamline the deployment and maintenance of SAP BTP services and applications. + +Currently, the SAP BTP provider is available in beta for non productive usage: [SAP BTP Terraform](https://registry.terraform.io/providers/SAP/btp/latest). + +The Terraform script documented here automates the setup of an SAP BTP subaccount based on a predefined template. The scripts can be used create SAP BTP subaccount with Cloud Foundry or Kyma runtime. The Terraform script does the below configuration after creating a SAP BTP subaccount: + +1. Configures the SAP BTP entitlements required to complete the mission. See [Setup SAP BTP Account using Terraform](https://github.com/SAP-samples/btp-terraform-samples/blob/main/released/discovery_center/mission_4327/setup_subaccount_cf/README.md#entitlements). +2. Enables the SAP BTP runtime (Cloud Foundry or Kyma). +3. Creates the neccessary subscription to applications: SAP Business Application Studio (BAS), SAP Build Work Zone, standard edition, etc. +4. Assigns users the neccessary roles required to access the applications, such as SAP Business Application Studio. +5. Adds additional users to the subaccount. +### [Entitlements ](https://github.tools.sap/refapps/incidents-mgmt/blob/main/documentation/administrate/Prepare-BTP/Configure-BTP-CF.md) + +| Service | Plan | Quota required | +| ------------- | :-----------: | ----: | +| Cloud Foundry Runtime | MEMORY | 1 | +| SAP Build Work Zone, standard edition | Standard | 1 | +| SAP HANA Cloud | hana | 1 | +| SAP HANA Cloud | tools | 1 | +| SAP HANA Schemas & HDI Containers | hdi-shared | 1 | + +## Deploy the resources + +To deploy the resources you must: +1. Clone repository `git clone https://github.com/SAP-samples/btp-terraform-samples.git` +2. Navigate to `released/discovery_center/mission_4327/setup_subaccount_cf` +3. You will be seeing these files named `main.tf`,`provider.tf`,`samples.tfvars`,`variables.tf`. +4. Create a file named `terraform.tfvars` and copy `samples.tfvars` content to `terraform.tfvars`. Update the variables to meet your requirements (By default free-tier plans are used, if you want to use it for production update in the `terraform.tfvars` accordingly) +Follow these steps to use the script: +5. Set `BTP_USERNAME`,`BTP_PASSWORD`,`CF_USER` and `CF_PASSWORD` as ENV variables. + +Windows PowerShell: +```Powershell + $env:BTP_USERNAME="" + $env:BTP_PASSWORD="" + $env:CF_USER="" + $env:CF_PASSWORD="" +``` +Linux, macOS: +```mac OS + export BTP_USERNAME="" + export BTP_PASSWORD="" + export CF_USER="" + export CF_PASSWORD="" +``` +6. **Install Terraform Plugins**: Open a terminal and navigate to the directory containing your Terraform configuration files. Run the following command to initialize and upgrade Terraform plugins: + + ```shell + terraform init + ``` + +7. **Review Changes**: Generate an execution plan to review the changes that will be made to your SAP BTP account. Run: + + ```shell + terraform plan + ``` + +8. **Apply Configuration**: Apply the Terraform configuration to create the SAP BTP subaccount and entitlements. Run: + + ```shell + terraform apply + ``` + + Confirm the changes by typing "yes." + +9. **Cleanup**: After your session or project is complete, you can delete the SAP BTP subaccount and associated resources to avoid charges: + + ```shell + terraform destroy + ``` + + Confirm the resource destruction by typing "yes." + +11. **Optional**: You can remove the Terraform state file (`terraform.tfstate`) manually if needed. + +Please exercise caution when using this script, especially in production environments, and ensure you understand the resources that will be created or modified. diff --git a/released/discovery_center/mission_4327/step2_cf/main.tf b/released/discovery_center/mission_4327/step2_cf/main.tf new file mode 100644 index 00000000..b4812ee4 --- /dev/null +++ b/released/discovery_center/mission_4327/step2_cf/main.tf @@ -0,0 +1,40 @@ +###################################################################### +# Create space using CF provider +###################################################################### +resource "cloudfoundry_space" "dev" { + name = "DEV" + org = var.cf_org_id +} + +###################################################################### +# add org and space users and managers +###################################################################### +resource "cloudfoundry_org_role" "organization_user" { + for_each = toset(var.cf_org_users) + username = each.value + type = "organization_user" + org = var.cf_org_id +} + +resource "cloudfoundry_org_role" "organization_manager" { + for_each = toset(var.cf_org_admins) + username = each.value + type = "organization_manager" + org = var.cf_org_id +} + +resource "cloudfoundry_space_role" "space_developer" { + for_each = toset(var.cf_space_developers) + username = each.value + type = "space_developer" + space = cloudfoundry_space.dev.id + depends_on = [cloudfoundry_org_role.organization_user, cloudfoundry_org_role.organization_manager] +} + +resource "cloudfoundry_space_role" "space_manager" { + for_each = toset(var.cf_space_managers) + username = each.value + type = "space_manager" + space = cloudfoundry_space.dev.id + depends_on = [cloudfoundry_org_role.organization_user, cloudfoundry_org_role.organization_manager] +} \ No newline at end of file diff --git a/released/discovery_center/mission_4327/step2_cf/outputs.tf b/released/discovery_center/mission_4327/step2_cf/outputs.tf new file mode 100644 index 00000000..ad4178cd --- /dev/null +++ b/released/discovery_center/mission_4327/step2_cf/outputs.tf @@ -0,0 +1,19 @@ +output "subaccount_id" { + value = var.subaccount_id +} + +output "cf_landscape_label" { + value = var.cf_landscape_label +} + +output "cf_org_id" { + value = var.cf_org_id +} + +output "cf_api_url" { + value = var.cf_api_url +} + +output "cf_space_name" { + value = cloudfoundry_space.dev.name +} \ No newline at end of file diff --git a/released/discovery_center/mission_4327/step2_cf/provider.tf b/released/discovery_center/mission_4327/step2_cf/provider.tf new file mode 100644 index 00000000..1802fe7a --- /dev/null +++ b/released/discovery_center/mission_4327/step2_cf/provider.tf @@ -0,0 +1,15 @@ +terraform { + required_providers { + cloudfoundry = { + source = "SAP/cloudfoundry" + version = "1.0.0-rc1" + } + } +} +###################################################################### +# Configure CF provider +###################################################################### +provider "cloudfoundry" { + # resolve API URL from environment instance + api_url = var.cf_api_url +} \ No newline at end of file diff --git a/released/discovery_center/mission_4327/step2_cf/samples.tfvars b/released/discovery_center/mission_4327/step2_cf/samples.tfvars new file mode 100644 index 00000000..76682cfe --- /dev/null +++ b/released/discovery_center/mission_4327/step2_cf/samples.tfvars @@ -0,0 +1,14 @@ +# ------------------------------------------------------------------------------------------------------ +# Provider configuration +globalaccount = "terraformintprod" +region = "eu10" +subaccount_name = "dcmqas" +cf_landscape_label = "cf-eu10" +cf_org_id = "c7d8295b-cebb-417e-b549-d58a2fca7f15" +subaccount_id = "0edd191c-f1f4-4d77-a267-82d08756dd6d" +cf_org_name = "btp-gp7d6d44d9-2948-3634-8dee-9ade97d9ade3" +cf_api_url = "https://api.cf.eu10.hana.ondemand.com" +cf_space_developers = ["DL_65DDA8EBA97EAA0134EEB5DC@global.corp.sap","DL_604F126B654D33027ECBD9B4@global.corp.sap"] +cf_space_managers = ["DL_65DDA8EBA97EAA0134EEB5DC@global.corp.sap","DL_604F126B654D33027ECBD9B4@global.corp.sap"] +cf_org_admins = ["DL_604F126B654D33027ECBD9B4@global.corp.sap"] +cf_org_users = ["DL_604F126B654D33027ECBD9B4@global.corp.sap"] \ No newline at end of file diff --git a/released/discovery_center/mission_4327/step2_cf/variables.tf b/released/discovery_center/mission_4327/step2_cf/variables.tf new file mode 100644 index 00000000..0b435101 --- /dev/null +++ b/released/discovery_center/mission_4327/step2_cf/variables.tf @@ -0,0 +1,59 @@ +variable "cf_api_url" { + type = string +} + +variable "cf_landscape_label" { + type = string +} + +variable "cf_org_id" { + type = string +} + +variable "subaccount_id" { + type = string +} + +variable "cf_space_developers" { + type = list(string) + description = "CF Space developers" + default = ["jane.doe@test.com", "john.doe@test.com"] + # add validation to check if CF Space developers contains a list of valid email addresses + validation { + condition = length([for email in var.cf_space_developers : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_space_developers) + error_message = "Please enter a valid email address for the CF Space developers." + } +} + +variable "cf_space_managers" { + type = list(string) + description = "CF Space managers" + default = ["jane.doe@test.com", "john.doe@test.com"] + # add validation to check if CF Space managers contains a list of valid email addresses + validation { + condition = length([for email in var.cf_space_managers : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_space_managers) + error_message = "Please enter a valid email address for the Cloud Connector Administrators." + } +} + +variable "cf_org_admins" { + type = list(string) + description = "CF Org Admins" + default = ["jane.doe@test.com", "john.doe@test.com"] + # add validation to check if CF Org Admins contains a list of valid email addresses + validation { + condition = length([for email in var.cf_org_admins : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_org_admins) + error_message = "Please enter a valid email address for the CF Org Admins." + } +} + +variable "cf_org_users" { + type = list(string) + description = "CF Org Users" + default = ["jane.doe@test.com", "john.doe@test.com"] + # add validation to check if CF Org Users contains a list of valid email addresses + validation { + condition = length([for email in var.cf_org_users : can(regex("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$", email))]) == length(var.cf_org_users) + error_message = "Please enter a valid email address for the CF Org Users." + } +} diff --git a/released/discovery_center/mission_4327/setup_subaccount_kyma/README.md b/released/discovery_center/mission_4327/step2_kyma/README.md similarity index 100% rename from released/discovery_center/mission_4327/setup_subaccount_kyma/README.md rename to released/discovery_center/mission_4327/step2_kyma/README.md diff --git a/released/discovery_center/mission_4327/setup_subaccount_kyma/main.tf b/released/discovery_center/mission_4327/step2_kyma/main.tf similarity index 100% rename from released/discovery_center/mission_4327/setup_subaccount_kyma/main.tf rename to released/discovery_center/mission_4327/step2_kyma/main.tf diff --git a/released/discovery_center/mission_4327/setup_subaccount_kyma/provider.tf b/released/discovery_center/mission_4327/step2_kyma/provider.tf similarity index 100% rename from released/discovery_center/mission_4327/setup_subaccount_kyma/provider.tf rename to released/discovery_center/mission_4327/step2_kyma/provider.tf diff --git a/released/discovery_center/mission_4327/setup_subaccount_kyma/samples.tfvars b/released/discovery_center/mission_4327/step2_kyma/samples.tfvars similarity index 100% rename from released/discovery_center/mission_4327/setup_subaccount_kyma/samples.tfvars rename to released/discovery_center/mission_4327/step2_kyma/samples.tfvars diff --git a/released/discovery_center/mission_4327/setup_subaccount_kyma/variables.tf b/released/discovery_center/mission_4327/step2_kyma/variables.tf similarity index 100% rename from released/discovery_center/mission_4327/setup_subaccount_kyma/variables.tf rename to released/discovery_center/mission_4327/step2_kyma/variables.tf From 8c4f70f0dd1ae1edc5aa779620658c56fdfc0c4b Mon Sep 17 00:00:00 2001 From: prajin-op Date: Wed, 31 Jul 2024 14:00:07 +0530 Subject: [PATCH 2/3] chore: Update mission 4327 --- .../mission_4327/step1/samples.tfvars | 8 +++---- .../mission_4327/step2_cf/samples.tfvars | 24 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/released/discovery_center/mission_4327/step1/samples.tfvars b/released/discovery_center/mission_4327/step1/samples.tfvars index a825c905..bd727f7d 100644 --- a/released/discovery_center/mission_4327/step1/samples.tfvars +++ b/released/discovery_center/mission_4327/step1/samples.tfvars @@ -2,10 +2,10 @@ # Provider configuration # ------------------------------------------------------------------------------------------------------ # Your global account subdomain -globalaccount = "terraformintprod" -region = "eu10" -subaccount_name = "dcmqas" -cf_landscape_label = "cf-eu10" +globalaccount = "myglobalaccount" +region = "us10" +subaccount_name = "DCM Goldenpath" +cf_org_name = "cf-environment" # ------------------------------------------------------------------------------------------------------ # Project specific configuration (please adapt!) # ------------------------------------------------------------------------------------------------------ diff --git a/released/discovery_center/mission_4327/step2_cf/samples.tfvars b/released/discovery_center/mission_4327/step2_cf/samples.tfvars index 76682cfe..f88d2c51 100644 --- a/released/discovery_center/mission_4327/step2_cf/samples.tfvars +++ b/released/discovery_center/mission_4327/step2_cf/samples.tfvars @@ -1,14 +1,14 @@ # ------------------------------------------------------------------------------------------------------ # Provider configuration -globalaccount = "terraformintprod" -region = "eu10" -subaccount_name = "dcmqas" -cf_landscape_label = "cf-eu10" -cf_org_id = "c7d8295b-cebb-417e-b549-d58a2fca7f15" -subaccount_id = "0edd191c-f1f4-4d77-a267-82d08756dd6d" -cf_org_name = "btp-gp7d6d44d9-2948-3634-8dee-9ade97d9ade3" -cf_api_url = "https://api.cf.eu10.hana.ondemand.com" -cf_space_developers = ["DL_65DDA8EBA97EAA0134EEB5DC@global.corp.sap","DL_604F126B654D33027ECBD9B4@global.corp.sap"] -cf_space_managers = ["DL_65DDA8EBA97EAA0134EEB5DC@global.corp.sap","DL_604F126B654D33027ECBD9B4@global.corp.sap"] -cf_org_admins = ["DL_604F126B654D33027ECBD9B4@global.corp.sap"] -cf_org_users = ["DL_604F126B654D33027ECBD9B4@global.corp.sap"] \ No newline at end of file +# ------------------------------------------------------------------------------------------------------ +# Your global account subdomain +globalaccount = "myglobalaccount" +region = "us10" +subaccount_name = "DCM Goldenpath" +cf_org_name = "cf-environment" +subaccount_admins = ["john.doe@sap.com"] +subaccount_service_admins = ["john.doe@sap.com"] +cf_space_developers = ["john.doe@sap.com"] +cf_space_managers = ["john.doe@sap.com"] +cf_org_admins = ["john.doe@sap.com"] +cf_org_users = ["john.doe@sap.com"] \ No newline at end of file From bb82c1f1a1bf4312eb91b6a9409cb3fb3547a18c Mon Sep 17 00:00:00 2001 From: prajin-op Date: Wed, 31 Jul 2024 18:50:09 +0530 Subject: [PATCH 3/3] chore: fixes format error --- .../mission_4327/step2_cf/samples.tfvars | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/released/discovery_center/mission_4327/step2_cf/samples.tfvars b/released/discovery_center/mission_4327/step2_cf/samples.tfvars index f88d2c51..54f30b0b 100644 --- a/released/discovery_center/mission_4327/step2_cf/samples.tfvars +++ b/released/discovery_center/mission_4327/step2_cf/samples.tfvars @@ -2,13 +2,13 @@ # Provider configuration # ------------------------------------------------------------------------------------------------------ # Your global account subdomain -globalaccount = "myglobalaccount" -region = "us10" -subaccount_name = "DCM Goldenpath" -cf_org_name = "cf-environment" -subaccount_admins = ["john.doe@sap.com"] -subaccount_service_admins = ["john.doe@sap.com"] -cf_space_developers = ["john.doe@sap.com"] -cf_space_managers = ["john.doe@sap.com"] -cf_org_admins = ["john.doe@sap.com"] -cf_org_users = ["john.doe@sap.com"] \ No newline at end of file +globalaccount = "myglobalaccount" +region = "us10" +subaccount_name = "DCM Goldenpath" +cf_org_name = "cf-environment" +subaccount_admins = ["john.doe@sap.com"] +subaccount_service_admins = ["john.doe@sap.com"] +cf_space_developers = ["john.doe@sap.com"] +cf_space_managers = ["john.doe@sap.com"] +cf_org_admins = ["john.doe@sap.com"] +cf_org_users = ["john.doe@sap.com"] \ No newline at end of file