Skip to content

[UPDATE] DC Mission 3260 - QAS-compatible script and README update #249

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 40 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
87be52f
uc: events to business action
mahesh0431 Sep 10, 2023
839b422
Added Readme - UC - Events to Business Actions
mahesh0431 Sep 10, 2023
78211fe
Added the environment variables documentation
mahesh0431 Sep 10, 2023
bab3bee
documentation
mahesh0431 Sep 28, 2023
59b2047
Update provider.tf
rui1610 Oct 4, 2023
44ae93f
Update terraform.tfvars
rui1610 Oct 4, 2023
4e5b1fe
Merge branch 'main' of https://github.com/SAP-samples/btp-terraform-s…
mahesh0431 Oct 5, 2023
1c50fd0
new structure and btp provider changes
mahesh0431 Oct 6, 2023
3de3460
docu update
mahesh0431 Oct 6, 2023
26f27a2
removed .vscode folder
mahesh0431 Oct 6, 2023
f2bb479
readme update for dcmission 4172
mahesh0431 Oct 6, 2023
1f0bb8c
mission 4356
mahesh0431 Oct 9, 2023
f798413
Merge branch 'SAP-samples:main' into main
mahesh0431 Oct 15, 2023
4d7a739
DC Mission 4033 and updates to 4172 - AEM
mahesh0431 Oct 18, 2023
e47651a
cf space creation removed
mahesh0431 Oct 19, 2023
64eea9a
DC Missions - 4033,4172,4356 restructuring
mahesh0431 Oct 20, 2023
be23d0d
formatting
mahesh0431 Oct 20, 2023
b3bac56
dependencies update
mahesh0431 Oct 23, 2023
d320802
Merge branch 'main' of https://github.com/mahesh0431/btp-terraform-sa…
mahesh0431 Oct 28, 2023
a5faa05
4033 4356
mahesh0431 Jul 2, 2024
f39d743
4033 and 4356
mahesh0431 Jul 2, 2024
304b6d7
Merge branch 'main' of https://github.com/mahesh0431/btp-terraform-sa…
mahesh0431 Jul 2, 2024
16b8cb8
4033 and 4356
mahesh0431 Jul 2, 2024
c11a007
update variables
rui1610 Jul 2, 2024
4db86c8
rename folders
rui1610 Jul 2, 2024
9983ae0
4172 changes
mahesh0431 Jul 2, 2024
6008b6f
3501 changes
mahesh0431 Jul 3, 2024
35b3ad3
Merge pull request #1 from rui1610/main
mahesh0431 Jul 4, 2024
05e6378
fixes variables
mahesh0431 Jul 4, 2024
0fc1880
Merge branch 'SAP-samples:main' into main
mahesh0431 Jul 4, 2024
bcd9d19
formatting
mahesh0431 Jul 4, 2024
9cbda42
Merge branch 'main' of https://github.com/mahesh0431/btp-terraform-sa…
mahesh0431 Jul 4, 2024
7f63f8a
Merge branch 'main' into main
rui1610 Jul 9, 2024
425921d
Merge branch 'SAP-samples:main' into main
mahesh0431 Jul 9, 2024
1183d88
Merge branch 'SAP-samples:main' into main
mahesh0431 Jul 10, 2024
ceeefbc
DC Mission 3260 - QAS-compatible script and README update
mahesh0431 Jul 10, 2024
dd39f2d
fix variables read
mahesh0431 Jul 10, 2024
57ca854
Merge branch 'main' into main
rui1610 Jul 10, 2024
4bfcb1c
fix issues after merging
rui1610 Jul 10, 2024
a0bceda
update formating
rui1610 Jul 10, 2024
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
40 changes: 31 additions & 9 deletions released/discovery_center/mission_3260/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,45 @@ This script simplifies the majority of tasks in the [Discovery Center Mission](h

## Execution

1. Copy the `samples.tfvars` to a file called `terraform.tfvars` and fill in the values for the variables.
2. To authenticate and enable interaction with your BTP environments, ensure you set the necessary environment variables BTP_USERNAME and BTP_PASSWORD
1. Set the environment variables BTP_USERNAME and BTP_PASSWORD to pass credentials to the BTP provider to authenticate and interact with your BTP environments.

```bash
Mac & Linux
export BTP_USERNAME=<your_username>
export BTP_PASSWORD=<your_password>
export CF_USER=<your_username>
export CF_PASSWORD=<your_password>

Windows(PS)
$env:BTP_USERNAME=<your_username>
$env:BTP_PASSWORD=<your_password>
$env:CF_USER=<your_username>
$env:CF_PASSWORD=<your_password>
```

3. Execute a `terraform init` to initialize the terraform providers and modules.
4. Execute a `terraform plan` to see what resources will be created.
5. Execute a `terraform apply` to create the resources.
2. Change the variables in the `samples.tfvars` file to meet your requirements

> ⚠ NOTE: You should pay attention **specifically** to the users defined in the samples.tfvars whether they already exist in your SAP BTP accounts. Otherwise you might get error messages like e.g. `Error: The user could not be found: jane.doe@test.com`.


3. Initialize your workspace:

```bash
terraform init
```

4. You can check what Terraform plans to apply based on your configuration:

```bash
terraform plan -var-file="samples.tfvars"
```

5. Apply your configuration to provision the resources:

```bash
terraform apply -var-file="samples.tfvars"
```

## In the end

You probably want to remove the assets after trying them out to avoid unnecessary costs. To do so execute the following command:

```bash
terraform destroy
```
3 changes: 3 additions & 0 deletions released/discovery_center/mission_3260/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
locals {
service_name__sap_process_automation = "process-automation"
}
74 changes: 54 additions & 20 deletions released/discovery_center/mission_3260/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@ locals {
# Creation of subaccount
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount" "dc_mission" {
count = var.subaccount_id == "" ? 1 : 0
name = var.subaccount_name
subdomain = local.subaccount_domain
region = lower(var.region)
usage = "USED_FOR_PRODUCTION"
}

data "btp_subaccount" "dc_mission" {
id = var.subaccount_id != "" ? var.subaccount_id : btp_subaccount.dc_mission[0].id
}
# ------------------------------------------------------------------------------------------------------
# Assign custom IDP to sub account (if custom_idp is set)
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_trust_configuration" "fully_customized" {
# Only create trust configuration if custom_idp has been set
count = var.custom_idp == "" ? 0 : 1
subaccount_id = btp_subaccount.dc_mission.id
subaccount_id = data.btp_subaccount.dc_mission.id
identity_provider = var.custom_idp
}

