BTP(SAP Business Technology Platform)の構築を、BTP CLIコマンドで行う方法を調査した。
1. BTP CLI のダウンロード
- 以下のURLから、環境に合わせたモジュールをダウンロードする。
https://tools.hana.ondemand.com/#cloud

- ダウンロードしたファイルを展開し、任意ディレクトリに保存
例:C:\btp\windows-amd64\btp

2. BTPにログイン
- コマンドプロンプトで カレントディレクトリを C:\btp\windows-amd64\btpに移動する。
- 以下を実行し、BTPにログインする。
btp login - CLI server URL [https://cli.btp.cloud.sap]> と出力されるため、そのままEnterキーを押下
- 以下を入力する。
User:<BTPのログインユーザ>
Password:<BTPのログインユーザパスワード>

仮に、グローバルアカウント上で作業を行う場合は、後続の手順「3.作業対象のサブアカウントに移動」以降は行わず、ここで必要な作業を実行する。
例)サブアカウントを新規作成する場合は以下を実行する。
btp create accounts/subaccount –display-name {サブアカウント名} –region {リージョン}
–subdomain {サブドメイン名}
btp create accounts/subaccount –display-name “TEST_Subaccount” –region us10 –subdomain test-subaccount-subdomain

3. 作業対象のサブアカウントに移動
- 以下を実行し、作業対象のSubaccountのIDを確認する。
btp list accounts/subaccount

- 以下を実行し、対象のSubaccountに移動する。
btp target –subaccount {subaccount id※}
例)btp target –subaccount d2b74ffe-c93c-4826-841d-4f976e83eb3c

4. 必要な作業を行う
以下のリファレンスを参照して、必要なコマンドを実行する。
https://help.sap.com/docs/btp/btp-cli-command-reference/btp-cli-command-reference
例1.)対象サブアカウントのインスタンスのリストの一覧を表示。
btp list services/instance

例2.)ロールの一覧表示
btp list security/role

例3) ロールテンプレートからロールを作成
btp create security/role {ロール名} –of-app {アプリケーションID} –of-role-template {ロールテンプレート名} –description {説明文}
