|
| 1 | +### |
| 2 | +# Create SAP BTP subaccount for default use caee |
| 3 | +### |
| 4 | +resource "btp_subaccount" "subaccount" { |
| 5 | + name = var.subacount_name |
| 6 | + subdomain = var.subacount_subdomain |
| 7 | + region = var.region |
| 8 | +} |
| 9 | + |
| 10 | +### |
| 11 | +# Add the entitlements to the subaccount |
| 12 | +### |
| 13 | +resource "btp_subaccount_entitlement" "entitlement-taskcenter" { |
| 14 | + subaccount_id = btp_subaccount.subaccount.id |
| 15 | + for_each = var.entitlements |
| 16 | + service_name = each.value.service_name |
| 17 | + plan_name = each.value.plan_name |
| 18 | +} |
| 19 | + |
| 20 | +### |
| 21 | +# Create Cloud Foundry environment |
| 22 | +### |
| 23 | +module "cloudfoundry_environment" { |
| 24 | + source = "./modules/envinstance-cloudfoundry/" |
| 25 | + subaccount_id = btp_subaccount.subaccount.id |
| 26 | + instance_name = var.cloudfoundry_org_name |
| 27 | + cloudfoundry_org_name = var.cloudfoundry_org_name |
| 28 | +} |
| 29 | + |
| 30 | +### |
| 31 | +# Create Cloud Foundry space and assign users |
| 32 | +### |
| 33 | +module "cloudfoundry_space" { |
| 34 | + source = "./modules/cloudfoundry-space/" |
| 35 | + cf_org_id = module.cloudfoundry_environment.org_id |
| 36 | + name = var.cloudfoundry_space_name |
| 37 | + cf_space_managers = var.cloudfoundry_space_managers |
| 38 | + cf_space_developers = var.cloudfoundry_space_developers |
| 39 | + cf_space_auditors = var.cloudfoundry_space_auditors |
| 40 | +} |
| 41 | + |
| 42 | +### |
| 43 | +# Assign the subaccount roles to the users |
| 44 | +### |
| 45 | +resource "btp_subaccount_role_collection_assignment" "subaccount-administrators" { |
| 46 | + subaccount_id = btp_subaccount.subaccount.id |
| 47 | + role_collection_name = "Subaccount Administrator" |
| 48 | + for_each = var.subaccount_admins |
| 49 | + user_name = each.value |
| 50 | + depends_on = [ |
| 51 | + btp_subaccount.subaccount |
| 52 | + ] |
| 53 | +} |
| 54 | + |
| 55 | + |
| 56 | +resource "btp_subaccount_role_collection_assignment" "subaccount-service-administrators" { |
| 57 | + subaccount_id = btp_subaccount.subaccount.id |
| 58 | + role_collection_name = "Subaccount Service Administrator" |
| 59 | + for_each = var.subaccount_service_admins |
| 60 | + user_name = each.value |
| 61 | + depends_on = [ |
| 62 | + btp_subaccount.subaccount |
| 63 | + ] |
| 64 | +} |
0 commit comments