Expand All @@ -33,7 +38,7 @@ resource "btp_subaccount_trust_configuration" "fully_customized" {
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_role_collection_assignment" "subaccount-admins" {
for_each = toset(var.subaccount_admins)
subaccount_id = btp_subaccount.dc_mission.id
subaccount_id = data.btp_subaccount.dc_mission.id
role_collection_name = "Subaccount Administrator"
user_name = each.value
}
Expand All @@ -43,7 +48,7 @@ resource "btp_subaccount_role_collection_assignment" "subaccount-admins" {
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_role_collection_assignment" "subaccount-service-admins" {
for_each = toset(var.subaccount_service_admins)
subaccount_id = btp_subaccount.dc_mission.id
subaccount_id = data.btp_subaccount.dc_mission.id
role_collection_name = "Subaccount Service Administrator"
user_name = each.value
}
Expand All @@ -52,10 +57,9 @@ resource "btp_subaccount_role_collection_assignment" "subaccount-service-admins"
# ------------------------------------------------------------------------------------------------------
# CLOUDFOUNDRY PREPARATION
# ------------------------------------------------------------------------------------------------------
#
# Fetch all available environments for the subaccount
data "btp_subaccount_environments" "all" {
subaccount_id = btp_subaccount.dc_mission.id
subaccount_id = data.btp_subaccount.dc_mission.id
}
# ------------------------------------------------------------------------------------------------------
# Take the landscape label from the first CF environment if no environment label is provided
Expand All @@ -64,11 +68,9 @@ data "btp_subaccount_environments" "all" {
resource "terraform_data" "replacement" {
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.dc_mission.id
subaccount_id = data.btp_subaccount.dc_mission.id
name = local.subaccount_cf_org
environment_type = "cloudfoundry"
service_name = "cloudfoundry"
Expand All @@ -79,27 +81,59 @@ resource "btp_subaccount_environment_instance" "cloudfoundry" {
})
}

# ------------------------------------------------------------------------------------------------------
# Create service instance - SAP Build Process Automation service
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_entitlement" "build_process_automation" {
subaccount_id = data.btp_subaccount.dc_mission.id
service_name = local.service_name__sap_process_automation
plan_name = var.service_plan__sap_process_automation
}

# Create app subscription to SAP Build Process Automation
resource "btp_subaccount_subscription" "build_process_automation" {
subaccount_id = data.btp_subaccount.dc_mission.id
app_name = local.service_name__sap_process_automation
plan_name = var.service_plan__sap_process_automation
depends_on = [btp_subaccount_entitlement.build_process_automation]
}

# Assign users to Role Collection: ProcessAutomationAdmin
resource "btp_subaccount_role_collection_assignment" "bpa_admin" {
for_each = toset(var.process_automation_admins)
subaccount_id = data.btp_subaccount.dc_mission.id
role_collection_name = "ProcessAutomationAdmin"
user_name = each.value
}

