In this exercise, we will enhance the existing configuration to setup SAP Build Process Automation using a Terraform module.
Note
You find the solution for this exercise in the solutions/ex4 folder.
After completing these steps, you will know how the module for SAP Build Process Automation is structured.
As for the SAP Build Code scenario in the previous step, the setup comprises several components:
- Assignment of the entitlement for SAP Build Process Automation to the subaccount.
- Subscription to the SAP Build Process Automation application.
- Assignment of the role collections to the users to access the application.
As before we use a module for these tasks that is available in the folder modules/build_process_automation
. The structure corresponds to the previous exercise. Take a few minutes to review the files in the module. Use this as a knowledge check from the previous exercise.
Once finished let us start to integrate the module into our main configuration.
After completing these steps, you will have enhanced the configuration to setup SAP Build Process Automation.
-
As the new module comes with new variables, we must add them to our configuration. Open the
variables.tf
file, add the following code and save your changes: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" }
This input will be used for the role collection assignments in the module.
-
We also need to provide the values for these variables to assign ourselves to the role collections to have access to SAP Build Process Automation. You already know the game. Open the
terraform.tfvars
file and add the following code:# users for SAP Build Process Automation process_automation_admins = ["[email protected]"] process_automation_developers = ["[email protected]"] process_automation_participants = ["[email protected]"]
Replace all occurrences of
[email protected]
with the email address of your SAP BTP user and save the changes. -
Next we need to add the module to our configuration. Open the
main.tf
file and add the following code:module "build_process_automation" { source = "../modules/build_process_automation" subaccount_id = btp_subaccount.sa_build.id process_automation_admins = var.process_automation_admins process_automation_developers = var.process_automation_developers process_automation_participants = var.process_automation_participants }
As in the previous exercise We provided the parameters based on our variables and the ID of the subaccount
btp_subaccount.sa_build.id
. Save your changes. -
As final step we propagate the output of the module via the outputs of our configuration. Open the
outputs.tf
file and add the following code:output "url_sap_build_process_automation" { value = module.build_process_automation.url_build_process_automation }
Save your changes and do ... yes the formatting exercise via:
terraform fmt
After completing these steps, you will have executed the Terraform configuration and successfully created the SAP Build Process Automation resources in your subaccount.
-
As we added another module to our setup we must reinitialize the configuration to make Terraform aware of this. To achieve this execute the following command:
terraform get
which results in the following output:
As in the previous step, this adds the newly added module to the setup needed by Terraform.
Note
In contrast to the initial setup via terraform init
we want to restrict the re-initialization to the newly added modules. We achieve this by using terraform get
. If you want to re-initialize the setup including provider versions you should execute terraform init -upgrade
. Be aware that this could result in newer provider versions depending on the version constraints of your provider configuration.
-
As in the previous exercises, let us validate the new configuration
terraform validate
This should show no errors. We can continue with the Terraform flow.
-
We want to check what Terraform will do when we apply the new configuration via:
terraform plan -out=tfplan
As we already have a resource created on SAP BTP this step is important to validate if the configuration is acting as expected. We also saved the plan to a file for later use.
Looking at the output, this looks like what we expected. Some resources will be addedd, but no changes to existing ones and no deletions:
-
As the planning looked good, let's apply the plan (this might take a bit):
terraform apply tfplan
As a result we see that Terraform created the resources for SAP Build Process Automation. The new output variable also shows up in the
Outputs
section at the end of the log from the Terraform CLI:When clicking on the
url_sap_build_code
you should be routed to the SAP Build lobby and you can create your first app or an automation flow:A quick cross-check in the SAP BTP cockpit shows us the new resources as part of our subaccount:
That's it folks! You've now completed the setup of an environment on SAP BTP comprising:
- The creation of an SAP BTP subaccount
- The setup of SAP Build Code
- The setup of SAP Build Process Automation
We hope you enjoyed the ride and learned something new along the way. If you have any questions or feedback, please don't hesitate to reach out to us.
With that ... happy Terraforming! 🚀
Terraform also makes it easy for you to clean up the setup. If you want to remove this setup from your trial execute the following command:
terraform destroy
This will trigger another round of planning. Check the result if the resources that are planned for destroy match your expectations:
If they do confirm the destroy operation and enjoy the show. After the command has successfully finished, the output shows that all resources have been destroyed:
All resources you created via Terraform are now deleted from your trial account on SAP BTP.