btp-setup-automator
btp-setup-automator copied to clipboard
[FEATURE REQUEST] Automate creation of sub-account within a directory
Which area is mainly impacted
Configuration
Requested Feature
I have not seen how to create a sub-account within a provided directory? We need to create sub-accounts within Customer directories (to help organize our efforts) and would prefer to not manually have to move sub-accounts once created with the automator.

Preferred expectation using automator:

Use Case/Scenario
This will allow the new sub-account to be created directly within a Customer space within the Global Account (our use case has a 3 sub accounts (dev, qa, preprod) for all customers to aid in organization, and distinct spaces for our different environments (and in some cases customer contractual requirements)
This will limit manual effort to go back in and manually move the newly created sub account from the root directory, to their designated space.
Would you like to support us?
- [ ] Yes, I would like to support you
Anything else?
No response
Creation of directory: https://help.sap.com/docs/BTP/btp-cli/btp-create-accounts-directory.html
Assignment of subaccount to directory: https://help.sap.com/docs/BTP/btp-cli/btp-create-accounts-subaccount.html
Tasks:
- [X] Adjust JSON File for parameters to allow specification of directory and referencing of directory when defining subaccount
- [X] Implement creations of directory if required and store mapping of name from
parameters.jsonto ID after creation - [X] Enhance creation of subaccount to reference directory if specified (use mapping of name to id)
As the implementation might take a bit, you can use the "executeAfterAccountSetup" for directory creation and move of the subaccount under the directory to proceed with the automatic setup of the account. As the BTP CLI is available this would be the commands
- Creation of the directory via https://help.sap.com/docs/BTP/btp-cli/btp-create-accounts-directory.html
- Movement of the subaccount created via btpsa using https://help.sap.com/docs/BTP/btp-cli/btp-move-accounts-subaccount.html
Thank you - Is there a way to obtain the newly created subaccount and directory IDs to move the subaccount into the newly created directly within the automator process?
The information is stored in the directory: /log as metadata_log.json in the container. The data is stored as JSON, yo you can access the subaccount ID via jq.
The subaccountid can be fetched via:
jq '.subaccountid' ./log/metadata_log.json
You must fetch the directory ID via btp cli
OK Thanks You. I believe I have what I need to proceed.
Reopening, as this is a valid request that should be available as part of the btpsa
Solution via PR #279 :
Basic configuration is done via usedirectory in parameters.json. This boolean parameter defines if a directory should be used/created when setting up the subaccount.
The following options exist for the further specification:
-no further parameters: A new directory is created; naming is derived by tool
-specification of directoryname: a new directory is created using this name. If a directory with the same name exists, this will be taken
-specification of directoryid (= existing directory): the corresponding directory will be used when the subaccount is created.
Restrictions:
- you can only specify one directory and assign one subaccount to it
- you can only specify a directory name when creating a new one
- you cannot define nested structures (directory in directory)
To have the functionality fetch the latest version of the main branch of the repository or pull the latest Docker Image (sha sha256:254dc2c14918c45f7aed198ed4040748b0f433cb9e6aeec14becc53baf54e217)
I have not yet downloaded the new image, but I am seeing this when creating a new directory and sub-account.
I run the automator to create 1) the new directory (CustomerName) and 2) the subaccount (dev). Items are created as one would expect.

2nd, I manually move the newly created sub-account into the newly created directory.

3rd, I update the parameters file to change the Customer Name, and re-run the automator. However, there is no new sub-account created in the root of the Global Account, as I believe the system is still seeing the 1st sub-account tied to the root, and not moved into the CustomerName folder.

Is this expected behavior or an issue?
Our structure is laid out in a structure similar to this:
Region --> Customer Name --> Connector Name --> Sub Account. (sub accounts will always have a 1-Dev, 2-QA, 3-PreProd (and if applicable 4-Prod) listings.

It appears we cannot retain our existing naming convention with the automator unless we're able to create the sub-account in the newly created folder, however I see that nesting is not allowed.
How many we overcome these issues while still retaining the use of the automator? Must we change to having a unique name such as appending a CustomerName prefix to all sub-accounts?
Concerning your description: do you change the name of the subaccount that needs to be created? If not the tool will probably pick up the existing dev account as it does a matching via the name.
The scenarios you describe/target are currently not supported. I would recommend to motivate your organization to contribute to the tool, enhance its functionality in order to enable the support of your scenarios.
We would not change the name between customers, all would have a 1-Dev, 2-QA, 3-PreProd under their own directory. It seems our best course of action would be to prefix the sub-accounts with a customer identifier, as I am not a coder by profession, or able to support that role. Thank you.
Quick question - you stated this: "If not the tool will probably pick up the existing dev account as it does a matching via the name."
So, even if the sub-account has been moved to a different sub-directory, the tool will still find that original (but moved) sub-account and re-use that instead of creating a new one in the root directory. If that is understood correctly, we will accommodate our naming convention. Thank You.
Yes a different name will do the trick, as the tool (as well as the BTP CLI) fetches the subaccounts independent of their parent nodes (be it global account or a directory).