resource "btp_subaccount_role_collection_assignment" "sbpa_participants" {
depends_on = [btp_subaccount_subscription.build_process_automation]
for_each = toset(var.process_automation_participants)
subaccount_id = data.btp_subaccount.dc_mission.id
role_collection_name = "ProcessAutomationParticipant"
user_name = each.value
}

resource "btp_subaccount_role_collection_assignment" "sbpa_developers" {
depends_on = [btp_subaccount_subscription.build_process_automation]
for_each = toset(var.process_automation_developers)
subaccount_id = data.btp_subaccount.dc_mission.id
role_collection_name = "ProcessAutomationDeveloper"
user_name = each.value
}

# ------------------------------------------------------------------------------------------------------
# Create service instance - SAP Build Process Automation service
# ------------------------------------------------------------------------------------------------------
resource "btp_subaccount_entitlement" "bpa" {
subaccount_id = btp_subaccount.dc_mission.id
subaccount_id = data.btp_subaccount.dc_mission.id
service_name = "process-automation"
plan_name = "free"
}

resource "btp_subaccount_subscription" "bpa" {
subaccount_id = btp_subaccount.dc_mission.id
subaccount_id = data.btp_subaccount.dc_mission.id
app_name = "process-automation"
plan_name = "free"
depends_on = [btp_subaccount_entitlement.bpa]
}

# Assign users to Role Collection: ProcessAutomationAdmin
resource "btp_subaccount_role_collection_assignment" "bpa_admin" {
for_each = toset(var.business_process_automation_admins)
subaccount_id = btp_subaccount.dc_mission.id
role_collection_name = "ProcessAutomationAdmin"
user_name = each.value
depends_on = [btp_subaccount_subscription.bpa]
}
5 changes: 3 additions & 2 deletions released/discovery_center/mission_3260/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
output "subaccount_id" {
value = btp_subaccount.dc_mission.id

value = data.btp_subaccount.dc_mission.id
description = "The ID of the subaccount."
}

Expand All @@ -11,4 +12,4 @@ output "cf_org_id" {
output "bpa_url" {
value = btp_subaccount_subscription.bpa.subscription_url
description = "Subscription URL for SAP Business Process Automation"
}
}
14 changes: 8 additions & 6 deletions released/discovery_center/mission_3260/samples.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
# Your global account subdomain
globalaccount = "youraccount"
region = "us10"
subaccount_name = "Discovery Center mission 3260 - build Events-to-Business actions"
#cf_landscape_label = "cf-us10"
#custom_idp = "xxxx"
subaccount_name = "Discovery Center mission 3260 - Process and approve your invoices with SAP Build Process Automation"

service_plan__sap_process_automation = "free"

# ------------------------------------------------------------------------------------------------------
# Project specific configuration (please adapt!)
# ------------------------------------------------------------------------------------------------------
subaccount_admins = ["another.user@test.com"]
subaccount_service_admins = ["another.user@test.com"]
business_process_automation_admins = ["another.user@test.com", "you@test.com"]
# Don't add the user, that is executing the TF script to subaccount_admins or subaccount_service_admins!
subaccount_admins = ["jane.doe@test.com", "john.doe@test.com"]
subaccount_service_admins = ["jane.doe@test.com", "john.doe@test.com"]
business_process_automation_admins = ["jane.doe@test.com", "john.doe@test.com"]

34 changes: 33 additions & 1 deletion released/discovery_center/mission_3260/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ variable "globalaccount" {
variable "subaccount_name" {
type = string
description = "The subaccount name."
default = "UC - Build resilient BTP Apps"
default = "DC Mission 3260 - Process and approve your invoices with SAP Build Process Automation"
}

# subaccount id
variable "subaccount_id" {
type = string
description = "The subaccount ID."
Expand Down Expand Up @@ -64,8 +65,39 @@ variable "subaccount_service_admins" {
default = ["jane.doe@test.com", "john.doe@test.com"]
}


# Process automation Variables
variable "service_plan__sap_process_automation" {
type = string
description = "The plan for SAP Build Process Automation"
default = "standard"

validation {
condition = contains(["standard", "free"], var.service_plan__sap_process_automation)
error_message = "Invalid value for service_plan__sap_process_automation. Only 'standard' and 'free' are allowed."
}
}

variable "process_automation_admins" {
type = list(string)
description = "Defines the users who have the role of ProcessAutomationAdmin in SAP Build Process Automation"
}

variable "process_automation_developers" {
type = list(string)
description = "Defines the users who have the role of ProcessAutomationDeveloper in SAP Build Process Automation"
}

variable "process_automation_participants" {
type = list(string)
description = "Defines the users who have the role of ProcessAutomationParticipant in SAP Build Process Automation"
default = ["jane.doe@test.com", "john.doe@test.com"]
}


variable "business_process_automation_admins" {
type = list(string)
description = "Defines the colleagues who are added as administrators for the SAP Business Process Automation."
default = ["jane.doe@test.com", "john.doe@test.com"]
}