Skip to content

Adopt DC mission 4441 (SAP Build Code) to correspond to Booster #261

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

Merged
merged 6 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 31 additions & 23 deletions released/usecases/services_apps/sap_build_code/step1/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ resource "terraform_data" "replacement" {
# ------------------------------------------------------------------------------------------------------
# Create the Cloud Foundry environment instance
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_entitlement" "cf" {
subaccount_id = btp_subaccount.build_code.id
service_name = "cloudfoundry"
plan_name = "build-code"
amount = 1
}

resource "btp_subaccount_environment_instance" "cf" {
subaccount_id = btp_subaccount.build_code.id
name = "cf-${random_id.subaccount_domain_suffix.hex}"
environment_type = "cloudfoundry"
service_name = "cloudfoundry"
plan_name = "standard"
plan_name = "build-code"
landscape_label = terraform_data.replacement.output

parameters = jsonencode({
Expand Down Expand Up @@ -94,7 +101,7 @@ resource "btp_subaccount_entitlement" "destination" {
service_name = "destination"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rui1610 I'm assuming we can't create the cicd destination without the destination service instance? I couldn't find the respective terraform BTP resource.

plan_name = "lite"
}
# Get serviceplan_id for cicd-service with plan_name "default"
# Get serviceplan_id for destination with plan_name "lite"
data "btp_subaccount_service_plan" "destination" {
subaccount_id = btp_subaccount.build_code.id
offering_name = "destination"
Expand Down Expand Up @@ -145,6 +152,7 @@ resource "btp_subaccount_entitlement" "build_code" {
subaccount_id = btp_subaccount.build_code.id
service_name = "build-code"
plan_name = "standard"
amount = 1
}
# Subscribe
resource "btp_subaccount_subscription" "build_code" {
Expand Down Expand Up @@ -178,13 +186,13 @@ resource "btp_subaccount_subscription" "sapappstudio" {
resource "btp_subaccount_entitlement" "sap_launchpad" {
subaccount_id = btp_subaccount.build_code.id
service_name = "SAPLaunchpad"
plan_name = "standard"
plan_name = "foundation"
}
# Subscribe
resource "btp_subaccount_subscription" "sap_launchpad" {
subaccount_id = btp_subaccount.build_code.id
app_name = "SAPLaunchpad"
plan_name = "standard"
plan_name = "foundation"
depends_on = [btp_subaccount_entitlement.sap_launchpad]
}

Expand Down Expand Up @@ -223,37 +231,37 @@ resource "btp_subaccount_subscription" "alm_ts" {
}

# ------------------------------------------------------------------------------------------------------
# Setup feature-flags-dashboard (Feature Flags Service)
# Setup sdm-web (Document Management Service)
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "feature_flags_dashboard" {
resource "btp_subaccount_entitlement" "sdm-web" {
subaccount_id = btp_subaccount.build_code.id
service_name = "feature-flags-dashboard"
plan_name = "dashboard"
service_name = "sdm-web"
plan_name = "build-code"
}
# Subscribe
resource "btp_subaccount_subscription" "feature_flags_dashboard" {
resource "btp_subaccount_subscription" "sdm-web" {
subaccount_id = btp_subaccount.build_code.id
app_name = "feature-flags-dashboard"
plan_name = "dashboard"
depends_on = [btp_subaccount_entitlement.feature_flags_dashboard]
app_name = "sdm-web"
plan_name = "build-code"
depends_on = [btp_subaccount_subscription.build_code, btp_subaccount_entitlement.sdm-web]
}

# ------------------------------------------------------------------------------------------------------
# Setup sdm-web (Document Management Service)
# Setup feature-flags-dashboard (Feature Flags Service)
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "sdm-web" {
resource "btp_subaccount_entitlement" "feature_flags_dashboard" {
subaccount_id = btp_subaccount.build_code.id
service_name = "sdm-web"
plan_name = "build-code"
service_name = "feature-flags-dashboard"
plan_name = "dashboard"
}
# Subscribe
resource "btp_subaccount_subscription" "sdm-web" {
resource "btp_subaccount_subscription" "feature_flags_dashboard" {
subaccount_id = btp_subaccount.build_code.id
app_name = "sdm-web"
plan_name = "build-code"
depends_on = [btp_subaccount_subscription.build_code, btp_subaccount_entitlement.sdm-web]
app_name = "feature-flags-dashboard"
plan_name = "dashboard"
depends_on = [btp_subaccount_entitlement.feature_flags_dashboard]
}

# ------------------------------------------------------------------------------------------------------
Expand All @@ -268,7 +276,7 @@ data "btp_subaccount_roles" "all" {
# ------------------------------------------------------------------------------------------------------
# Assign role collection for Build Code Administrator
# ------------------------------------------------------------------------------------------------------
# Assign roles to the role collection "Build Code Administrator"
# Create role collection "Build Code Administrator"
resource "btp_subaccount_role_collection" "build_code_administrator" {
subaccount_id = btp_subaccount.build_code.id
name = "Build Code Administrator"
Expand All @@ -279,7 +287,7 @@ resource "btp_subaccount_role_collection" "build_code_administrator" {
name = role.name
role_template_app_id = role.app_id
role_template_name = role.role_template_name
} if contains(["Business_Application_Studio_Administrator", "Administrator", "FeatureFlags_Dashboard_Administrator", "RegistryAdmin"], role.role_template_name)
} if contains(["Business_Application_Studio_Administrator", "Administrator", "FeatureFlags_Dashboard_Administrator", "RegistryAdmin", "SDM_Admin", "SDM_BusinessAdmin", "SDM_MigrationAdmin", "SuperAdmin", "SDMWeb_Admin", "SDMWeb_Migration"], role.role_template_name)
]
}
# Assign users to the role collection "Build Code Administrator"
Expand All @@ -305,7 +313,7 @@ resource "btp_subaccount_role_collection" "build_code_developer" {
name = role.name
role_template_app_id = role.app_id
role_template_name = role.role_template_name
} if contains(["Business_Application_Studio_Developer", "Developer", "FeatureFlags_Dashboard_Auditor", "RegistryDeveloper"], role.role_template_name)
} if contains(["Business_Application_Studio_Developer", "Developer", "FeatureFlags_Dashboard_Auditor", "RegistryDeveloper", "SDM_User", "Viewer", "Workzone_User", "SDMWeb_User"], role.role_template_name)
]
}
# Assign users to the role collection "Build Code Developer"
Expand Down
13 changes: 10 additions & 3 deletions released/usecases/services_apps/sap_build_code/step2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ To deploy the resources you must:

1. If you did not create a `tfvars` file in step 1 (via the variable `create_tfvars_file_for_step2`) you must manually Take the output of step 1 and transfer it in a `tfvars` file e.g. `sample.tfvars` file to meet your requirements. Of course you can also further adjust the generated `tfvars` file from step 1.

2. If not already done in step 1, initialize your workspace:
2. Export the variables for user name and password

```bash
export CF_USER='<Email address of your CF user>'
export CF_PASSWORD='<Password of your CF user>'
```

3. If not already done in step 1, initialize your workspace:

```bash
terraform init
```

3. You can check what Terraform plans to apply based on your configuration. If you use the generated `tfvars` file from step 1 you do not need need to explicitly add the filename to the command:
4. You can check what Terraform plans to apply based on your configuration. If you use the generated `tfvars` file from step 1 you do not need need to explicitly add the filename to the command:

```bash
terraform plan
Expand All @@ -28,7 +35,7 @@ To deploy the resources you must:
terraform plan -var-file="sample.tfvars"
```

4. According to the variants of step 3. apply your configuration to provision the resources either via:
5. According to the variants of step 3. apply your configuration to provision the resources either via:

```bash
terraform apply
Expand Down
157 changes: 114 additions & 43 deletions released/usecases/services_apps/sap_build_code/step2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ resource "btp_subaccount_entitlement" "mobile_services" {
subaccount_id = var.subaccount_id
service_name = "mobile-services"
plan_name = "build-code"
amount = 1
}
# Create the service instance
data "cloudfoundry_service" "mobile_services" {
Expand All @@ -73,96 +74,134 @@ resource "cloudfoundry_service_credential_binding" "mobile_services" {
}

# ------------------------------------------------------------------------------------------------------
# Setup cloud-logging
# Setup transport (standard)
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "cloud_logging" {
resource "btp_subaccount_entitlement" "transport_standard" {
subaccount_id = var.subaccount_id
service_name = "cloud-logging"
plan_name = "build-code"
service_name = "transport"
plan_name = "standard"
}
# Create the service instance
data "cloudfoundry_service" "cloud_logging" {
name = "cloud-logging"
depends_on = [btp_subaccount_entitlement.cloud_logging]
data "cloudfoundry_service" "transport_standard" {
name = "transport"
depends_on = [btp_subaccount_entitlement.transport_standard]
}
resource "cloudfoundry_service_instance" "cloud_logging" {
name = "default_cloud-logging"
resource "cloudfoundry_service_instance" "transport_standard" {
name = "default_transport_standard"
space = cloudfoundry_space.dev.id
type = "managed"
service_plan = data.cloudfoundry_service.cloud_logging.service_plans["build-code"]
depends_on = [cloudfoundry_space_role.space_manager, cloudfoundry_space_role.space_developer, cloudfoundry_org_role.organization_manager, btp_subaccount_entitlement.cloud_logging]
service_plan = data.cloudfoundry_service.transport_standard.service_plans["standard"]
depends_on = [cloudfoundry_space_role.space_manager, cloudfoundry_space_role.space_developer, cloudfoundry_org_role.organization_manager, btp_subaccount_entitlement.transport_standard]
}
# Create service key
resource "random_id" "service_key_cloud_logging" {
resource "random_id" "service_key_transport_standard" {
byte_length = 12
}
resource "cloudfoundry_service_credential_binding" "cloud_logging" {
resource "cloudfoundry_service_credential_binding" "transport_standard" {
type = "key"
name = join("_", ["defaultKey", random_id.service_key_cloud_logging.hex])
service_instance = cloudfoundry_service_instance.cloud_logging.id
name = join("_", ["defaultKey", random_id.service_key_transport_standard.hex])
service_instance = cloudfoundry_service_instance.transport_standard.id
}


# ------------------------------------------------------------------------------------------------------
# Setup alert-notification
# Setup transport (export)
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "alert_notification" {
resource "btp_subaccount_entitlement" "transport_export" {
subaccount_id = var.subaccount_id
service_name = "alert-notification"
plan_name = "build-code"
service_name = "transport"
plan_name = "export"
}
# Create the service instance
data "cloudfoundry_service" "alert_notification" {
name = "alert-notification"
depends_on = [btp_subaccount_entitlement.alert_notification]
data "cloudfoundry_service" "transport_export" {
name = "transport"
depends_on = [btp_subaccount_entitlement.transport_export]
}
resource "cloudfoundry_service_instance" "alert_notification" {
name = "default_alert-notification"
resource "cloudfoundry_service_instance" "transport_export" {
name = "default_transport_export"
space = cloudfoundry_space.dev.id
type = "managed"
service_plan = data.cloudfoundry_service.alert_notification.service_plans["build-code"]
depends_on = [cloudfoundry_space_role.space_manager, cloudfoundry_space_role.space_developer, cloudfoundry_org_role.organization_manager, btp_subaccount_entitlement.alert_notification]
service_plan = data.cloudfoundry_service.transport_export.service_plans["export"]
depends_on = [cloudfoundry_space_role.space_manager, cloudfoundry_space_role.space_developer, cloudfoundry_org_role.organization_manager, btp_subaccount_entitlement.transport_export]
}
# Create service key
resource "random_id" "service_key_alert_notification" {
resource "random_id" "service_key_transport_export" {
byte_length = 12
}
resource "cloudfoundry_service_credential_binding" "alert_notification" {
resource "cloudfoundry_service_credential_binding" "transport_export" {
type = "key"
name = join("_", ["defaultKey", random_id.service_key_alert_notification.hex])
service_instance = cloudfoundry_service_instance.alert_notification.id
name = join("_", ["defaultKey", random_id.service_key_transport_export.hex])
service_instance = cloudfoundry_service_instance.transport_export.id
}

# ------------------------------------------------------------------------------------------------------
# Setup transport
# Setup transport (operator)
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "transport" {
resource "btp_subaccount_entitlement" "transport_operator" {
subaccount_id = var.subaccount_id
service_name = "transport"
plan_name = "standard"
plan_name = "transport_operator"
}
# Create the service instance
data "cloudfoundry_service" "transport" {
data "cloudfoundry_service" "transport_operator" {
name = "transport"
depends_on = [btp_subaccount_entitlement.transport]
depends_on = [btp_subaccount_entitlement.transport_operator]
}
resource "cloudfoundry_service_instance" "transport" {
name = "default_transport"
resource "cloudfoundry_service_instance" "transport_operator" {
name = "default_transport_operator"
space = cloudfoundry_space.dev.id
type = "managed"
service_plan = data.cloudfoundry_service.transport.service_plans["standard"]
depends_on = [cloudfoundry_space_role.space_manager, cloudfoundry_space_role.space_developer, cloudfoundry_org_role.organization_manager, btp_subaccount_entitlement.transport]
service_plan = data.cloudfoundry_service.transport_operator.service_plans["transport_operator"]
depends_on = [cloudfoundry_space_role.space_manager, cloudfoundry_space_role.space_developer, cloudfoundry_org_role.organization_manager, btp_subaccount_entitlement.transport_operator]
}
# Create service key
resource "random_id" "service_key_transport" {
resource "random_id" "service_key_transport_operator" {
byte_length = 12
}
resource "cloudfoundry_service_credential_binding" "transport" {
resource "cloudfoundry_service_credential_binding" "transport_operator" {
type = "key"
name = join("_", ["defaultKey", random_id.service_key_transport.hex])
service_instance = cloudfoundry_service_instance.transport.id
name = join("_", ["defaultKey", random_id.service_key_transport_operator.hex])
service_instance = cloudfoundry_service_instance.transport_operator.id
}

# ------------------------------------------------------------------------------------------------------
# Setup cloud-logging
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "cloud_logging" {
subaccount_id = var.subaccount_id
service_name = "cloud-logging"
plan_name = "build-code"
amount = 1
}
# Create the service instance
data "cloudfoundry_service" "cloud_logging" {
name = "cloud-logging"
depends_on = [btp_subaccount_entitlement.cloud_logging]
}
resource "cloudfoundry_service_instance" "cloud_logging" {
name = "default_cloud-logging"
space = cloudfoundry_space.dev.id
type = "managed"
service_plan = data.cloudfoundry_service.cloud_logging.service_plans["build-code"]
parameters = jsonencode({
ingest_otlp = {
enable = "true"
}
})
depends_on = [cloudfoundry_space_role.space_manager, cloudfoundry_space_role.space_developer, cloudfoundry_org_role.organization_manager, btp_subaccount_entitlement.cloud_logging]
}
# Create service key
resource "random_id" "service_key_cloud_logging" {
byte_length = 12
}
resource "cloudfoundry_service_credential_binding" "cloud_logging" {
type = "key"
name = join("_", ["defaultKey", random_id.service_key_cloud_logging.hex])
service_instance = cloudfoundry_service_instance.cloud_logging.id
}

# ------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -218,6 +257,38 @@ resource "cloudfoundry_service_credential_binding" "feature_flags" {
service_instance = cloudfoundry_service_instance.feature_flags.id
}

# ------------------------------------------------------------------------------------------------------
# Setup alert-notification
# ------------------------------------------------------------------------------------------------------
# Entitle
resource "btp_subaccount_entitlement" "alert_notification" {
subaccount_id = var.subaccount_id
service_name = "alert-notification"
plan_name = "build-code"
amount = 1
}
# Create the service instance
data "cloudfoundry_service" "alert_notification" {
name = "alert-notification"
depends_on = [btp_subaccount_entitlement.alert_notification]
}
resource "cloudfoundry_service_instance" "alert_notification" {
name = "default_alert-notification"
space = cloudfoundry_space.dev.id
type = "managed"
service_plan = data.cloudfoundry_service.alert_notification.service_plans["build-code"]
depends_on = [cloudfoundry_space_role.space_manager, cloudfoundry_space_role.space_developer, cloudfoundry_org_role.organization_manager, btp_subaccount_entitlement.alert_notification]
}
# Create service key
resource "random_id" "service_key_alert_notification" {
byte_length = 12
}
resource "cloudfoundry_service_credential_binding" "alert_notification" {
type = "key"
name = join("_", ["defaultKey", random_id.service_key_alert_notification.hex])
service_instance = cloudfoundry_service_instance.alert_notification.id
}

# ------------------------------------------------------------------------------------------------------
# USERS AND ROLES
# ------------------------------------------------------------------------------------------------------
Expand Down