Automate Account Operations with the Command Line Interface (CLI)
- How to use a script to automate account admin processes
Prerequisites
- You have an account on SAP BTP. You can check out steps 1-7 of the tutorial on how to Get an Account on SAP BTP to Try Out Free Tier Service Plans (we will automate the rest in this tutorial here).
- You have the Cloud Foundry CLI, as described in Installing the cf CLI.
- You have a UNIX-like environment.
With the introduction of cloud management tools feature set B to SAP BTP, the stars of the show are without a doubt the new REST APIs and command line. With these features, you now have many more options to automate your account administrative flows in SAP BTP.
The REST APIs are offered for each administrative operation available in the SAP BTP cockpit. The API Reference is integrated into the SAP API Business Hub so users can quickly learn how to leverage it for your own use cases. For example, for automating manual operations that until now could only be done via the cockpit.
If you prefer to use a terminal with CLI commands, the SAP BTP command line interface (btp CLI) also offers the operations available in the cockpit, with an integrated help so that you can quickly identify and execute commands to operate your global account in SAP BTP and your resources manually or automatically via scripts.
This tutorial is designed for a UNIX-like environment, such as macOS or Linux.
About this tutorial
In this tutorial, you are a DevOps engineer for Atomic, which develops innovative solutions for its customers on top of SAP BTP. Atomic also uses partner companies for developing solutions.
Every time a new development project begins, Atomic’s DevOps department needs to set up a development environment on SAP BTP.
According to Atomic’s guidelines and standards, each such development environment must include in their account model a directory, which contains three subaccounts for each of the relevant stages, namely, Dev, Test, and Prod. In addition, each subaccount must have an entitlement for two services:
SAP Alert Notification service for SAP BTP
SAP HANA Cloud
Setting up such an environment for each new project can be very tedious and time-consuming. Luckily, the btp CLI can be used to automate these operations – a new environment can be set up very quickly with the single click of a button.
In this tutorial, you act as a member of Atomic’s DevOps department. Your department has decided to use the btp CLI to automate these operations, including the creation of a Cloud Foundry space and an instance of the SAP HANA Cloud service in the space.
For this example, you can download an automation script that we’ve prepared in advance and execute it to set up the new environment.
The script will do the following:
Log in to your global account on SAP BTP.
Create a new directory in your account model.
Assign two service entitlement plans (for the SAP HANA Cloud and the SAP Alert Notification services) to the directory.
Create three subaccounts in the directory.
Enable the Cloud Foundry environment and creates an org for each subaccount.
Log in to Cloud Foundry.
Create a space in the Cloud Foundry org of one of the subaccounts.
Create an instance of the SAP HANA Cloud (
hana-free
) service in the space.
Through this tutorial, we hope we can help you to unleash the power of CLI script-based automation for your account admin processes on SAP BTP.